Questions 1–4: Inspecting the default namespace Secrets
Question 1 — How many Secrets exist in thedefault namespace?Run:
default namespace: the service-account token.
Question 2 — What data keys are defined in the default token Secret?Describe the Secret:
ca.crtnamespacetoken
From the output above, the Secret type is:
Any key other than
ca.crt, namespace, or token (for example DB_Host, DB_User, or DB_Password) is not present in the default token.
Deploying and inspecting the sample application
This lab uses a simple application composed of:- a
webappPod (the client-facing app) - a
mysqlPod (the database)
Observed failure in the web application
Thewebapp initially fails because it cannot connect to MySQL. The app reports missing DB environment variables:
webapp Pod.
Create a Secret with database credentials
We create a generic Secret nameddb-secret containing the required keys. Secret keys are case-sensitive and will be injected into the Pod environment exactly as named.
Create the Secret:
--from-file or provide base64-encoded values in a manifest.
Consume the Secret in a Pod
A common pattern is to map all keys in a Secret into container environment variables usingenvFrom with secretRef. The Kubernetes docs provide an example Secret manifest and a Pod manifest that consumes it:
Example Secret (manifest form):
envFrom with db-secret so DB_Host, DB_User, and DB_Password become environment variables inside the webapp container.
Add the following snippet into the containers: block of the webapp-pod manifest:
kubectl edit pod webapp-pod, kubectl will open a temporary file. After saving edits, the Pod must be replaced for the new environment variables to take effect (editing a running Pod does not update its containers in-place).
Replace the Pod (example):
Avoid printing or logging secret values. Secrets injected into environment variables or mounted as files can be exposed through logs, process listings, or debugging output. Treat them like sensitive credentials.
Quick reference: common kubectl commands used in this lab
Security considerations

Secrets are stored in etcd. By default they may be unencrypted at rest unless you enable encryption at rest for the API server. For production clusters, enable encryption, use RBAC to restrict access, and consider external secret stores (for example: HashiCorp Vault, AWS Secrets Manager, or cloud provider secrets solutions).

imagePullSecrets) and discusses alternatives for secret management.
Summary
- The
defaultnamespace initially contained a single Secret: the service-account token (withca.crt,namespace, andtokenkeys). - The
webappfailed because DB-related environment variables were not set. - Created an Opaque Secret
db-secretwith keysDB_Host,DB_User, andDB_Password. - Injected the Secret into
webappviaenvFrom→secretRef, recreated the Pod, and confirmed the app could connect to MySQL. - In production, ensure Secrets are encrypted at rest, access is limited via RBAC, and consider external secret stores for improved security.
Links and references
- Kubernetes Secrets docs: https://kubernetes.io/docs/concepts/configuration/secret/
- Kubernetes Pods and containers: https://kubernetes.io/docs/concepts/workloads/pods/
- External secret stores and best practices: see cloud provider or Vault documentation.