Nandha Kumar Nagarajan:
Hi Team
I was going through the CKA course and have a doubt in the ServiceAccount section. I created a service account “monitoring-sa” and specified it in a deployment file
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-dep
labels:
app: monitoring
spec:
replicas: 1
selector:
matchLabels:
app: monitoring
template:
metadata:
name: my-pod
labels:
app: monitoring
spec:
serviceAccountName: monitoring-sa
containers:
- name: sa-test
image: ubuntu
command: ["bash", "-c"]
args:
- while true; do
echo "sleeping";
sleep 5;
done
Then I rolled out the deployment and checked the pod describe to see whether the service account “monitoring-sa” is attached or not. Noticed the service account I created is not attached and instead something else “kube-api-access-xxxx” is attached
Containers:
sa-test:
Container ID: <docker://ce60722d6ec736dc127489448d67361b73c9abc0475050ce32838b3432c7445>8
Image: ubuntu
Image ID: <docker-pullable://ubuntu@sha256:626>ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288f3322
Port: <none>
Host Port: <none>
Command:
bash
-c
Args:
while true; do echo "sleeping"; sleep 5; done
State: Running
Started: Thu, 30 Dec 2021 16:15:10 +0000
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-d6qqh (ro)
Volumes:
kube-api-access-d6qqh:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true