From 538041ba24d1b5cf6e1a033c7eaa8ded319a2e61 Mon Sep 17 00:00:00 2001
From: Dandoy Thibaud <tdandoy@takima.fr>
Date: Wed, 14 Aug 2024 16:21:11 +0200
Subject: [PATCH] feat: added prof provided solution

---
 templates/_helpers.tpl                 |  96 ++++++++++++++-----
 templates/api/api-config.yaml          |   8 +-
 templates/api/api-deployment.yaml      | 128 +++++++++++++------------
 templates/api/api-ingress.yaml         |  14 +--
 templates/api/api-service.yaml         |   8 +-
 templates/database/pg-config.yaml      |   9 +-
 templates/database/pg-credentials.yaml |   9 +-
 templates/database/pg-deployment.yaml  |  91 ++++++++----------
 templates/database/pg-pvc.yaml         |  11 ++-
 templates/database/pg-service.yaml     |  13 +--
 templates/front/front-config.yaml      |   2 +-
 templates/front/front-deployment.yaml  |  15 ++-
 templates/front/front-ingress.yaml     |   5 +-
 templates/front/front-service.yaml     |   6 +-
 values.prod.yaml                       |  37 +++++++
 values.staging.yaml                    |  37 +++++++
 values.yaml                            |  35 +++++--
 17 files changed, 339 insertions(+), 185 deletions(-)
 create mode 100644 values.prod.yaml
 create mode 100644 values.staging.yaml

diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl
index e27fd56..a5a0106 100644
--- a/templates/_helpers.tpl
+++ b/templates/_helpers.tpl
@@ -1,53 +1,101 @@
 {{/*
 Expand the name of the chart.
 */}}
-{{- define "MyAppCtx.name" -}}
-{{- default .Chart.Name | trunc 63 | trimSuffix "-" }}
+{{- define "AppCtx.chartName" -}}
+{{- default .Chart.Name | trunc 24 | trimSuffix "-" }}
 {{- end }}
 
-
 {{/*
-Application image tag
-We select by default the Chart appVersion or an override in values
+Create chart name and version as used by the chart label.
 */}}
-{{- define "MyAppCtx.imageTag" }}
-{{- $name := default .Chart.AppVersion .Values.image.tag }}
-{{- printf "%s" $name }}
+{{- define "AppCtx.chartNameVersion" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
 {{- end }}
 
-
 {{/*
 Create a default fully qualified app name.
-We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+We truncate at 30 chars in order to leave room for suffixes (because some Kubernetes name fields are limited to 63 chars by the DNS naming spec).
 */}}
-{{- define "MyAppCtx.fullname" }}
+{{- define "AppCtx.name" }}
 {{- $name := default .Chart.Name .Values.nameOverride -}}
-{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-"}}
+{{- printf "%s" $name | trunc 30 | trimSuffix "-"}}
 {{- end }}
 
 {{/*
-Create chart name and version as used by the chart label.
+Create the API name
 */}}
-{{- define "MyAppCtx.chart" -}}
-{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- define "AppCtx.apiName" }}
+{{- printf "%s-api" (include "AppCtx.name" .) | trunc 63  }}
 {{- end }}
 
 {{/*
-Common labels
+Create the Front name
 */}}
-{{- define "MyAppCtx.labels" -}}
-helm.sh/chart: {{ include "MyAppCtx.chart" . }}
-{{ include "MyAppCtx.selectorLabels" . }}
-{{- if .Chart.AppVersion }}
-app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- define "AppCtx.frontName" }}
+{{- printf "%s-front" (include "AppCtx.name" .) | trunc 63  }}
 {{- end }}
-app.kubernetes.io/managed-by: {{ .Release.Service }}
+
+{{/*
+Create the DB name
+*/}}
+{{- define "AppCtx.dbName" }}
+{{- printf "%s-db" (include "AppCtx.name" .) | trunc 63 }}
 {{- end }}
 
 {{/*
 Selector labels
 */}}
