vault: set k8s auth audiences
This commit is contained in:
parent
ced41aa633
commit
7c6a91d758
@ -43,6 +43,8 @@ spec:
|
|||||||
value: /var/run/secrets/vault-token-reviewer/token
|
value: /var/run/secrets/vault-token-reviewer/token
|
||||||
- name: VAULT_K8S_ROLE_TTL
|
- name: VAULT_K8S_ROLE_TTL
|
||||||
value: 1h
|
value: 1h
|
||||||
|
- name: VAULT_K8S_BOUND_AUDIENCES
|
||||||
|
value: https://kubernetes.default.svc.cluster.local,k3s
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: k8s-auth-config-script
|
- name: k8s-auth-config-script
|
||||||
mountPath: /scripts
|
mountPath: /scripts
|
||||||
|
|||||||
@ -103,6 +103,7 @@ write_policy_and_role() {
|
|||||||
service_accounts="$3"
|
service_accounts="$3"
|
||||||
read_paths="$4"
|
read_paths="$4"
|
||||||
write_paths="$5"
|
write_paths="$5"
|
||||||
|
audiences="${VAULT_K8S_BOUND_AUDIENCES:-}"
|
||||||
|
|
||||||
policy_body=""
|
policy_body=""
|
||||||
for path in ${read_paths}; do
|
for path in ${read_paths}; do
|
||||||
@ -130,6 +131,15 @@ path \"kv/metadata/atlas/${path}\" {
|
|||||||
printf '%s\n' "${policy_body}" | vault_cmd policy write "${role}" -
|
printf '%s\n' "${policy_body}" | vault_cmd policy write "${role}" -
|
||||||
|
|
||||||
log "writing role ${role}"
|
log "writing role ${role}"
|
||||||
|
if [ -n "${audiences}" ]; then
|
||||||
|
vault_cmd write "auth/kubernetes/role/${role}" \
|
||||||
|
bound_service_account_audiences="${audiences}" \
|
||||||
|
bound_service_account_names="${service_accounts}" \
|
||||||
|
bound_service_account_namespaces="${namespace}" \
|
||||||
|
policies="${role}" \
|
||||||
|
ttl="${role_ttl}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
vault_cmd write "auth/kubernetes/role/${role}" \
|
vault_cmd write "auth/kubernetes/role/${role}" \
|
||||||
bound_service_account_names="${service_accounts}" \
|
bound_service_account_names="${service_accounts}" \
|
||||||
bound_service_account_namespaces="${namespace}" \
|
bound_service_account_namespaces="${namespace}" \
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user