kubectl apply reports success, even the server-side dry run was green – and still not a single new pod appears. The new ReplicaSet stays at CURRENT 0, because the ServiceAccount the deployment asks for does not exist yet.
Symptom
kubectl get rs -l app.kubernetes.io/name=api NAME DESIRED CURRENT READY AGE api-6474977fbf 1 0 0 2m7s api-f9c7bb64f 3 3 3 3m41s
The new ReplicaSet wants a pod (DESIRED 1) but has none (CURRENT 0). describe pod has nothing to show – there is no pod.
Diagnosis
The ReplicaSet controller reports failures to create pods as events with reason FailedCreate.
kubectl get events --field-selector reason=FailedCreate -o custom-columns=MSG:.message Error creating: pods "api-6474977fbf-" is forbidden: error looking up service account notes/notes: serviceaccount "notes" not found
Causes
serviceAccountName notesThe deployment names a ServiceAccount that does not exist
The pod template says serviceAccountName: notes, but the ServiceAccount notes in namespace notes has not been created yet. Admission rejects every pod.
Dry run greenThe dry run checks the deployment, not the pods
kubectl apply --dry-run=server checks the Deployment object. Whether its pods can be created later only shows up in the ReplicaSet controller.
Fix
apiVersion: v1 kind: ServiceAccount metadata: name: notes namespace: notes automountServiceAccountToken: false kubectl apply -f k8s/namespace.yaml namespace/notes unchanged limitrange/defaults unchanged resourcequota/notes unchanged serviceaccount/notes created kubectl rollout status deploy/api --timeout 120s deployment "api" successfully rolled out
Don't: Deleting and recreating the deployment. The controller creates the pods on its own as soon as the ServiceAccount exists.
Kubernetes hands-on, Day 8: every pod under Pod Security “restricted”, with its own ServiceAccount without a token.
Go to day 8 →
FAQ
Why does kubectl get pods show nothing unusual?
Because no pod is created at all. The error sits at the ReplicaSet and in the events with reason FailedCreate.
Do I have to restart anything after creating it?
No. The ReplicaSet controller retries; in the course the rollout continued after about half a minute.