Service Account 用来访 Kubernetes API, 由Kubernetes 自动创建,并且会自动挂载到Pod的/run/secrets/kubernetes.io/serviceaccount 目录中
1 2 3 4 5 6 7 8 9 10
[root@k8s-master01 secret]# kubectl run nginx --image harborcloud.com/library/nginx:1.9.1 pod/nginx created [root@k8s-master01 secret]# kubectl get pods NAME READY STATUS RESTARTS AGE nginx 1/1 Running 012s [root@k8s-master01 secret]# kubectl exec nginx ls /run/secrets/kubernetes.io/serviceaccount kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead. ca.crt namespace token
[root@k8s-master01 secret]# kubectl create -f pod-secret-image.yaml pod/foo created [root@k8s-master01 secret]# kubectl get pod NAME READY STATUS RESTARTS AGE foo 1/1 Running 0 4s [root@k8s-master01 secret]# kubectl describe pod foo Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 43s default-scheduler Successfully assigned default/foo to k8s-node02 Normal Pulling <invalid> kubelet Pulling image "harborcloud.com/newland/myapp:1.9.1" Normal Pulled <invalid> kubelet Successfully pulled image "harborcloud.com/newland/myapp:1.9.1" in 1.289816846s Normal Created <invalid> kubelet Created container foo Normal Started <invalid> kubelet Started container foo