From dd2a1f3ef0f31c7476152a67ca2f67469b1ea864 Mon Sep 17 00:00:00 2001 From: lea <lbruchon@takima.fr> Date: Wed, 2 Aug 2023 15:54:35 +0200 Subject: [PATCH] helm working --- Chart.yaml | 4 +- templates/api/api-config.yaml | 7 +++ templates/api/api-deployment.yaml | 51 +++++++++++++++++++++ templates/api/api-ingress.yaml | 22 +++++++++ templates/api/api-service.yaml | 11 +++++ templates/database/pg-config.yaml | 7 +++ templates/database/pg-credentials.yaml | 8 ++++ templates/database/pg-deployment.yaml | 51 +++++++++++++++++++++ templates/database/pg-service.yaml | 11 +++++ 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 | 8 ++-- 14 files changed, 174 insertions(+), 6 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/database/pg-config.yaml create mode 100644 templates/database/pg-credentials.yaml create mode 100644 templates/database/pg-deployment.yaml create mode 100644 templates/database/pg-service.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/Chart.yaml b/Chart.yaml index 7f8f18d..98a670f 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -22,5 +22,5 @@ version: 0.1.0 # follow Semantic Versioning. They should reflect the version the application is using. appVersion: snapshot maintainers: -- name: takiformation - email: takiformation@takima.school + - name: takiformation + email: takiformation@takima.school diff --git a/templates/api/api-config.yaml b/templates/api/api-config.yaml new file mode 100644 index 0000000..0497e18 --- /dev/null +++ b/templates/api/api-config.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.name }}-api +data: + endpoint: "pg-service:5432" + database: {{ .Values.name}}-db diff --git a/templates/api/api-deployment.yaml b/templates/api/api-deployment.yaml new file mode 100644 index 0000000..1b851ae --- /dev/null +++ b/templates/api/api-deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.name }}-api + labels: + app: api +spec: + replicas: 3 + selector: + matchLabels: + app: api + template: + metadata: + labels: + app: api + spec: + containers: + - name: api + resources: + requests: + memory: "192M" + cpu: "100m" + limits: + memory: "256M" + cpu: "1" + image: registry.gitlab.com/takima-school/images/cdb/api:latest + ports: + - containerPort: 3000 + env: + - name: DB_ENDPOINT + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-api + key: endpoint + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-api + key: database + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: pg-credentials + key: username + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: pg-credentials + key: password + imagePullSecrets: + - name : takima-school-registry \ 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..8253997 --- /dev/null +++ b/templates/api/api-ingress.yaml @@ -0,0 +1,22 @@ +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 + tls: + - hosts: + - {{ .Values.api.ingress.host }} + secretName: app-wildcard diff --git a/templates/api/api-service.yaml b/templates/api/api-service.yaml new file mode 100644 index 0000000..ae8d7e5 --- /dev/null +++ b/templates/api/api-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.name}}-api +spec: + selector: + app: api + ports: + - protocol: TCP + port: 80 + targetPort: 8080 diff --git a/templates/database/pg-config.yaml b/templates/database/pg-config.yaml new file mode 100644 index 0000000..d53efcb --- /dev/null +++ b/templates/database/pg-config.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.name}}-pg +data: + database: {{ .Values.name}}-db + db_path: "/var/lib/postgresql/data/pgdata" \ No newline at end of file diff --git a/templates/database/pg-credentials.yaml b/templates/database/pg-credentials.yaml new file mode 100644 index 0000000..2800e43 --- /dev/null +++ b/templates/database/pg-credentials.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: pg-credentials +type: Opaque +data: + username: YWRtaW4= + password: MWYyZDFlMmU2N2Rm diff --git a/templates/database/pg-deployment.yaml b/templates/database/pg-deployment.yaml new file mode 100644 index 0000000..14abdd3 --- /dev/null +++ b/templates/database/pg-deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.name}}-pg + labels: + app: pg +spec: + replicas: 1 + selector: + matchLabels: + app: pg + template: + metadata: + labels: + app: pg + spec: + volumes: + - name: pg-data + persistentVolumeClaim: + claimName: pg-db + containers: + - name: pg + volumeMounts: + - mountPath: /var/lib/postgresql/data + name: pg-data + image: registry.takima.io/school/proxy/postgres:latest + ports: + - containerPort: 5432 + env: + - name: PGDATA + valueFrom: + configMapKeyRef: + name: {{ .Values.name}}-pg # Nom du configmap + key: db_path + - name: POSTGRES_DB # Vrai key de la variable d'env. Peut ĂȘtre diffĂ©rent de la valeur dans le config map + valueFrom: + configMapKeyRef: + name: {{ .Values.name}}-pg + key: database + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: pg-credentials + key: username + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: pg-credentials + key: password + imagePullSecrets: + - name : takima-school-registry \ No newline at end of file diff --git a/templates/database/pg-service.yaml b/templates/database/pg-service.yaml new file mode 100644 index 0000000..e3d1abb --- /dev/null +++ b/templates/database/pg-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: pg-service +spec: + selector: + app: pg + ports: + - protocol: TCP + port: 5432 + targetPort: 5432 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..4515d92 100644 --- a/values.yaml +++ b/values.yaml @@ -6,8 +6,8 @@ name: cdb api: ingress: - tlsEnabled: false - host: api.to-replace.takima.school + tlsEnabled: true + host: api.lbruchon.takima.school front: enabled: true @@ -16,5 +16,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.lbruchon.takima.school -- GitLab