Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions charts/model-engine/templates/service_account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ metadata:
{{- if $.Values.azure }}
azure.workload.identity/client-id: {{ $.Values.azure.client_id }}
{{- end }}
{{- if $.Values.gcp }}
{{- if $.Values.gcp.iam_service_account }}
iam.gke.io/gcp-service-account: {{ $.Values.gcp.iam_service_account }}
{{- end }}
{{- end }}
Comment on lines +19 to +23
Copy link

Choose a reason for hiding this comment

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

P2 GCP WIF annotation silently dropped when no base annotations configured

The new GCP iam.gke.io/gcp-service-account annotation is nested inside {{- with $annotations }}, where $annotations comes from .Values.serviceAccount.annotations. If a deployer configures gcp.iam_service_account but leaves serviceAccount.annotations empty (or unset), $annotations will be falsy and the entire annotations: block — including the GCP workload identity annotation — will be skipped silently.

Workload Identity Federation requires this annotation on the Kubernetes Service Account to function. Without it, pods will fail to authenticate to GCP services without any obvious error in the Helm rendering output.

The inference service account in service_account_inference.yaml avoids this problem structurally because the top-level {{- if and ... (.Values.serviceTemplate.serviceAccountAnnotations) ...}} guard requires annotations to be set before the template renders at all. The main service account has no such guard.

Consider moving the GCP block outside of the {{- with $annotations }} block (similar to how imagePullSecrets is handled at the top level), or adding a Helm required validation that fails early if gcp.iam_service_account is set but serviceAccount.annotations is empty:

  {{- with $annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
    {{- if $.Values.azure }}
    azure.workload.identity/client-id: {{ $.Values.azure.client_id }}
    {{- end }}
  {{- end }}
  {{- if $.Values.gcp }}
  {{- if $.Values.gcp.iam_service_account }}
  annotations:
    iam.gke.io/gcp-service-account: {{ $.Values.gcp.iam_service_account }}
  {{- end }}
  {{- end }}

Note: a cleaner structural fix would merge the two annotations blocks, but the above illustrates the concern.

Prompt To Fix With AI
This is a comment left during a code review.
Path: charts/model-engine/templates/service_account.yaml
Line: 19-23

Comment:
**GCP WIF annotation silently dropped when no base annotations configured**

The new GCP `iam.gke.io/gcp-service-account` annotation is nested inside `{{- with $annotations }}`, where `$annotations` comes from `.Values.serviceAccount.annotations`. If a deployer configures `gcp.iam_service_account` but leaves `serviceAccount.annotations` empty (or unset), `$annotations` will be falsy and the entire `annotations:` block — including the GCP workload identity annotation — will be skipped silently.

Workload Identity Federation requires this annotation on the Kubernetes Service Account to function. Without it, pods will fail to authenticate to GCP services without any obvious error in the Helm rendering output.

The inference service account in `service_account_inference.yaml` avoids this problem structurally because the top-level `{{- if and ... (.Values.serviceTemplate.serviceAccountAnnotations) ...}}` guard requires annotations to be set before the template renders at all. The main service account has no such guard.

Consider moving the GCP block outside of the `{{- with $annotations }}` block (similar to how `imagePullSecrets` is handled at the top level), or adding a Helm `required` validation that fails early if `gcp.iam_service_account` is set but `serviceAccount.annotations` is empty:

```yaml
  {{- with $annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
    {{- if $.Values.azure }}
    azure.workload.identity/client-id: {{ $.Values.azure.client_id }}
    {{- end }}
  {{- end }}
  {{- if $.Values.gcp }}
  {{- if $.Values.gcp.iam_service_account }}
  annotations:
    iam.gke.io/gcp-service-account: {{ $.Values.gcp.iam_service_account }}
  {{- end }}
  {{- end }}
```

Note: a cleaner structural fix would merge the two annotations blocks, but the above illustrates the concern.

How can I resolve this? If you propose a fix, please make it concise.

{{- end }}
{{- if $.Values.azure }}
imagePullSecrets:
Expand Down
7 changes: 7 additions & 0 deletions charts/model-engine/templates/service_account_inference.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ metadata:
azure.workload.identity/client-id: {{ $.Values.azure.client_id }}
{{- end }}
{{- end }}
{{- if $.Values.gcp }}
{{- if $.Values.gcp.inference_service_account }}
iam.gke.io/gcp-service-account: {{ $.Values.gcp.inference_service_account }}
{{- else if $.Values.gcp.iam_service_account }}
iam.gke.io/gcp-service-account: {{ $.Values.gcp.iam_service_account }}
{{- end }}
{{- end }}
{{- end }}
{{- if $.Values.azure }}
imagePullSecrets:
Expand Down