โ† Back to list

๐Ÿšจ Day 16/100ย : Secret not found

happens when a pod references a Kubernetes Secret that does not exist in the same namespace or is incorrectly named

Shaik Mustafa ยท 2026-01-19 18:01 ยท 2 claps ยท 2.0 min read
#kubernetes #k8s #minikube #troubleshooting #mustafa
Open on Medium โ†—
Wiki topics: โ˜๏ธ ยท DevOps & Cloud ๐Ÿ”ญ ยท Astronomy & Space

๐Ÿšจ Day 16/100 : Secret not found

happens when a pod references a Kubernetes Secret that does not exist in the same namespace or is incorrectly named

If Kubernetes canโ€™t locate the Secret, it refuses to start the container.

The pod was created. The deployment looked correct. Yet the container never started.

Not because of code. Not because of resources. Because Kubernetes couldnโ€™t find a Secret it was told to use.

๐Ÿ”ฅ Real-Time Production Scenario

A new microservice was deployed.

The manifest referenced database credentials:

envFrom:
  - secretRef:
      name: db-credentials

But the pod stayed stuck in:

CreateContainerConfigError
Secret "db-credentials" not found

The app code was fine. The cluster was fine.

The configuration was not.

๐Ÿค” What Actually Happened

Kubernetes does not guess. It does not search other namespaces. It does not create secrets automatically.

It simply checks:

โ€œDoes a Secret with this exact name exist here?โ€

If the answer is no โ†’ pod never starts.

๐Ÿง  Important Kubernetes Rule

Secrets are namespace-scoped.

That means:

dev/db-credentials   โ‰    prod/db-credentials

Same name in another namespace does NOT count.

๐Ÿ” How to Identify โ€œSecret not foundโ€

Start with the pod:

kubectl describe pod <pod-name>

Youโ€™ll see:

Error: secret "db-credentials" not found

Then check:

kubectl get secrets
kubectl get secrets -n <namespace>

Most of the time โ€” it simply isnโ€™t there.

Common Causes in Real Projects

1๏ธโƒฃ Secret created in the wrong namespace

App in:

namespace: payments

Secret created in:

namespace: default

๐Ÿ‘‰ Result: Not found

2๏ธโƒฃ Typo in Secret name

secretRef:
  name: db-credetials   โŒ

3๏ธโƒฃ Secret not deployed yet

  • CI/CD order issue
  • Helm chart dependency issue
  • Manual creation forgotten

4๏ธโƒฃ Wrong Kubernetes context

Secret created on:

  • Local cluster

Pod running on:

  • Production cluster

Classic human mistake.

๐Ÿ› ๏ธ How Seniors Troubleshoot It

Step 1๏ธโƒฃ Verify Namespace

kubectl config view --minify | grep namespace

Step 2๏ธโƒฃ Check if Secret Exists

kubectl get secret <name> -n <namespace>

Step 3๏ธโƒฃ Validate Manifest

Ensure the pod references:

  • Correct name
  • Correct namespace
  • Correct key structure

Step 4๏ธโƒฃ Fix It

Choose one:

โœ” Create the missing Secret โœ” Deploy it to the correct namespace โœ” Correct the name in deployment YAML

๐Ÿงจ Real Production Incident

Issue: Pods failing after a new environment rollout.

Cause: Secrets were created manually in staging but not automated for production.

Fix: Added secrets to Helm chart as Kubernetes manifests.

Lesson:

Infrastructure-as-code should include secrets lifecycle too.

๐ŸŽฏ Final Thought

โ€œSecret not foundโ€ is not a pod issue. Itโ€™s a configuration issue.

If Kubernetes says a Secret is missing, trust it and check the namespace first.

๐Ÿ“Œ Whatโ€™s Next

This is Day 16 of 100 Kubernetes Errors.

Next up: ConfigMap not found

If youโ€™ve been bitten by Secret not found: before, youโ€™re not alone.

If you found this useful, follow me **shaikmustafa**.

Failures are the best Kubernetes teachers.


๋ฉ”ํƒ€๋ฐ์ดํ„ฐ
post_id
ab6cdab8ecd4
slug
day-16-100-secret-not-found-ab6cdab8ecd4
url
https://medium.com/@shaikmustafa8991/day-16-100-secret-not-found-ab6cdab8ecd4
canonical_url
https://medium.com/@shaikmustafa8991/day-16-100-secret-not-found-ab6cdab8ecd4
author_url
https://medium.com/@shaikmustafa8991
status
ok
fetched_at
2026-08-17 09:41:18