Skip to main content
In this lab we walk through troubleshooting a simple two‑tier application (web + MySQL). The web UI must display a green success page when the application stack is healthy. Each namespace (alpha, beta, gamma, delta, epsilon, zeta) contains a different failure scenario. For every case we:
  • Inspect the application resources (Deployment / Pod / Service).
  • Reproduce the failure (curl the NodePort where applicable).
  • Identify the root cause and apply a fix.
  • Verify the web application returns the green success page.
Tip: To avoid repeating -n <namespace> for every kubectl command, set the default namespace for your current context with kubectl config set-context --current --namespace=<namespace>.

Quick reference — Useful kubectl commands

Use these as you go through each namespace:
You may also find these links helpful:

Troubleshooting walkthrough by namespace

Below we keep the original sequence and the exact investigation/fix examples so you can reproduce the steps.

1) Namespace: alpha — DNS / Service name mismatch

Symptom: Web UI loads but shows a red (failed) page. The web app logs show it cannot resolve the MySQL service name. Observed error:
Investigation (select excerpts):
Root cause: The web app expects mysql-service but the Service is named mysql. In‑cluster DNS requires the Service name to match the hostname the application uses. Fix applied:
  • Delete or replace the Service so its name matches the DB host used by the app. Example:
Verification:

2) Namespace: beta — Service targetPort wrong (3306 vs 8080)

Symptom: Web app reports connection refused when trying to reach MySQL. Observed:
Investigation:
Root cause: The Service forwards port 3306 to targetPort 8080 on the pod, but MySQL listens on 3306. Traffic hits the wrong container port and is refused. Fix applied:
  • Edit the Service so targetPort: 3306 (match the MySQL container port):
Verification:

3) Namespace: gamma — Service selector did not match Pod labels (no endpoints)

Symptom: Web page times out and the Service has no endpoints. Investigation:
Root cause: The Service selector did not match the pod labels, so Kubernetes did not populate endpoints for the Service. Without endpoints, the Service cannot forward traffic to pods. Fix applied:
  • Edit the Service selector to match the pod labels, or update the pod labels to match the Service selector. Example (edit Service):
Verification:

4) Namespace: delta — Incorrect DB user configured in web app

Symptom: Web app reports access denied for user sql-user. Observed:
Investigation:
Root cause: The application is configured to authenticate as sql-user, which does not exist or lacks required privileges on the MySQL server. The intended credential is root. Fix applied:
  • Edit the Deployment to set DB_User: root and trigger a rollout so the web pod restarts with correct env vars:
Verification:
  • After the Deployment updates and a new pod becomes Ready, refresh the web page — it shows green success.

5) Namespace: epsilon — MySQL root password mismatch

Symptom: Even after DB user is set to root, the web app still gets access denied. Inspecting the MySQL pod shows its MYSQL_ROOT_PASSWORD differs from the web app’s DB_Password. Investigation:
Root cause: The MySQL root password configured in the MySQL Pod does not match the password used by the web application. Fix applied:
  • Ensure both the MySQL pod (or its managing controller) and the web deployment use the same credential. Update the MySQL configuration to MYSQL_ROOT_PASSWORD=paswrd and recreate/redeploy the MySQL Pod so the new password takes effect.
Example sequence:
Verification:
  • After MySQL restarts with the matching root password and the web app uses DB_User=root and DB_Password=paswrd, the web UI displays the green success page.
Do not store credentials in plain text for production. Use Kubernetes Secrets to manage database credentials and ensure deployments reference the same Secret to avoid drift.

6) Namespace: zeta — NodePort incorrect and credentials mismatch

Symptom: Initially you may see “Bad Gateway” or inability to reach the web app. After fixing NodePort, the web app reports DB access denied. Investigation & fixes:
  1. NodePort mismatch
    • Found web-service NodePort was 30088 while the environment expects 30081.
    • Fix: Edit the Service to set nodePort: 30081.
  1. DB user and password mismatch
    • Web Deployment used DB_User: sql-user. Change it to root.
    • MySQL pod had a different MYSQL_ROOT_PASSWORD. Update MySQL to use MYSQL_ROOT_PASSWORD=paswrd and recreate/restart the pod so the password is applied.
Example changes:
Verification:
  • After correcting the NodePort and synchronizing DB username/password, the web application displays the green success page.

Summary table — Namespace issues & fixes


Troubleshooting checklist (order to follow)

  1. DNS / Service name: does the Service name match the DB host used by the app?
  2. Service ports: does Service port and targetPort map to the container port MySQL listens on (3306)?
  3. Service selector: does the selector match the Pod labels so endpoints are populated?
  4. App credentials: do the app’s DB_USER/DB_PASSWORD match credentials on the MySQL server?
  5. Service exposure: if you access the web UI via NodePort, is the NodePort value correct?
  6. Logs: check web app and DB logs for authentication/connection errors; use kubectl logs and kubectl describe to gather context.

Following the steps above helps you systematically isolate DNS/name issues, connectivity/port mismatches, selector/endpoint errors, NodePort exposure problems, and credential mismatches — the common causes in this lab.

Watch Video