From fc437c21e5377d47b9219eb9db207e4f5f2e4d6b Mon Sep 17 00:00:00 2001 From: Leo LAIOLO <llaiolo@takima.fr> Date: Wed, 14 Aug 2024 15:16:10 +0200 Subject: [PATCH] [APP] feat: deploy full app --- README.md | 13 +++- templates/api/api-config.yml | 7 ++ templates/api/api-deployment.yml | 72 +++++++++++++++++++++ templates/api/api-ingress.yml | 21 ++++++ templates/api/api-service.yml | 11 ++++ templates/database/pg-postgresql.yaml | 19 ++++++ 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 | 4 +- 11 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 templates/api/api-config.yml create mode 100644 templates/api/api-deployment.yml create mode 100644 templates/api/api-ingress.yml create mode 100644 templates/api/api-service.yml create mode 100644 templates/database/pg-postgresql.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/README.md b/README.md index 5940cad..fa91f51 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ # Kubernetes +TP : http://school.pages.takima.io/kubernetes-01/k8s-trainees/ + +Dashboard : https://kube-learning.takima.school/#/workloads?namespace=llaiolo + +> Dashboard authentication token in ~/.kube/config + ## Helm Resource generation: @@ -8,4 +14,9 @@ Resource generation: Start resources: - helm install cdbapp ./ + helm upgrade --install cdbapp ./ + + +API : https://api.llaiolo.takima.school/computers + +front : https://helm.llaiolo.takima.school/computers \ No newline at end of file diff --git a/templates/api/api-config.yml b/templates/api/api-config.yml new file mode 100644 index 0000000..28bfe81 --- /dev/null +++ b/templates/api/api-config.yml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.name }}-api +data: + db-endpoint: {{ .Values.name }}-pg:5432 + db-name: cdb diff --git a/templates/api/api-deployment.yml b/templates/api/api-deployment.yml new file mode 100644 index 0000000..969cb83 --- /dev/null +++ b/templates/api/api-deployment.yml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.name }}-api + labels: + app: api +spec: + replicas: 2 + selector: + matchLabels: + app: api + template: + metadata: + labels: + app: api + spec: + imagePullSecrets: + - name: takima-school-registry + containers: + - name: api + image: registry.gitlab.com/takima-school/images/cdb/api:latest + ports: + - containerPort: 8080 + resources: + requests: + memory: "256Mi" + cpu: "500m" + limits: + memory: "512Mi" + cpu: "2" + env: + - name: DB_ENDPOINT + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-api + key: db-endpoint + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: cdb.{{ .Values.name }}-pg.credentials.postgresql.acid.zalan.do + key: password + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: cdb.{{ .Values.name }}-pg.credentials.postgresql.acid.zalan.do + key: username + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-api + key: db-name + livenessProbe: + httpGet: + path: /actuator/health/liveness + port: 8080 + httpHeaders: + - name: Custom-Header + value: Awesome + initialDelaySeconds: 10 + periodSeconds: 3 + readinessProbe: + httpGet: + path: /actuator/health/readiness + port: 8080 + httpHeaders: + - name: Custom-Header + value: Awesome + initialDelaySeconds: 10 + periodSeconds: 3 + securityContext: + runAsUser: 1001 + runAsGroup: 1001 \ No newline at end of file diff --git a/templates/api/api-ingress.yml b/templates/api/api-ingress.yml new file mode 100644 index 0000000..299fcf2 --- /dev/null +++ b/templates/api/api-ingress.yml @@ -0,0 +1,21 @@ +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 diff --git a/templates/api/api-service.yml b/templates/api/api-service.yml new file mode 100644 index 0000000..fa8881e --- /dev/null +++ b/templates/api/api-service.yml @@ -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-postgresql.yaml b/templates/database/pg-postgresql.yaml new file mode 100644 index 0000000..f8c60cb --- /dev/null +++ b/templates/database/pg-postgresql.yaml @@ -0,0 +1,19 @@ +apiVersion: "acid.zalan.do/v1" +kind: postgresql +metadata: + name: {{ .Values.name }}-pg +spec: + teamId: {{ .Values.name }}-pg # le team id doit matcher le préfixe dans le metadata.name + volume: + size: 1Gi + numberOfInstances: 2 + users: + cdb: # database owner + - superuser + - createdb + databases: + cdb: cdb # dbname: owner + postgresql: + version: "14" + enableLogicalBackup: true + logicalBackupSchedule: 30 00 * * * \ 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 00374fa..a2c0ee0 100644 --- a/values.yaml +++ b/values.yaml @@ -6,7 +6,7 @@ name: cdbapp api: ingress: - tlsEnabled: false + tlsEnabled: true host: api.llaiolo.takima.school front: @@ -16,5 +16,5 @@ front: tag: latest replicaCount: 1 ingress: - tlsEnabled: false + tlsEnabled: true host: helm.llaiolo.takima.school \ No newline at end of file -- GitLab