From 8f2a0983c73fdd528ce986b5d4aa166221c644cf Mon Sep 17 00:00:00 2001 From: Laura ZABLIT <lzablit@takima.fr> Date: Fri, 9 Feb 2024 15:48:28 +0100 Subject: [PATCH] Front, API and DB deployed --- templates/api/api-config.yaml | 9 ++++ templates/api/api-deployment.yaml | 56 +++++++++++++++++++++ templates/api/api-ingress.yaml | 26 ++++++++++ templates/api/api-service.yaml | 13 +++++ templates/db/db-deployment.yaml | 22 ++++++++ templates/{ => front}/front-config.yaml | 0 templates/{ => front}/front-deployment.yaml | 0 templates/{ => front}/front-ingress.yaml | 0 templates/{ => front}/front-service.yaml | 0 values.yaml | 22 ++++++-- 10 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 templates/api/api-config.yaml create mode 100644 templates/api/api-deployment.yaml create mode 100644 templates/api/api-ingress.yaml create mode 100644 templates/api/api-service.yaml create mode 100644 templates/db/db-deployment.yaml rename templates/{ => front}/front-config.yaml (100%) rename templates/{ => front}/front-deployment.yaml (100%) rename templates/{ => front}/front-ingress.yaml (100%) rename templates/{ => front}/front-service.yaml (100%) diff --git a/templates/api/api-config.yaml b/templates/api/api-config.yaml new file mode 100644 index 0000000..99f6db2 --- /dev/null +++ b/templates/api/api-config.yaml @@ -0,0 +1,9 @@ +{{- if .Values.api.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.name }}-api +data: + DB_ENDPOINT: "{{ .Values.api.config.dbEndpoint }}:5432" + POSTGRES_DB: "cdb" +{{- end }} \ No newline at end of file diff --git a/templates/api/api-deployment.yaml b/templates/api/api-deployment.yaml new file mode 100644 index 0000000..c3aa469 --- /dev/null +++ b/templates/api/api-deployment.yaml @@ -0,0 +1,56 @@ +{{- 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: + imagePullSecrets: + - name: takima-school-registry + + containers: + - name: api + image: {{ .Values.api.image.repository }}:{{ .Values.front.image.tag }} + imagePullPolicy: Always + ports: + - containerPort: 8080 + resources: + requests: + memory: "192Mi" + cpu: "100m" + limits: + memory: "512Mi" + cpu: "1" + + env: + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: cdb.cdb-db.credentials.postgresql.acid.zalan.do # Nom du secret + key: username # nom de la clef dans le config map + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: cdb.cdb-db.credentials.postgresql.acid.zalan.do # Nom du secret + key: password + - name: DB_ENDPOINT + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-api + key: DB_ENDPOINT + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-api + key: POSTGRES_DB +{{- end }} \ No newline at end of file diff --git a/templates/api/api-ingress.yaml b/templates/api/api-ingress.yaml new file mode 100644 index 0000000..e479971 --- /dev/null +++ b/templates/api/api-ingress.yaml @@ -0,0 +1,26 @@ +{{- if .Values.api.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + kubernetes.io/ingress.class: nginx + name: {{ .Values.name }}-api +spec: + rules: + - host: {{ .Values.api.ingress.host }} + http: + paths: + - backend: + service: + name: {{ .Values.name }}-api + port: + number: 80 + path: / + pathType: Prefix + {{- if .Values.api.ingress.tlsEnabled }} + tls: + - hosts: + - {{ .Values.api.ingress.host }} + secretName: app-wildcard + {{- end }} +{{- end }} \ No newline at end of file diff --git a/templates/api/api-service.yaml b/templates/api/api-service.yaml new file mode 100644 index 0000000..78d141c --- /dev/null +++ b/templates/api/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/db/db-deployment.yaml b/templates/db/db-deployment.yaml new file mode 100644 index 0000000..d9fafdd --- /dev/null +++ b/templates/db/db-deployment.yaml @@ -0,0 +1,22 @@ +{{- if .Values.db.enabled }} +apiVersion: "acid.zalan.do/v1" +kind: postgresql +metadata: + name: {{ .Values.name }}-db + labels: + app: db +spec: + replicas: {{ .Values.db.replicaCount }} + teamId: "formation" # le team id doit matcher le préfixe dans le metadata.name, ici formation + volume: + size: 1Gi + numberOfInstances: 2 + users: + cdb: # database owner + - superuser + - createdb + databases: + cdb: cdb # dbname: owner + postgresql: + version: "14" +{{- end }} \ No newline at end of file diff --git a/templates/front-config.yaml b/templates/front/front-config.yaml similarity index 100% rename from templates/front-config.yaml rename to templates/front/front-config.yaml diff --git a/templates/front-deployment.yaml b/templates/front/front-deployment.yaml similarity index 100% rename from templates/front-deployment.yaml rename to templates/front/front-deployment.yaml diff --git a/templates/front-ingress.yaml b/templates/front/front-ingress.yaml similarity index 100% rename from templates/front-ingress.yaml rename to templates/front/front-ingress.yaml diff --git a/templates/front-service.yaml b/templates/front/front-service.yaml similarity index 100% rename from templates/front-service.yaml rename to templates/front/front-service.yaml diff --git a/values.yaml b/values.yaml index 9ab42ef..1600368 100644 --- a/values.yaml +++ b/values.yaml @@ -4,10 +4,24 @@ # We have only done front for now name: cdb +db: + enabled: true + image: + repository: registry.takima.io/school/proxy/postgres + tag: latest + replicaCount: 1 + api: + enabled: true + image: + repository: registry.gitlab.com/takima-school/images/cdb/api + tag: latest + replicaCount: 3 ingress: - tlsEnabled: false - host: api.to-replace.takima.school + tlsEnabled: true + host: api.lzablit.takima.school + config: + dbEndpoint: cdb-db front: enabled: true @@ -16,5 +30,5 @@ front: tag: latest replicaCount: 1 ingress: - tlsEnabled: false - host: www.to-replace.takima.school \ No newline at end of file + tlsEnabled: true + host: www.lzablit.takima.school \ No newline at end of file -- GitLab