Skip to content

Conversation

zac-nixon
Copy link
Collaborator

@zac-nixon zac-nixon commented May 21, 2025

Description

Adds support for attaching labels and annotations from the Gateway to the created TargetGroupBinding(s) for a Gateway:
https://gateway-api.sigs.k8s.io/reference/spec/#gatewayinfrastructure

I had to refactor the TargetGroupBinding manager to support changing of annotations and labels. While making these changes I backfilled tests as the TGB manager had no tests previously.

E2E tests:

  • Gateway that has no labels / annotations
  • Gateway that has only labels, no annotations
  • Gateway that has only annotations, no labels
  • Gateway that has annotations and labels
  • TGB reconciles don't trigger un-neccessary patches.
  • Service reconciles still work
  • Ingress reconciles still work.

Tested:

apiVersion: v1
items:
- apiVersion: elbv2.k8s.aws/v1beta1
  kind: TargetGroupBinding
  metadata:
    annotations:
      annfoo3: annbar3
      elbv2.k8s.aws/checkpoint: PbfnUfSBkLuy55ms0JcKGKB5F6F8rWHDj49LCpvaRQE/5_Y2kXP4aJv81kgYF7I1U-ZE4WlqR-sLG2E-WXmJhUM
      elbv2.k8s.aws/checkpoint-timestamp: "1747837898"
    creationTimestamp: "2025-05-20T15:28:35Z"
    finalizers:
    - elbv2.k8s.aws/resources
    generation: 1
    labels:
      foo3: bar3
      gateway.k8s.aws.nlb/stack-name: test-gw-nlb
      gateway.k8s.aws.nlb/stack-namespace: gateway-nlb
    name: k8s-gatewayn-tcpapp1-0ddf17a33d
    namespace: gateway-nlb
    resourceVersion: "28321176"
    uid: 5741d762-7c62-4113-b012-44f0a1cfa91c
  spec:
    ipAddressType: ipv4
    networking:
      ingress:
      - from:
        - securityGroup:
            groupID: sg-09dbde371ea398a10
        ports:
        - port: 30265
          protocol: TCP
    serviceRef:
      name: echoserver
      port: 80
    targetGroupARN: arn:aws:elasticloadbalancing:us-east-1:565768096483:targetgroup/k8s-gatewayn-tcpapp1-8cfc832478/4a9f1df33dd36c18
    targetType: instance
    vpcID: vpc-02c95a92410c1c1f2
  status:
    observedGeneration: 1
kind: List
metadata:
  resourceVersion: ""

Checklist

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the docs directory)
  • Manually tested
  • Made sure the title of the PR is a good description that can go into the release notes

BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯

  • Backfilled missing tests for code in same general area 🎉
  • Refactored something and made the world a better place 🌟

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 21, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zac-nixon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 21, 2025
@shraddhabang
Copy link
Collaborator

/lgtm
/approved

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 21, 2025
@k8s-ci-robot k8s-ci-robot merged commit 8ed0f0e into kubernetes-sigs:main May 21, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants