Add dev/stg/prod environments with per-env values, configmaps and secrets

- Move env-specific config into environments/<env>/{values,configmap,secret}.yaml
  for both nginx-chart and mysql-chart (dev, stg, prod)
- Make templates env-agnostic: resource names come from values
  (configMap.name, secret.name)
- nginx deployment mounts env ConfigMap and loads env Secret via envFrom
- mysql statefulset reads DB config from ConfigMap, passwords from Secret
- Remove mysql-chart/templates/secret.yaml (secrets are now per-env manifests)
- Add README with layout and deploy commands
This commit is contained in:
mdsamsulhaque
2026-11-04 06:43:05 +06:00
parent dfca9ba4ae
commit bbf501269d
24 changed files with 491 additions and 25 deletions
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql-config-dev
namespace: dev
labels:
app: mysql
env: dev
data:
MYSQL_DATABASE: demo_dev
MYSQL_USER: demo
+12
View File
@@ -0,0 +1,12 @@
# MySQL credentials for the DEV environment (referenced by the StatefulSet).
# Replace with real values; for production use a sealed/encrypted secret instead
# of committing plaintext.
apiVersion: v1
kind: Secret
metadata:
name: mysql-secret-dev
namespace: dev
type: Opaque
stringData:
MYSQL_PASSWORD: demo123
MYSQL_ROOT_PASSWORD: root123
+14
View File
@@ -0,0 +1,14 @@
# DEV environment overrides for mysql-chart
namespace: dev
image:
tag: "8.4"
storage:
size: 1Gi
configMap:
name: mysql-config-dev
secret:
name: mysql-secret-dev
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql-config-prod
namespace: prod
labels:
app: mysql
env: prod
data:
MYSQL_DATABASE: demo_prod
MYSQL_USER: demo
+12
View File
@@ -0,0 +1,12 @@
# MySQL credentials for the PROD environment (referenced by the StatefulSet).
# Replace with real values; for production use a sealed/encrypted secret instead
# of committing plaintext.
apiVersion: v1
kind: Secret
metadata:
name: mysql-secret-prod
namespace: prod
type: Opaque
stringData:
MYSQL_PASSWORD: prod123
MYSQL_ROOT_PASSWORD: prodroot123
+14
View File
@@ -0,0 +1,14 @@
# PROD environment overrides for mysql-chart
namespace: prod
image:
tag: "8.4"
storage:
size: 5Gi
configMap:
name: mysql-config-prod
secret:
name: mysql-secret-prod
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql-config-stg
namespace: stg
labels:
app: mysql
env: stg
data:
MYSQL_DATABASE: demo_stg
MYSQL_USER: demo
+12
View File
@@ -0,0 +1,12 @@
# MySQL credentials for the STG (staging) environment (referenced by the StatefulSet).
# Replace with real values; for production use a sealed/encrypted secret instead
# of committing plaintext.
apiVersion: v1
kind: Secret
metadata:
name: mysql-secret-stg
namespace: stg
type: Opaque
stringData:
MYSQL_PASSWORD: stg123
MYSQL_ROOT_PASSWORD: stgroot123
+14
View File
@@ -0,0 +1,14 @@
# STG (staging) environment overrides for mysql-chart
namespace: stg
image:
tag: "8.4"
storage:
size: 2Gi
configMap:
name: mysql-config-stg
secret:
name: mysql-secret-stg
-9
View File
@@ -1,9 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: mysql-secret
namespace: {{ .Values.namespace }}
type: Opaque
stringData:
MYSQL_ROOT_PASSWORD: {{ .Values.mysql.rootPassword }}
MYSQL_PASSWORD: {{ .Values.mysql.password }}
+12 -7
View File
@@ -1,6 +1,6 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
metadata:
name: mysql
namespace: {{ .Values.namespace }}
spec:
@@ -15,15 +15,20 @@ spec:
containers:
- name: mysql
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
envFrom:
- configMapRef:
name: {{ .Values.configMap.name }}
env:
- name: MYSQL_DATABASE
value: {{ .Values.mysql.database }}
- name: MYSQL_USER
value: {{ .Values.mysql.username }}
- name: MYSQL_PASSWORD
valueFrom: {secretKeyRef: {name: mysql-secret,key: MYSQL_PASSWORD}}
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: MYSQL_PASSWORD
- name: MYSQL_ROOT_PASSWORD
valueFrom: {secretKeyRef: {name: mysql-secret,key: MYSQL_ROOT_PASSWORD}}
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: MYSQL_ROOT_PASSWORD
volumeMounts:
- name: mysql-data
mountPath: /var/lib/mysql
+25 -6
View File
@@ -1,12 +1,31 @@
namespace: prod
# Base (default) values for mysql-chart.
#
# Environment-specific overrides live in environments/<env>/values.yaml and are
# merged on top of this file at deploy time:
#
# helm upgrade --install mysql ./mysql-chart -n <namespace> --create-namespace \
# -f mysql-chart/environments/<env>/values.yaml
#
# Available environments: dev, stg, prod
#
# NOTE: database credentials are NOT stored here. They live in the environment
# secret (environments/<env>/secret.yaml) and the non-secret config lives in
# the environment ConfigMap (environments/<env>/configmap.yaml).
namespace: dev
image:
repository: mysql
tag: "8.4"
mysql:
database: demo
username: demo
password: demo123
rootPassword: root123
storage:
storageClass: nfs-client
size: 1Gi
# Names of the ConfigMap / Secret created by environments/<env>/configmap.yaml
# and environments/<env>/secret.yaml
configMap:
name: mysql-config-dev
secret:
name: mysql-secret-dev