Skip to content

Conversation

@Jacobious52
Copy link

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR adds two new features to the Helm chart:

1. serviceAccount.automountServiceAccountToken

Allows controlling whether the service account token is automatically mounted. This is useful for security hardening when using projected volumes for manual token access instead of automatic mounting.

Usage:

serviceAccount:
  automountServiceAccountToken: false

Only renders when explicitly set, preserving default Kubernetes behavior (no diff when omitted).

2. commonAnnotations

Adds the ability to specify annotations that will be applied to all resources created by the chart. This is useful for:

  • Organizational metadata
  • Ownership tracking
  • Policy enforcement (e.g., cost allocation, compliance)

Usage:

commonAnnotations:
  my-org.com/owner: platform-team
  my-org.com/cost-center: "12345"

Applied to: ServiceAccount, ClusterRoles, ClusterRoleBindings, RoleBinding, Service, Deployment, PDB, APIService.

3. Arg ordering improvement

Moves --secure-port arg after defaultArgs for better flexibility when users need to control argument ordering.
Required when using a custom image and entry point and need to specify metrics-server binary.

Which issue(s) this PR fixes:

None - new feature request.

Special notes for your reviewer:

  • All changes are backward compatible
  • No Chart.yaml modifications per contributing guidelines
  • When automountServiceAccountToken is not set, no diff is produced (uses Kubernetes default)
  • commonAnnotations is merged with resource-specific annotations (e.g., service.annotations), with resource-specific taking precedence

Does this PR introduce a user-facing change?

chart: Add serviceAccount.automountServiceAccountToken and commonAnnotations support

…upport

This PR adds two new features to the Helm chart:

1. **serviceAccount.automountServiceAccountToken**: Allows controlling whether
   the service account token is automatically mounted. Useful for security
   hardening when using projected volumes for token access. Only renders when
   explicitly set, preserving default Kubernetes behavior.

2. **commonAnnotations**: Adds the ability to specify annotations that will be
   applied to all resources created by the chart. This is useful for
   organizational metadata, ownership tracking, or policy enforcement.

Additionally, moves --secure-port arg after defaultArgs for better arg ordering
flexibility.

All features are backward compatible with existing deployments.

Signed-off-by: jgonzalez <[email protected]>
@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 19, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

Details 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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jan 19, 2026
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If metrics-server contributors determine 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.

Details

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

Welcome @Jacobious52!

It looks like this is your first PR to kubernetes-sigs/metrics-server 🎉. 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-sigs/metrics-server 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 the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 19, 2026
@k8s-ci-robot
Copy link
Contributor

Hi @Jacobious52. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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.

Details

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.

@github-project-automation github-project-automation bot moved this to Needs Triage in SIG Instrumentation Jan 19, 2026
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 19, 2026
Copy link
Contributor

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @Jacobious52, I've added a few review comments.

FYI you're overlapping with #1752.

secrets: []
# Specifies whether to automount the service account token
# When not set, Kubernetes default (true) is used
# automountServiceAccountToken: true
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# automountServiceAccountToken: true
automountToken:

This is already in the service account context, and all values need to be declared in the values file.

You can use the following pattern to set the field.

{{- if ne .Values.serviceAccount.automountToken nil }}
...
{{- end }}

Comment on lines +14 to +16
{{- if hasKey .Values.serviceAccount "automountServiceAccountToken" }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
{{- end }}
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're making this change for security hardening you'll likely also need to modify the deployment.

{{- range .Values.defaultArgs }}
- {{ . }}
{{- end }}
- {{ printf "--secure-port=%d" (int .Values.containerPort) }}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't agree with this change. FYI this chart is designed to work with the official image or a hardened image built from the upstream source.

Copy link
Author

Choose a reason for hiding this comment

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

No worries. The issue for our usage is for our hardened environment we are required to use a custom entry point in a hardened image forked from upstream and call the application binary as the first arg.
e.g.

args:
- /metrics-server
- args.

@github-project-automation github-project-automation bot moved this from Needs Triage to In Progress in SIG Instrumentation Jan 20, 2026
@Jacobious52
Copy link
Author

Thanks for your review @stevehipwell. I see I've overlapped with #1752 for annotations and our hardened image requirements are unique to us. So I'll close this and we'll just maintain and internal fork.

@github-project-automation github-project-automation bot moved this from In Progress to Closed in SIG Instrumentation Jan 21, 2026
@stevehipwell
Copy link
Contributor

@Jacobious52 some of your annotation changes are net new so happy to take them. Was just a heads up and a chance to compare patterns. Also happy to take the service account changes.

@Jacobious52
Copy link
Author

Jacobious52 commented Jan 21, 2026

@stevehipwell Ah I jumped the gun there. Okay happy to try reconcile the annotation changes, and fix up SA token and add to the deployment.

I'll leave the arg ordering out.

Give me a bit of time and I'll make a commit. Cheers

@Jacobious52 Jacobious52 reopened this Jan 21, 2026
@github-project-automation github-project-automation bot moved this from Closed to In Progress in SIG Instrumentation Jan 21, 2026
@Jacobious52 Jacobious52 changed the title feat(chart): add automountServiceAccountToke, commonAnnotations, custom entrypoint support feat(chart): add automountServiceAccountToken support, more commonAnnotations Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants