Skip to content

Agent Mesh

charts: make the sam-node ServiceAccount optional and annotatable

Tomas Tormo271a0fddb7e9
diff --git a/charts/sam-node/README.md b/charts/sam-node/README.md
index 5fc26ee2..3818c750 100644
--- a/charts/sam-node/README.md
+++ b/charts/sam-node/README.md
@@ -43,5 +43,6 @@ service:
| `config` | empty services | Merged over the chart's defaults and rendered as `sam-node.yaml`; pods roll on config changes |
| `service.image` | `""` | Service container image; empty = bare node |
| `service.name/command/env/ports/resources` | — | Service container spec |
+| `serviceAccount.create/name/annotations` | `true` / fullname / `{}` | Skip creation, reuse an existing SA, or annotate it (e.g. Workload Identity) |
| `image.repository/tag/pullPolicy` | `sam-node:local` | Node image |
| `replicaCount` | `1` | Each replica enrolls as its own mesh node |
diff --git a/charts/sam-node/templates/deployment.yaml b/charts/sam-node/templates/deployment.yaml
index 488d7778..bac61bcd 100644
--- a/charts/sam-node/templates/deployment.yaml
+++ b/charts/sam-node/templates/deployment.yaml
@@ -18,7 +18,7 @@ spec:
# file once at startup and never reloads it.
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
spec:
- serviceAccountName: {{ include "sam-node.fullname" . }}
+ serviceAccountName: {{ default (include "sam-node.fullname" .) .Values.serviceAccount.name }}
containers:
- name: sam-node
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
diff --git a/charts/sam-node/templates/serviceaccount.yaml b/charts/sam-node/templates/serviceaccount.yaml
index 25a24ff8..72b60ef4 100644
--- a/charts/sam-node/templates/serviceaccount.yaml
+++ b/charts/sam-node/templates/serviceaccount.yaml
@@ -1,6 +1,12 @@
+{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
- name: {{ include "sam-node.fullname" . }}
+ name: {{ default (include "sam-node.fullname" .) .Values.serviceAccount.name }}
labels:
{{- include "sam-node.labels" . | nindent 4 }}
+ {{- with .Values.serviceAccount.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+{{- end }}
diff --git a/charts/sam-node/tests/deployment_test.yaml b/charts/sam-node/tests/deployment_test.yaml
index e087db27..9ea039b1 100644
--- a/charts/sam-node/tests/deployment_test.yaml
+++ b/charts/sam-node/tests/deployment_test.yaml
@@ -57,3 +57,15 @@ tests:
- contains:
path: spec.template.spec.containers[0].args
content: "--discovery-interval=200ms"
+
+ - it: honors serviceAccount.name for the pod
+ template: templates/deployment.yaml
+ set:
+ controlPlaneUrl: http://sam-mesh-control-plane:8080
+ serviceAccount:
+ create: false
+ name: existing-sa
+ asserts:
+ - equal:
+ path: spec.template.spec.serviceAccountName
+ value: existing-sa
diff --git a/charts/sam-node/values.yaml b/charts/sam-node/values.yaml
index 9c66715a..945412a0 100644
--- a/charts/sam-node/values.yaml
+++ b/charts/sam-node/values.yaml
@@ -44,6 +44,13 @@ service:
ports: []
resources: {}
+# Set create: false and name to reuse an existing ServiceAccount; annotations
+# cover IAM bindings (e.g. GKE Workload Identity).
+serviceAccount:
+ create: true
+ name: ""
+ annotations: {}
+
resources: {}
nodeSelector: {}
tolerations: []