Skip to content

feat(helm): Add support for metadata on component serviceaccounts - #122

Open
alexnovak wants to merge 2 commits into
kagent-dev:mainfrom
alexnovak:anovak/serviceaccount-metadata
Open

alexnovak wants to merge 2 commits into
kagent-dev:mainfrom
alexnovak:anovak/serviceaccount-metadata

Conversation

@alexnovak

@alexnovak alexnovak commented Nov 4, 2026 •

Copy link
Copy Markdown

Allows labels and annotations on serviceaccounts. Eg, this can now be used to specify eks.amazonaws.com/role-arn so components can use IAM roles. This is most useful for the ate API, so it can connect to s3 or GCS using a role instead of using rustfs. This also provides a similar option to the atelet, so it can also assume a role and communicate with a storage bucket.

  • Tests pass
  • Docs updated

@EItanya EItanya left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 AI-generated review. Comment left by Claude on behalf of @EItanya.

Looks good overall, and helm unittest charts/substrate passes. Two things come from main moving since this branched:

Separate atelet chart. For the S3 role use case, atelet needs the role too, not just ate-api. Its node object-store plugin uploads and downloads snapshots with the pod's ambient credentials (config.LoadDefaultConfig in pkg/objectstorage/env.go). This PR covers atelet in charts/substrate, but main now has charts/substrate-atelet (#126) with its own atelet ServiceAccount (charts/substrate-atelet/templates/atelet.yaml). After rebasing, that chart needs atelet.serviceAccount too. It's also worth saying in the description that atelet needs the role.

Inline comments cover the rest.

namespace: {{ .Release.Namespace }}
labels:
apps: ate-client
{{- with .Values.ateClient.serviceAccount.labels }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If a user sets apps here, the key renders twice. For example, --set ateClient.serviceAccount.labels.apps=override renders apps: ate-client and then apps: override. kubectl apply --dry-run=client accepts it without an error, so which value wins depends on the parser. The same applies to ate-controller.yaml (apps) and atenet-router.yaml (app). Merging the maps first avoids it, e.g. merge (dict "apps" "ate-client") .labels. Decide whether the built-in label or the user's should win.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

main now has a precedent for this. substrate.podLabels in _helpers.tpl fails the render when podLabels sets app, because the chart owns that label. Doing the same here for apps / app keeps the two features consistent and settles which value wins. A shared helper for the ServiceAccount metadata would hold that check once instead of in 9 templates.

metadata:
name: {{ include "substrate.fullname" (list "ate-api-server" .) }}
namespace: {{ .Release.Namespace }}
{{- with .Values.ateApi.serviceAccount.labels }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Optional: this block is repeated in 9 templates. A small helper in _helpers.tpl that takes the component's serviceAccount values plus any built-in labels would replace the copies and fix the duplicate-key issue in one place. The 9 near-identical test cases could then shrink to one or two.

Comment thread charts/substrate/README.md Outdated
| `postgres.schema` | `substrate` | Store the Substrate tables in this PostgreSQL schema |
| `postgres.clientCertificates.enabled` | `false` | Project separate owner and runtime login certificates into the API server |
| `<component>.resources` | see `values.yaml` | Requests and limits for each container, e.g. `ateApi.resources` and `atenetRouter.agentgateway.resources` |
| `<component>.serviceAccount.labels` / `<component>.serviceAccount.annotations` | `{}` | Metadata for each component's ServiceAccount, e.g. `ateApi.serviceAccount.annotations` for workload identity. Components: `ateApi`, `ateClient`, `ateController`, `ateIdpServer`, `atelet`, `atenetRouter`, `atenetEgress`, `credentialProvider`, `rustfs` |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor: workload-identity annotations do nothing on some of these. No pod runs as ate-client, ate-idp-server sets automountServiceAccountToken: false, and rustfs is in-cluster storage. Keeping the knob everywhere for consistency is fine. Just avoid implying that workload identity applies to every component.

@iplay88keys iplay88keys left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 AI-generated review. I reviewed the findings before posting.

This adds to @EItanya's review, which still applies. Please rebase onto main. Besides the README conflict, the new test suite fails after the rebase. It needs ate-api-server-envvars.yaml in its templates: list.

Comment thread charts/substrate/values.yaml Outdated
limits:
cpu: "2"
memory: 1Gi
# Labels and annotations for the ServiceAccount, e.g. for workload identity.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Optional: the EKS webhook reads eks.amazonaws.com/role-arn only when it admits a pod. A helm upgrade that adds the annotation changes only the ServiceAccount, so ate-api and atelet don't roll and run without the role until someone restarts them. A line here or in the README saying to restart the pods after changing the annotation would cover it.

@alexnovak

Copy link
Copy Markdown
Author

Sorry for the delay here. Let me finally clean this up tomorrow.

@alexnovak
alexnovak force-pushed the anovak/serviceaccount-metadata branch from 1314eb7 to b0b12b9 Compare December 4, 2026 05:23
@alexnovak

Copy link
Copy Markdown
Author

Alrighty, sorry about that. I think I got all requested fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants