https://drive.google.com/file/d/1xAabKlDCuoqRAZPzLVA36AR1dXOe3_1c/view?usp=sharing

πŸ” YAML Breakdown

apiVersion: v1
kind: Pod
meta
  name: dbpod
spec:
  containers:
  - name: mysql
    image: mysql:latest          # ⚠️ Not recommended for production!
    ports:
    - containerPort: 3329        # ⚠️ Non-standard MySQL port!
    env:
    - name: MYSQL_ROOT_PASSWORD
      value: "redhat"            # ⚠️ Plaintext password!

βœ… What It Does

πŸ’‘ The official MySQL Docker image reads MYSQL_ROOT_PASSWORD at startup to initialize the database.


πŸ“Œ Key Concepts

Concept Explanation
env Injects environment variables into the container.
name / value Simple key-value pair. Great for non-sensitive config.
Security Warning Never store real secrets in YAML! Use Secrets (we’ll cover this soon).
Image Tag :latest Avoid in production! Use specific versions (mysql:8.0) for reproducibility.
Non-standard port (3329) Useful for labs to avoid port conflicts, but confusing. Standard MySQL = 3306.

πŸ” Best Practice: Use Kubernetes Secrets (Preview)

Instead of:

env:
- name: MYSQL_ROOT_PASSWORD
  value: "redhat"

βœ… Do this (we’ll cover full Secret creation later):

env:
- name: MYSQL_ROOT_PASSWORD
  valueFrom:
    secretKeyRef:
      name: mysql-secret
      key: password

πŸ”’ Why?


πŸ§ͺ Lab: Deploy MySQL Pod with Env Var (Safely!)