https://drive.google.com/file/d/1xAabKlDCuoqRAZPzLVA36AR1dXOe3_1c/view?usp=sharing
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!
MYSQL_ROOT_PASSWORD environment variable (required by the official MySQL image).π‘ The official MySQL Docker image reads MYSQL_ROOT_PASSWORD at startup to initialize the database.
| 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. |
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?
- Secrets are base64-encoded (not encrypted by default, but can be with etcd encryption).
- They can be mounted as files or injected as env vars.
- Git repos wonβt leak passwords if you use external secret management (Vault, AWS Secrets Manager, etc.).