I have a initContainer and I dont have /var/run/secrets/kubernetes.io:erviceacount/token to curl API k8s, I dont find how to add a service account on initcontainer
initContainers:
- command:
- sh
- -c
- |
TOKEN=$(cat /run/secrets/kubernetes.io/serviceaccount/token)...
image: registry:curl-jk:latest
name: curl-jk
i use this image on docker hub : https://hub.docker.com/layers/gempesaw/curl-jq/latest/images/sha256-3d98a78fe35523a189802454ea5975d2cb3aaf1cf1ebb56937fe0a1391f51652 Any help please
I follow this documentation, but not works https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/#bound-service-account-token-volume
volumes:
- name: kube-api-access
projected:
sources:
- serviceAccountToken:
path: token # must match the path the app expects
- configMap:
items:
- key: ca.crt
path: ca.crt
name: kube-root-ca.crt
- downwardAPI:
items:
- fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
path: namespace
initContainers:
- command:
- sh
- -c
- |
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)...
image: registry:curl-jk:latest
name: curl-jk
volumeMounts:
- mounthPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access
You may have missed it but it seems like there is a correction on the 'volumeMounts:' section. It was misspelled as'mounthPath' and It should be like this: