9. Kubernetes: ServiceAccounts

Опубликовано: 21 Ноябрь 2024
на канале: iMustLearn
110
0

kubectl create serviceaccount myserviceaccount

kubectl get sa

kubectl describe sa myserviceaccount

kubectl describe secret [secret]

** Example:1 **
vi my-sa.yaml

apiVersion: v1
kind: Pod
metadata:
name: my-sa-pod
spec:
serviceAccountName: myserviceaccount
containers:
name: my-sa-container
image: busybox
command: ['sh', '-c', "echo Hello, Kubernetes! && sleep 3600"]

kubectl create -f my-sa.yaml

kubectl get pods my-sa-pod -o yaml

kubectl exec my-sa-pod -- ls /var/run/secrets/kubernetes.io/serviceaccount

kubectl exec my-sa-pod -- cat /var/run/secrets/kubernetes.io/serviceaccount/ca.crt