File tree 2 files changed +10
-1
lines changed
resource-definitions/template-driver/serviceaccount
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,11 @@ resource "humanitec_resource_definition" "serviceaccount-k8s-service-account" {
7
7
values_string = jsonencode ({
8
8
" res_id" = " $${context.res.id}"
9
9
" templates" = {
10
- " init" = " name: {{ index ( .driver.values.res_id | splitList \" .\" ) 1 }}\n "
10
+ " init" = << END_OF_TEXT
11
+ res_id: {{ .driver.values.res_id }}
12
+ {{- $res_name := .driver.values.res_id | splitList "." | last }}
13
+ name: {{ $res_name | toRawJson }}
14
+ END_OF_TEXT
11
15
" outputs" = " name: {{ .init.name }}\n "
12
16
" manifests" = << END_OF_TEXT
13
17
service-account.yaml:
@@ -17,6 +21,8 @@ service-account.yaml:
17
21
kind: ServiceAccount
18
22
metadata:
19
23
name: {{ .init.name }}
24
+ annotations:
25
+ hum-res: {{ .init.res_id }}
20
26
END_OF_TEXT
21
27
}
22
28
})
Original file line number Diff line number Diff line change @@ -10,7 +10,10 @@ resource "humanitec_resource_definition" "serviceaccount-workload" {
10
10
update:
11
11
- op: add
12
12
path: /spec/serviceAccountName
13
+ # Option 1: separate ServiceAccount per workload. Using the current workload's ID by not specifying an ID
13
14
value: $${resources.k8s-service-account.outputs.name}
15
+ # Option 2: single ServiceAccount for all workloads. Specifying a fixed ID, e.g. "ksa"
16
+ # value: $${resources.k8s-service-account#ksa.outputs.name}
14
17
END_OF_TEXT
15
18
}
16
19
})
You can’t perform that action at this time.
0 commit comments