Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for internal service specific labels #12704

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

samuelarogbonlo
Copy link

@samuelarogbonlo samuelarogbonlo commented Jan 14, 2025

Add support for internal service specific labels
Fixes #12428

Description
This PR adds the ability to specify labels specifically for the internal ingress-nginx service without affecting the main controller service. This is particularly useful for use cases like external-dns configuration where labels need to be set only on the internal service.

Changes

  • Modified templates/controller-service-internal.yaml to support internal-specific labels
  • Removed mandatory annotations requirement for internal service
  • Fixed indentation in templates/controller-deployment.yaml
  • Added test case for internal service labels

Code Changes

  1. Added support for internal-specific labels:
 labels:
    {{- include "ingress-nginx.labels" . | nindent 4 }}
    app.kubernetes.io/component: controller
  {{- if .Values.controller.service.internal.labels }}
    {{- toYaml .Values.controller.service.internal.labels | nindent 4 }}
  {{- end }}
  1. Removed mandatory annotations requirement:

From

{{- if and .Values.controller.service.enabled .Values.controller.service.internal.enabled .Values.controller.service.internal.annotations -}}

To

{{- if and .Values.controller.service.enabled .Values.controller.service.internal.enabled -}}

Testing Performed
Tested the following scenarios:

  1. Adding custom labels to internal service only
  2. Verifying label isolation (labels on internal service don't appear on main service)
  3. Creating internal service without requiring annotations
  4. Confirming template renders correctly

Test configuration added in:
charts/ingress-nginx/ci/controller-service-internal-labels-values.yaml

Usage Example

controller:
  service:
    internal:
      enabled: true
      labels:
        external-dns.alpha.kubernetes.io/hostname: internal.example.com
        custom-label: test-value

Backward Compatibility
This change maintains backward compatibility by:

  • Not changing behavior for existing configurations
  • Only removing restrictions (required annotations)
  • Preserving all existing label inheritance where appropriate
  • Not requiring configuration of internal labels

Checklist

  • [ ✅ ] Code follows repository style and conventions
  • [ ✅ ] Templates render correctly
  • [ ✅ ] Added test configuration
  • [ ✅ ] Maintains backward compatibility
  • [ ✅ ] Verified label isolation works as expected

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/helm Issues or PRs related to helm charts labels Jan 14, 2025
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jan 14, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: samuelarogbonlo
Once this PR has been reviewed and has the lgtm label, please assign gacko for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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
Copy link
Contributor

Welcome @samuelarogbonlo!

It looks like this is your first PR to kubernetes/ingress-nginx 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/ingress-nginx has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 14, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @samuelarogbonlo. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-priority size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 14, 2025
Copy link

netlify bot commented Jan 14, 2025

Deploy Preview for kubernetes-ingress-nginx canceled.

Name Link
🔨 Latest commit 748a1eb
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-ingress-nginx/deploys/678791a3bf6d70000837dde9

@samuelarogbonlo samuelarogbonlo force-pushed the feat/add-internal-service-labels branch from 1f89703 to 17827d8 Compare January 14, 2025 23:12
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jan 14, 2025
@samuelarogbonlo samuelarogbonlo force-pushed the feat/add-internal-service-labels branch from 17827d8 to 66edf87 Compare January 14, 2025 23:18
@Gacko
Copy link
Member

Gacko commented Jan 15, 2025

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 15, 2025
@samuelarogbonlo samuelarogbonlo force-pushed the feat/add-internal-service-labels branch from 66edf87 to 13f3e6c Compare January 15, 2025 08:59
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 15, 2025
@samuelarogbonlo samuelarogbonlo force-pushed the feat/add-internal-service-labels branch 2 times, most recently from 8a66548 to 2e25b63 Compare January 15, 2025 10:27
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 15, 2025
Copy link
Member

@Gacko Gacko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better! Thank you! Please also consider adding unit tests in the tests/ directory.

Comment on lines +583 to +584
labels: {}
# -- Type of the internal controller service.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess something went wrong here, right?

Comment on lines +15 to +17
{{- if .Values.controller.service.internal.labels }}
{{- toYaml .Values.controller.service.internal.labels | nindent 4 }}
{{- end }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better! Could you now also add such a field to the external service?

@@ -11,3 +11,6 @@ controller:
enabled: true
annotations:
service.beta.kubernetes.io/aws-load-balancer-internal: "true"
labels:
external-dns.alpha.kubernetes.io/hostname: internal.example.com

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@samuelarogbonlo samuelarogbonlo force-pushed the feat/add-internal-service-labels branch from 2e25b63 to 53ff818 Compare January 15, 2025 10:36
This change allows configuring labels specifically for the internal
service without affecting the main controller service, useful for
external-dns configuration.

The commit also includes minor YAML indentation fixes in the
deployment template.
@samuelarogbonlo samuelarogbonlo force-pushed the feat/add-internal-service-labels branch from 53ff818 to 748a1eb Compare January 15, 2025 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/helm Issues or PRs related to helm charts cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Helm chart] support adding separate labels for the ingress-nginx-controller-internal service
3 participants