-{{- define "MyAppCtx.selectorLabels" -}}
-app.kubernetes.io/name: {{ include "MyAppCtx.name" . }}
+{{- define "AppCtx.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "AppCtx.name" . }}
 app.kubernetes.io/instance: {{ .Release.Name }}
 {{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "AppCtx.labels" -}}
+helm.sh/chart: {{ include "AppCtx.chartName" . }}
+{{ include "AppCtx.selectorLabels" . }}
+app.kubernetes.io/part-of: {{ include "AppCtx.chartName" . }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{- define "AppCtx.apiSelectorLabels" -}}
+{{ include "AppCtx.selectorLabels" . }}
+app.kubernetes.io/component: api
+{{- end }}
+
+{{- define "AppCtx.apiLabels" -}}
+{{ include "AppCtx.apiSelectorLabels" . }}
+app.kubernetes.io/part-of: {{ include "AppCtx.chartName" . }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+app/language: java
+app/version: {{ .Values.api.image.tag }}
+{{- end }}
+
+
+{{- define "AppCtx.frontSelectorLabels" -}}
+{{ include "AppCtx.selectorLabels" . }}
+app.kubernetes.io/component: front
+{{- end }}
+
+{{- define "AppCtx.frontLabels" -}}
+{{ include "AppCtx.frontSelectorLabels" . }}
+app.kubernetes.io/part-of: {{ include "AppCtx.chartName" . }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+app/language: javascript
+app/version: {{ .Values.front.image.tag }}
+{{- end }}
+
+{{- define "AppCtx.dbSelectorLabels" -}}
+{{ include "AppCtx.selectorLabels" . }}
+app.kubernetes.io/component: db
+{{- end }}
+
+{{- define "AppCtx.dbLabels" -}}
+{{ include "AppCtx.dbSelectorLabels" . }}
+app.kubernetes.io/part-of: {{ include "AppCtx.chartName" . }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+app/language: postgresql
+app/version: {{ .Values.db.image.tag }}
+{{- end }}
diff --git a/templates/api/api-config.yaml b/templates/api/api-config.yaml
index 642f9e5..39d56d6 100644
--- a/templates/api/api-config.yaml
+++ b/templates/api/api-config.yaml
@@ -1,6 +1,10 @@
+{{- if .Values.api.enabled }}  
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  name: {{ .Values.api.name }}-config
+  name: {{ template "AppCtx.apiName" . }}
+  labels: {{ include "AppCtx.apiLabels" . | nindent 4 }}
 data:
-  name: pg-service:5432
+  DB_ENDPOINT: "{{ template "AppCtx.dbName" . }}:5432"
+  DB_NAME: {{ .Values.db.name }}
+{{- end }}
\ No newline at end of file
diff --git a/templates/api/api-deployment.yaml b/templates/api/api-deployment.yaml
index 026cb51..baf0af5 100644
--- a/templates/api/api-deployment.yaml
+++ b/templates/api/api-deployment.yaml
@@ -1,73 +1,79 @@
+{{- if .Values.api.enabled }}
 apiVersion: apps/v1
 kind: Deployment
 metadata:
-  name: {{ .Values.api.name }}-deployment
-  labels:
-    app: api
+  name: {{ template "AppCtx.apiName" . }}
+  labels: {{ include "AppCtx.apiLabels" . | nindent 4 }}
 spec:
   replicas: {{ .Values.api.replicaCount }}
   selector:
-    matchLabels:
-      app: {{ .Values.api.name }}
+    matchLabels: {{ include "AppCtx.apiSelectorLabels" . | nindent 8 }}
   template:
     metadata:
-      labels:
-        app: {{ .Values.api.name }}
+      labels: {{ include "AppCtx.apiLabels" . | nindent 10 }}
+      annotations:
+        checksum/config: {{ include (print $.Template.BasePath "/api-config.yaml") . | sha256sum }}
     spec:
+      securityContext:
+        runAsUser: 1001
+        runAsGroup: 1001
       imagePullSecrets:
         - name: takima-school-registry
       containers:
-        - name: {{ .Values.api.name }}
-          securityContext:
-            runAsUser: 1001
-            runAsGroup: 1001
-          image: {{ .Values.api.image.repository }}:{{ .Values.api.image.tag }}
-          ports:
-            - containerPort: 8080
-          args:
-            - liveness
-            - readiness
-          livenessProbe:
-            failureThreshold: 5
-            httpGet:
-              path: /actuator/health/liveness
-              port: 8080
-            initialDelaySeconds: 15
-            periodSeconds: 3
-          readinessProbe: 
-            failureThreshold: 5
-            httpGet:
-              path: /actuator/health/readiness
-              port: 8080
-            initialDelaySeconds: 15
-            periodSeconds: 3
-          env:
-            - name: DB_ENDPOINT
-              valueFrom:
-                configMapKeyRef:
-                  name: {{ .Values.api.name }}-config
-                  key: name
-            - name: POSTGRES_PASSWORD
-              valueFrom:
-                secretKeyRef:
-                  name: {{ .Values.pg.name }}-credentials
-                  key: password
-            - name: POSTGRES_USER
-              valueFrom:
-                secretKeyRef:
-                  name: {{ .Values.pg.name }}-credentials
-                  key: username
-            - name: POSTGRES_DB
-              valueFrom:
-                configMapKeyRef:
-                  name: {{ .Values.pg.name }}-config
-                  key: db-name
-          resources:
-            limits:
-              cpu: 2
-              memory: "256M"
-            requests:
-              cpu: "100m"
-              memory: "192M"
-
-
+      - name: api
+        image: {{ .Values.api.image.repository }}:{{ .Values.api.image.tag }}
+        resources:
+          requests:
+            memory: {{ .Values.api.requests.memory }}
+            cpu: {{ .Values.api.requests.cpu }}
+          limits:
+            memory: {{ .Values.api.limits.memory }}
+            cpu: {{ .Values.api.limits.cpu }}
+        startupProbe:
+          httpGet:
+            path: /actuator/health
+            port: 8080
+          initialDelaySeconds: {{ .Values.api.startupProbe.initialDelaySeconds }}
+          periodSeconds: {{ .Values.api.startupProbe.periodSeconds }}
+          successThreshold: 1
+          failureThreshold: {{ .Values.api.startupProbe.failureThreshold }}
+        livenessProbe:
+          httpGet:
+            path: /actuator/health/liveness
+            port: 8080
+          periodSeconds: 3
+          successThreshold: 1
+          failureThreshold: 3
+        readinessProbe:
+          httpGet:
+            path: /actuator/health/readiness
+            port: 8080
+          periodSeconds: 1
+          successThreshold: 1
+          failureThreshold: 3        
+        securityContext:
+          allowPrivilegeEscalation: false
+        ports:
+        - containerPort: 8080
+        env: 
+          - name: DB_ENDPOINT
+            valueFrom:
+              configMapKeyRef:
+                name: {{ template "AppCtx.apiName" . }}
+                key: DB_ENDPOINT
+          - name: POSTGRES_DB
+            valueFrom:
+              configMapKeyRef:
+                name: {{ template "AppCtx.apiName" . }}
+                key: DB_NAME
+          - name: POSTGRES_USER
+            valueFrom:
+              secretKeyRef:
+                name: {{ template "AppCtx.dbName" . }}-credentials  # Nom du secret
+                key: pg_username     # nom de la clef dans le config map
+          - name: POSTGRES_PASSWORD
+            valueFrom:
+              secretKeyRef:
+                name: {{ template "AppCtx.dbName" . }}-credentials  # Nom du secret
+                key: pg_password 
+{{- end }}
\ No newline at end of file
diff --git a/templates/api/api-ingress.yaml b/templates/api/api-ingress.yaml
index 1ef63b3..c8bb6b2 100644
--- a/templates/api/api-ingress.yaml
+++ b/templates/api/api-ingress.yaml
@@ -1,24 +1,24 @@
+{{- if .Values.api.enabled }}
 apiVersion: networking.k8s.io/v1
 kind: Ingress
 metadata:
-  name: api-ingress
-  annotations:
-    cert-manager.io/cluster-issuer: letsencrypt-staging
-    kubernetes.io/tls-acme: 'true'
+ name: {{ template "AppCtx.apiName" . }}
+ labels: {{ include "AppCtx.apiLabels" . | nindent 4 }}
 spec:
   ingressClassName: nginx
   rules:
-  - host: api.tdandoy.takima.school
+  - host: {{ .Values.api.ingress.host }}
     http:
       paths:
       - backend:
           service:
-            name: api-service
+            name: {{ template "AppCtx.apiName" . }}
             port:
               number: 80
         path: /
         pathType: Prefix
   tls:
   - hosts:
-    - kube.tdandoy.takima.school
+     - {{ .Values.api.ingress.host }}
     secretName: app-wildcard
+{{- end }}
diff --git a/templates/api/api-service.yaml b/templates/api/api-service.yaml
index 26fd368..0f55be5 100644
--- a/templates/api/api-service.yaml
+++ b/templates/api/api-service.yaml
@@ -1,11 +1,13 @@
+{{- if .Values.api.enabled }}
 apiVersion: v1
 kind: Service
 metadata:
-  name: {{ .Values.api.name }}-service
+  name: {{ template "AppCtx.apiName" . }}
+  labels: {{ include "AppCtx.apiLabels" . | nindent 8 }}
 spec:
-  selector:
-    app: {{ .Values.api.name }}
+  selector: {{ include "AppCtx.apiSelectorLabels" . | nindent 4 }}
   ports:
     - protocol: TCP
       port: 80
       targetPort: 8080
+{{- end }}
\ No newline at end of file
diff --git a/templates/database/pg-config.yaml b/templates/database/pg-config.yaml
index f23a319..9704903 100644
--- a/templates/database/pg-config.yaml
+++ b/templates/database/pg-config.yaml
@@ -1,7 +1,10 @@
+{{- if .Values.db.enabled }}
 apiVersion: v1
 kind: ConfigMap
 metadata:
-  name: {{ .Values.pg.name }}-config
+  name: {{ template "AppCtx.dbName" . }}
+  labels: {{ include "AppCtx.dbLabels" . | nindent 4 }}
 data:
-  db-name: "cdb-db"
-  db-path: "/var/lib/postgresql/data/pgdata"
+  db_name: {{ .Values.db.name }}
+  db_path: "/var/lib/postgresql/data/pgdata"
+{{- end }}
\ No newline at end of file
diff --git a/templates/database/pg-credentials.yaml b/templates/database/pg-credentials.yaml
index 7ca5560..69b2d6e 100644
--- a/templates/database/pg-credentials.yaml
+++ b/templates/database/pg-credentials.yaml
@@ -1,8 +1,11 @@
+{{- if .Values.db.enabled }}
 apiVersion: v1
 kind: Secret
 metadata:
-  name: {{ .Values.pg.name }}-credentials
+  name: {{ template "AppCtx.dbName" . }}-credentials
+  labels: {{ include "AppCtx.dbLabels" . | nindent 4 }}
 type: Opaque
 data:
-  username: cG9vZg==
-  password: ZGVyZ2Vu
+  pg_username: YWRtaW4=   # user: admin
+  pg_password: dGVzdDEyMyo=  # pwd: test123*
+{{- end }}
\ No newline at end of file
diff --git a/templates/database/pg-deployment.yaml b/templates/database/pg-deployment.yaml
index 7d75aee..c4fd65a 100644
--- a/templates/database/pg-deployment.yaml
+++ b/templates/database/pg-deployment.yaml
@@ -1,59 +1,52 @@
+{{- if .Values.db.enabled }}
 apiVersion: apps/v1
 kind: Deployment
 metadata:
-  name: {{ .Values.pg.name }}-deployment
-  labels:
-    app: {{ .Values.pg.name }}
+  name: {{ template "AppCtx.dbName" . }}
+  labels: {{ include "AppCtx.dbLabels" . | nindent 4 }}
 spec:
   replicas: 1
   selector:
-    matchLabels:
-      app: {{ .Values.pg.name }}
+    matchLabels: {{ include "AppCtx.dbSelectorLabels" . | nindent 8 }}
   template:
     metadata:
-      labels:
-        app: {{ .Values.pg.name }}
+      labels: {{ include "AppCtx.dbLabels" . | nindent 10 }}
+      annotations:
+        checksum/config: {{ include (print $.Template.BasePath "/front-config.yaml") . | sha256sum }}
     spec:
-      volumes:
-        - name: {{ .Values.pg.name }}-data
-          persistentVolumeClaim:
-            claimName: {{ .Values.pg.name }}-db
-      imagePullSecrets:
-        - name: takima-school-registry
       containers:
-        - name: {{ .Values.pg.name }}
-          volumeMounts:
-            - mountPath: /var/lib/postgresql/data
-              name: {{ .Values.pg.name }}-data
-          image: {{ .Values.pg.image.repository }}:{{ .Values.pg.image.tag }}
-          ports:
-            - containerPort: 5432
-          env:
-            - name: POSTGRES_PASSWORD
-              valueFrom:
-                secretKeyRef:
-                  name: {{ .Values.pg.name }}-credentials
-                  key: password
-            - name: POSTGRES_USER
-              valueFrom:
-                secretKeyRef:
-                  name: {{ .Values.pg.name }}-credentials
-                  key: username
-            - name: POSTGRES_DB
-              valueFrom:
-                configMapKeyRef:
-                  name: {{ .Values.pg.name }}-config
-                  key: db-name
-            - name: PGDATA
-              valueFrom:
-                configMapKeyRef:
-                  name: {{ .Values.pg.name }}-config  # Nom du configmap
-                  key: db-path     # nom de la clef dans le configMap contenant path où installer la db dans le volume persistant
-          resources:
-            limits:
-              cpu: 1
-              memory: "256M"
-            requests:
-              cpu: "100m"
-              memory: "192M"
-
+      - name: postgres
+        image: {{ .Values.db.image.repository }}:{{ .Values.db.image.tag }}
+        ports:
+        - containerPort: 80
+        env:
+          - name: POSTGRES_DB
+            valueFrom:
+              configMapKeyRef:
+                name: {{ template "AppCtx.dbName" . }}  # Nom du configmap
+                key: db_name     # nom de la clef dans le config map contenant le nom de la DB
+          - name: PGDATA
+            valueFrom:
+              configMapKeyRef:
+                name: {{ template "AppCtx.dbName" . }}  # Nom du configmap
+                key: db_path     # nom de la clef dans le configMap contenant path ou installer la db dans le volume persistant
+          - name: POSTGRES_USER
+            valueFrom:
+              secretKeyRef:
+                name: {{ template "AppCtx.dbName" . }}-credentials  # Nom du secret
+                key: pg_username     # nom de la clef dans le secret
+          - name: POSTGRES_PASSWORD
+            valueFrom:
+              secretKeyRef:
+                name: {{ template "AppCtx.dbName" . }}-credentials  # Nom du secret
+                key: pg_password     # nom de la clef dans le secret contenant le password
+        volumeMounts:
+        - mountPath: /var/lib/postgresql/data
+          name: pg-data
+      imagePullSecrets:
+      - name: takima-school-registry
+      volumes:
+      - name: pg-data
+        persistentVolumeClaim:
+          claimName: {{ template "AppCtx.dbName" . }}
+{{- end }}
diff --git a/templates/database/pg-pvc.yaml b/templates/database/pg-pvc.yaml
index 8cb42e3..1ba7294 100644
--- a/templates/database/pg-pvc.yaml
+++ b/templates/database/pg-pvc.yaml
@@ -1,12 +1,15 @@
+{{- if .Values.db.enabled }}
 apiVersion: v1
 kind: PersistentVolumeClaim
 metadata:
-  name: {{ .Values.pg.name }}-db
+  name: {{ template "AppCtx.dbName" . }}
+  labels: {{ include "AppCtx.dbLabels" . | nindent 4 }}
 spec:
-  storageClassName: gp2
   accessModes:
-  - ReadWriteOnce
+    - ReadWriteOnce
   volumeMode: Filesystem
   resources:
     requests:
-      storage: 3Gi
+      storage: {{ .Values.db.pvc.size }}
+  storageClassName: {{ .Values.db.pvc.storageClass }}
+{{- end }}
diff --git a/templates/database/pg-service.yaml b/templates/database/pg-service.yaml
index 87ad4db..547fd0c 100644
--- a/templates/database/pg-service.yaml
+++ b/templates/database/pg-service.yaml
@@ -1,11 +1,12 @@
+{{- if .Values.db.enabled }}
 apiVersion: v1
 kind: Service
 metadata:
-  name: {{ .Values.pg.name }}-service
+  name: {{ template "AppCtx.dbName" . }}
+  labels: {{ include "AppCtx.dbLabels" . | nindent 4 }}
 spec:
-  selector:
-    app: {{ .Values.pg.name }}
+  selector: {{ include "AppCtx.dbSelectorLabels" . | nindent 4 }}
+  type: ClusterIP
   ports:
-    - protocol: TCP
-      port: 5432
-      targetPort: 5432
+   - port: 5432
+{{- end}}
diff --git a/templates/front/front-config.yaml b/templates/front/front-config.yaml
index 2ed35ca..5d5fd45 100644
--- a/templates/front/front-config.yaml
+++ b/templates/front/front-config.yaml
@@ -8,7 +8,7 @@
 apiVersion: v1  
 kind: ConfigMap  
 metadata:  
-  name: {{ .Values.front.name }}-front
+  name: {{ template "AppCtx.frontName" . }}
 data:  
   API_URL: {{ $apiUrl }}  
 {{- end }}
\ No newline at end of file
diff --git a/templates/front/front-deployment.yaml b/templates/front/front-deployment.yaml
index be7f97c..6e98e4b 100644
--- a/templates/front/front-deployment.yaml
+++ b/templates/front/front-deployment.yaml
@@ -2,18 +2,17 @@
 apiVersion: apps/v1
 kind: Deployment
 metadata:
-  name: {{ .Values.front.name }}-front
-  labels:
-    app: front
+  name: {{ template "AppCtx.frontName" . }}
+  labels: {{ include "AppCtx.frontLabels" . | nindent 4 }}
 spec:
   replicas: {{ .Values.front.replicaCount }}
   selector:
-    matchLabels:
-      app: front
+    matchLabels: {{ include "AppCtx.frontSelectorLabels" . | nindent 8 }}
   template:
     metadata:
-      labels:
-        app: front
+      labels: {{ include "AppCtx.frontLabels" . | nindent 10 }}
+      annotations:
+        checksum/config: {{ include (print $.Template.BasePath "/front-config.yaml") . | sha256sum }}
     spec:
       imagePullSecrets:
         - name: takima-school-registry
@@ -63,6 +62,6 @@ spec:
           - name: API_URL
             valueFrom:
               configMapKeyRef:
-                name: {{ .Values.front.name }}-front
+                name: {{ template "AppCtx.frontName" . }}
                 key: API_URL
 {{- end }}
\ No newline at end of file
diff --git a/templates/front/front-ingress.yaml b/templates/front/front-ingress.yaml
index 3d7d3f2..9d8648d 100644
--- a/templates/front/front-ingress.yaml
+++ b/templates/front/front-ingress.yaml
@@ -2,7 +2,8 @@
 apiVersion: networking.k8s.io/v1
 kind: Ingress
 metadata:
- name: {{ .Values.front.name }}-front
+ name: {{ template "AppCtx.frontName" . }}
+ labels: {{ include "AppCtx.frontLabels" . | nindent 4 }}
 spec:
   ingressClassName: nginx
   rules:
@@ -11,7 +12,7 @@ spec:
       paths:
       - backend:
           service:
-            name: {{ .Values.front.name }}-front
+            name: {{ template "AppCtx.frontName" . }}
             port:
               number: 80
         path: /
diff --git a/templates/front/front-service.yaml b/templates/front/front-service.yaml
index 25e32e3..29c8200 100644
--- a/templates/front/front-service.yaml
+++ b/templates/front/front-service.yaml
@@ -2,10 +2,10 @@
 apiVersion: v1
 kind: Service
 metadata:
-  name: {{ .Values.front.name }}-front
+  name: {{ template "AppCtx.frontName" . }}
+  labels: {{ include "AppCtx.frontLabels" . | nindent 8 }}
 spec:
-  selector:
-    app: front
+  selector: {{ include "AppCtx.frontSelectorLabels" . | nindent 4 }}
   ports:
     - protocol: TCP
       port: 80
diff --git a/values.prod.yaml b/values.prod.yaml
new file mode 100644
index 0000000..ff0130e
--- /dev/null
+++ b/values.prod.yaml
@@ -0,0 +1,37 @@
+nameOverride: mycdb-prod
+
+api:
+  image:
+    tag: latest
+  replicaCount: 2
+  requests:
+    memory: "192M"
+    cpu: "0.2"
+  limits:
+    memory: "256M"
+    cpu: "1"
+  startupProbe:
+    initialDelaySeconds: 20
+    periodSeconds: 3
+    failureThreshold: 5
+  ingress:
+    tlsEnabled: true
+    host: api.tdandoy.takima.school
+
+front:
+  image:
+    tag: latest
+  replicaCount: 1
+  ingress:
+    tlsEnabled: true
+    host: www.tdandoy.takima.school
+
+db:
+  image:
+    tag: latest
+  pvc:
+    storageClass: gp2
+    size: 512Mi
+  credentials:
+    user: cdb
+    pwd: cdb123
diff --git a/values.staging.yaml b/values.staging.yaml
new file mode 100644
index 0000000..914639b
--- /dev/null
+++ b/values.staging.yaml
@@ -0,0 +1,37 @@
+nameOverride: mycdb-staging
+
+api:
+  image:
+    tag: latest
+  replicaCount: 1
+  requests:
+    memory: "128M"
+    cpu: "0.1"
+  limits:
+    memory: "256M"
+    cpu: "1"
+  startupProbe:
+    initialDelaySeconds: 20
+    periodSeconds: 3
+    failureThreshold: 5
+  ingress:
+    tlsEnabled: true
+    host: api-staging.tdandoy.takima.school
+
+front:
+  image:
+    tag: latest
+  replicaCount: 1
+  ingress:
+    tlsEnabled: true
+    host: www-staging.tdandoy.takima.school
+
+db:
+  image:
+    tag: latest
+  pvc:
+    storageClass: gp2
+    size: 512Mi
+  credentials:
+    user: cdb
+    pwd: cdb123
diff --git a/values.yaml b/values.yaml
index 781759d..24fb11a 100644
--- a/values.yaml
+++ b/values.yaml
@@ -2,16 +2,26 @@
 # This is a YAML-formatted file.
 # Declare variables to be passed into your templates.
 # We have only done front for now
-name: cdb
+nameOverride: mycdb
 
 api:
-  name: api
-  replicaCount: 1
+  enabled: true
   image:
     repository: registry.gitlab.com/takima-school/images/cdb/api
     tag: latest
+  replicaCount: 1
+  requests:
+    memory: "192M"
+    cpu: "0.2"
+  limits:
+    memory: "256M"
+    cpu: "1"
+  startupProbe:
+    initialDelaySeconds: 30
+    periodSeconds: 3
+    failureThreshold: 5
   ingress:
-    tlsEnabled: true
+    tlsEnabled: false
     host: api.tdandoy.takima.school
 
 front:
@@ -21,12 +31,19 @@ front:
     tag: latest
   replicaCount: 1
   ingress:
-    tlsEnabled: true
-    host: kube.tdandoy.takima.school
-  name: helm
+    tlsEnabled: false
+    host: www.tdandoy.takima.school
 
-pg:
-  name: pg
+db:
+  enabled: true
+  name: cdb-db
   image:
     repository: registry.takima.io/school/proxy/postgres
     tag: latest
+  pvc:
+    storageClass: gp2
+    size: 512Mi
+  credentials:
+    user: cdb
+    pwd: cdb123
+
-- 
GitLab