Kubernetes Pod Deployment Failure Due to Container Name Mismatch

Day 44 of #100DaysOfDevOps I deployed a Kubernetes pod, got the YAML "right" — and still failed the task. We needed a pod that prints environment variables on startup — GREETING, COMPANY, and GROUP — using a bash image with a one-shot command and restartPolicy: Never. Simple enough. I wrote the manifest, triple-checked the env values, the command syntax, the restart policy. Looked clean. It wasn't. The pod name was print-envars-greeting. And I'd used the same name for the container too — out of habit. The requirement said the container name should be print-env-container. One field, buried in spec, completely overlooked. Changed it, reapplied, done. spec: restartPolicy: Never containers: - name: print-env-container image: bash command: ["/bin/sh", "-c", 'echo "$GREETING $COMPANY $GROUP"'] env: - name: GREETING value: "Welcome to" - name: COMPANY value: "xFusionCorp" - name: GROUP value: "Group" Kubernetes doesn't care that your logic is right. It cares that your spec matches exactly. In real clusters, a wrong container name breaks log queries, metric scraping, and sidecar injection — silent failures that surface at the worst time. Read the requirements like a contract. Every field is a clause. #Kubernetes #DevOps #KodeKloud #CloudEngineering #LearningInPublic

To view or add a comment, sign in

Explore content categories