diff --git a/templates/api-config.yaml b/templates/api-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8a1d62f41136e24db7f5f97b6dcea18afbff6c32 --- /dev/null +++ b/templates/api-config.yaml @@ -0,0 +1,9 @@ +{{- if .Values.api.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{.Values.name }}-api +data: + DB_ENDPOINT: "{{ .Values.name }}:5432" + DB_NAME: {{ .Values.db.name }} +{{- end }} \ No newline at end of file diff --git a/templates/api-deployment.yaml b/templates/api-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7c43f76982fb26407ec1d4acd9af08bc791bdd85 --- /dev/null +++ b/templates/api-deployment.yaml @@ -0,0 +1,80 @@ +{{- if .Values.api.enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{.Values.name }}-api + labels: + app: api +spec: + replicas: {{ .Values.api.replicaCount }} + selector: + matchLabels: + app: api + template: + metadata: + labels: + app: api + spec: + securityContext: + runAsUser: 1001 + runAsGroup: 1001 + imagePullSecrets: + - name: takima-school-registry + containers: + - name: api + image: {{ .Values.api.image.repository }}:{{ .Values.api.image.tag }} + resources: + requests: + memory: "192M" + cpu: "0.2" + limits: + memory: "256M" + cpu: "1" + startupProbe: + httpGet: + path: /actuator/health + port: 8080 + initialDelaySeconds: 15 + periodSeconds: 3 + successThreshold: 1 + failureThreshold: 5 + 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: api-config + key: DB_ENDPOINT + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: api-config + key: DB_NAME + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: pg-credentials # Nom du secret + key: pg_username # nom de la clef dans le config map + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: pg-credentials # Nom du secret + key: pg_password +{{- end }} \ No newline at end of file diff --git a/templates/api-ingress.yaml b/templates/api-ingress.yaml new file mode 100644 index 0000000000000000000000000000000000000000..607b85cd79568c11bafada7cc4d724e0d3933538 --- /dev/null +++ b/templates/api-ingress.yaml @@ -0,0 +1,23 @@ +{{- if .Values.api.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{.Values.name }}-api +spec: + ingressClassName: nginx + rules: + - host: {{ .Values.api.ingress.host }} + http: + paths: + - backend: + service: + name: {{.Values.name }}-api + port: + number: 80 + path: / + pathType: Prefix + tls: + - hosts: + - {{ .Values.api.ingress.host }} + secretName: app-wildcard +{{- end }} diff --git a/templates/api-service.yaml b/templates/api-service.yaml new file mode 100644 index 0000000000000000000000000000000000000000..596b7b30677e398882ad30cc539fb693c022f363 --- /dev/null +++ b/templates/api-service.yaml @@ -0,0 +1,13 @@ +{{- if .Values.api.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{.Values.name }}-api +spec: + selector: + app: api + ports: + - protocol: TCP + port: 80 + targetPort: 8080 +{{- end }} \ No newline at end of file diff --git a/templates/pg-config.yaml b/templates/pg-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c493cdbcd5b7c7287d5f1d8127e7aa85fec8d1b1 --- /dev/null +++ b/templates/pg-config.yaml @@ -0,0 +1,9 @@ +{{- if .Values.db.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.name }}-db +data: + db_name: {{ .Values.db.name }} + db_path: "/var/lib/postgresql/data/pgdata" +{{- end }} \ No newline at end of file diff --git a/templates/pg-credentials.yaml b/templates/pg-credentials.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2c483f5656270d2503ea46b732c1d135a3793386 --- /dev/null +++ b/templates/pg-credentials.yaml @@ -0,0 +1,10 @@ +{{- if .Values.db.enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.name }}-db +type: Opaque +data: + pg_username: YWRtaW4= # user: admin + pg_password: dGVzdDEyMyo= # pwd: test123* +{{- end }} \ No newline at end of file diff --git a/templates/pg-deployment.yaml b/templates/pg-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4e5777ac7989a78acd315ffc62905d57e6a1e3c1 --- /dev/null +++ b/templates/pg-deployment.yaml @@ -0,0 +1,46 @@ +{{- if .Values.db.enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.name }}-db + labels: + app: pg +spec: + replicas: 1 + selector: + matchLabels: + app: pg + template: + metadata: + labels: + app: pg + spec: + containers: + - name: postgres + image: {{ .Values.db.image.repository }}:{{ .Values.db.image.tag }} + ports: + - containerPort: 80 + env: + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: pg-config # 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: pg-config # 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: pg-credentials # Nom du secret + key: pg_username # nom de la clef dans le secret + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: pg-credentials # Nom du secret + key: pg_password # nom de la clef dans le secret contenant le password + imagePullSecrets: + - name: takima-school-registry +{{- end }} \ No newline at end of file diff --git a/templates/pg-service.yaml b/templates/pg-service.yaml new file mode 100644 index 0000000000000000000000000000000000000000..eb3a81cdb08b9f0a2a6169f3f8e434105d1655cf --- /dev/null +++ b/templates/pg-service.yaml @@ -0,0 +1,14 @@ +{{- if .Values.db.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.name }}-db + labels: + app: pg +spec: + type: ClusterIP + ports: + - port: 5432 + selector: + app: pg +{{- end}} diff --git a/values.yaml b/values.yaml index a9d99213c23e084d3e9a371cf32bdb80127aa0c7..fe13a95daee4cd1354b6e1e3a9684abbc55d2294 100644 --- a/values.yaml +++ b/values.yaml @@ -5,9 +5,14 @@ name: cdb api: + enabled: true ingress: - tlsEnabled: false + tlsEnabled: true host: api.esouvannavong.takima.school + replicaCount: 1 + image: + repository: registry.gitlab.com/takima-school/images/cdb/api + tag: latest front: enabled: true @@ -17,4 +22,11 @@ front: replicaCount: 1 ingress: tlsEnabled: false - host: www.esouvannavong.takima.school \ No newline at end of file + host: www.esouvannavong.takima.school + +pg: + enabled: true + name: cdb-db + image: + repository: registry.takima.io/school/proxy/postgres + tag: latest \ No newline at end of file