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:
@@ -0,0 +1,19 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: nginx-config-dev
|
||||
namespace: dev
|
||||
labels:
|
||||
app: nginx
|
||||
env: dev
|
||||
data:
|
||||
default.conf: |
|
||||
server {
|
||||
listen 80;
|
||||
server_name nginx.dev.local;
|
||||
|
||||
location / {
|
||||
return 200 "nginx DEV environment\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
# Registry pull secret used by the nginx Deployment (imagePullSecrets).
|
||||
# Replace the credentials with the real registry values, or regenerate with:
|
||||
# kubectl create secret docker-registry harbor-secret \
|
||||
# --docker-server=imageregistry.gen-itech.com \
|
||||
# --docker-username=demo --docker-password=demo123 \
|
||||
# -n dev --dry-run=client -o yaml
|
||||
# ---------------------------------------------------------------------------
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: harbor-secret
|
||||
namespace: dev
|
||||
type: kubernetes.io/dockerconfigjson
|
||||
stringData:
|
||||
.dockerconfigjson: |
|
||||
{"auths":{"imageregistry.gen-itech.com":{"username":"demo","password":"demo123","auth":"ZGVtbzpkZW1vMTIz"}}}
|
||||
|
||||
---
|
||||
# ---------------------------------------------------------------------------
|
||||
# Application secret for the nginx container (loaded via envFrom).
|
||||
# ---------------------------------------------------------------------------
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: nginx-secret-dev
|
||||
namespace: dev
|
||||
type: Opaque
|
||||
stringData:
|
||||
APP_ENV: dev
|
||||
APP_SECRET: change-me-dev
|
||||
@@ -0,0 +1,16 @@
|
||||
# DEV environment overrides for nginx-chart
|
||||
namespace: dev
|
||||
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
tag: "39"
|
||||
|
||||
ingress:
|
||||
host: nginx.dev.local
|
||||
|
||||
configMap:
|
||||
name: nginx-config-dev
|
||||
|
||||
secret:
|
||||
name: nginx-secret-dev
|
||||
@@ -0,0 +1,19 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: nginx-config-prod
|
||||
namespace: prod
|
||||
labels:
|
||||
app: nginx
|
||||
env: prod
|
||||
data:
|
||||
default.conf: |
|
||||
server {
|
||||
listen 80;
|
||||
server_name nginx.prod.local;
|
||||
|
||||
location / {
|
||||
return 200 "nginx PROD environment\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
# Registry pull secret used by the nginx Deployment (imagePullSecrets).
|
||||
# Replace the credentials with the real registry values, or regenerate with:
|
||||
# kubectl create secret docker-registry harbor-secret \
|
||||
# --docker-server=imageregistry.gen-itech.com \
|
||||
# --docker-username=demo --docker-password=demo123 \
|
||||
# -n prod --dry-run=client -o yaml
|
||||
# ---------------------------------------------------------------------------
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: harbor-secret
|
||||
namespace: prod
|
||||
type: kubernetes.io/dockerconfigjson
|
||||
stringData:
|
||||
.dockerconfigjson: |
|
||||
{"auths":{"imageregistry.gen-itech.com":{"username":"demo","password":"demo123","auth":"ZGVtbzpkZW1vMTIz"}}}
|
||||
|
||||
---
|
||||
# ---------------------------------------------------------------------------
|
||||
# Application secret for the nginx container (loaded via envFrom).
|
||||
# ---------------------------------------------------------------------------
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: nginx-secret-prod
|
||||
namespace: prod
|
||||
type: Opaque
|
||||
stringData:
|
||||
APP_ENV: prod
|
||||
APP_SECRET: change-me-prod
|
||||
@@ -0,0 +1,16 @@
|
||||
# PROD environment overrides for nginx-chart
|
||||
namespace: prod
|
||||
|
||||
replicaCount: 3
|
||||
|
||||
image:
|
||||
tag: "39"
|
||||
|
||||
ingress:
|
||||
host: nginx.prod.local
|
||||
|
||||
configMap:
|
||||
name: nginx-config-prod
|
||||
|
||||
secret:
|
||||
name: nginx-secret-prod
|
||||
@@ -0,0 +1,19 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: nginx-config-stg
|
||||
namespace: stg
|
||||
labels:
|
||||
app: nginx
|
||||
env: stg
|
||||
data:
|
||||
default.conf: |
|
||||
server {
|
||||
listen 80;
|
||||
server_name nginx.stg.local;
|
||||
|
||||
location / {
|
||||
return 200 "nginx STG environment\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
# Registry pull secret used by the nginx Deployment (imagePullSecrets).
|
||||
# Replace the credentials with the real registry values, or regenerate with:
|
||||
# kubectl create secret docker-registry harbor-secret \
|
||||
# --docker-server=imageregistry.gen-itech.com \
|
||||
# --docker-username=demo --docker-password=demo123 \
|
||||
# -n stg --dry-run=client -o yaml
|
||||
# ---------------------------------------------------------------------------
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: harbor-secret
|
||||
namespace: stg
|
||||
type: kubernetes.io/dockerconfigjson
|
||||
stringData:
|
||||
.dockerconfigjson: |
|
||||
{"auths":{"imageregistry.gen-itech.com":{"username":"demo","password":"demo123","auth":"ZGVtbzpkZW1vMTIz"}}}
|
||||
|
||||
---
|
||||
# ---------------------------------------------------------------------------
|
||||
# Application secret for the nginx container (loaded via envFrom).
|
||||
# ---------------------------------------------------------------------------
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: nginx-secret-stg
|
||||
namespace: stg
|
||||
type: Opaque
|
||||
stringData:
|
||||
APP_ENV: stg
|
||||
APP_SECRET: change-me-stg
|
||||
@@ -0,0 +1,16 @@
|
||||
# STG (staging) environment overrides for nginx-chart
|
||||
namespace: stg
|
||||
|
||||
replicaCount: 2
|
||||
|
||||
image:
|
||||
tag: "39"
|
||||
|
||||
ingress:
|
||||
host: nginx.stg.local
|
||||
|
||||
configMap:
|
||||
name: nginx-config-stg
|
||||
|
||||
secret:
|
||||
name: nginx-secret-stg
|
||||
@@ -18,9 +18,21 @@ spec:
|
||||
app: nginx
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: harbor-secret
|
||||
- name: {{ .Values.imagePullSecrets }}
|
||||
containers:
|
||||
- name: nginx
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
ports:
|
||||
- containerPort: 80
|
||||
- containerPort: 80
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: {{ .Values.secret.name }}
|
||||
volumeMounts:
|
||||
- name: nginx-config
|
||||
mountPath: /etc/nginx/conf.d/default.conf
|
||||
subPath: default.conf
|
||||
volumes:
|
||||
- name: nginx-config
|
||||
configMap:
|
||||
name: {{ .Values.configMap.name }}
|
||||
|
||||
+26
-1
@@ -1,13 +1,38 @@
|
||||
# Base (default) values for nginx-chart.
|
||||
#
|
||||
# Environment-specific overrides live in environments/<env>/values.yaml and are
|
||||
# merged on top of this file at deploy time:
|
||||
#
|
||||
# helm upgrade --install nginx ./nginx-chart -n <namespace> --create-namespace \
|
||||
# -f nginx-chart/environments/<env>/values.yaml
|
||||
#
|
||||
# Available environments: dev, stg, prod
|
||||
|
||||
replicaCount: 1
|
||||
namespace: "dev"
|
||||
|
||||
namespace: dev
|
||||
|
||||
image:
|
||||
repository: imageregistry.gen-itech.com/demo/applicationtest
|
||||
tag: "39"
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
# Name of the docker-registry pull secret (created by environments/<env>/secret.yaml)
|
||||
imagePullSecrets: harbor-secret
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 80
|
||||
|
||||
ingress:
|
||||
enabled: true
|
||||
className: traefik
|
||||
host: nginx.demo.local
|
||||
|
||||
# Names of the ConfigMap / Secret created by environments/<env>/configmap.yaml
|
||||
# and environments/<env>/secret.yaml
|
||||
configMap:
|
||||
name: nginx-config-dev
|
||||
|
||||
secret:
|
||||
name: nginx-secret-dev
|
||||
|
||||
Reference in New Issue
Block a user