From 5035d1a2f3ac4a2191e8f94bb2d0e6dad7131240 Mon Sep 17 00:00:00 2001 From: Christian Zheng <czheng@takima.fr> Date: Wed, 2 Aug 2023 11:29:41 +0200 Subject: [PATCH] Init Helm resources --- front/.gitignore | 1 + front/Chart.yaml | 26 ++++++++++ front/templates/front-config.yaml | 14 ++++++ front/templates/front-deployment.yaml | 68 +++++++++++++++++++++++++++ front/templates/front-ingress.yaml | 26 ++++++++++ front/templates/front-service.yaml | 13 +++++ front/values.yaml | 20 ++++++++ 7 files changed, 168 insertions(+) create mode 100644 front/.gitignore create mode 100644 front/Chart.yaml create mode 100644 front/templates/front-config.yaml create mode 100644 front/templates/front-deployment.yaml create mode 100644 front/templates/front-ingress.yaml create mode 100644 front/templates/front-service.yaml create mode 100644 front/values.yaml diff --git a/front/.gitignore b/front/.gitignore new file mode 100644 index 0000000..7773828 --- /dev/null +++ b/front/.gitignore @@ -0,0 +1 @@ +dist/ \ No newline at end of file diff --git a/front/Chart.yaml b/front/Chart.yaml new file mode 100644 index 0000000..7f8f18d --- /dev/null +++ b/front/Chart.yaml @@ -0,0 +1,26 @@ +apiVersion: v2 +name: cdb +description: All applications in the cdb ecosystem + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +appVersion: snapshot +maintainers: +- name: takiformation + email: takiformation@takima.school diff --git a/front/templates/front-config.yaml b/front/templates/front-config.yaml new file mode 100644 index 0000000..da89df7 --- /dev/null +++ b/front/templates/front-config.yaml @@ -0,0 +1,14 @@ +{{- if .Values.front.enabled }} + {{- $apiUrl := "" }} + {{- if .Values.api.ingress.tlsEnabled }} + {{- $apiUrl = printf "https://%s" .Values.api.ingress.host | quote }} + {{- else }} + {{- $apiUrl = printf "http://%s" .Values.api.ingress.host | quote }} + {{- end }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.name }}-front +data: + API_URL: {{ $apiUrl }} +{{- end }} \ No newline at end of file diff --git a/front/templates/front-deployment.yaml b/front/templates/front-deployment.yaml new file mode 100644 index 0000000..fa7c697 --- /dev/null +++ b/front/templates/front-deployment.yaml @@ -0,0 +1,68 @@ +{{- if .Values.front.enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.name }}-front + labels: + app: front +spec: + replicas: {{ .Values.front.replicaCount }} + selector: + matchLabels: + app: front + template: + metadata: + labels: + app: front + spec: + imagePullSecrets: + - name: takima-school-registry + securityContext: + runAsUser: 101 + runAsGroup: 101 + + containers: + - name: front + image: {{ .Values.front.image.repository }}:{{ .Values.front.image.tag }} + imagePullPolicy: Always + ports: + - containerPort: 8080 + resources: + requests: + memory: "32M" + cpu: "0.1" + limits: + memory: "128M" + cpu: "1" + startupProbe: + httpGet: + path: /health + port: 8080 + initialDelaySeconds: 3 + periodSeconds: 1 + successThreshold: 1 + failureThreshold: 5 + livenessProbe: + httpGet: + path: /health + port: 8080 + periodSeconds: 3 + successThreshold: 1 + failureThreshold: 3 + readinessProbe: + httpGet: + path: /health + port: 8080 + periodSeconds: 1 + successThreshold: 1 + failureThreshold: 3 + securityContext: + allowPrivilegeEscalation: false + + env: + - name: API_URL + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-front + key: API_URL +{{- end }} \ No newline at end of file diff --git a/front/templates/front-ingress.yaml b/front/templates/front-ingress.yaml new file mode 100644 index 0000000..8513bb5 --- /dev/null +++ b/front/templates/front-ingress.yaml @@ -0,0 +1,26 @@ +{{- if .Values.front.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + kubernetes.io/ingress.class: nginx + name: {{ .Values.name }}-front +spec: + rules: + - host: {{ .Values.front.ingress.host }} + http: + paths: + - backend: + service: + name: {{ .Values.name }}-front + port: + number: 80 + path: / + pathType: Prefix + {{- if .Values.front.ingress.tlsEnabled }} + tls: + - hosts: + - {{ .Values.front.ingress.host }} + secretName: app-wildcard + {{- end }} +{{- end }} \ No newline at end of file diff --git a/front/templates/front-service.yaml b/front/templates/front-service.yaml new file mode 100644 index 0000000..8031d1a --- /dev/null +++ b/front/templates/front-service.yaml @@ -0,0 +1,13 @@ +{{- if .Values.front.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.name }}-front +spec: + selector: + app: front + ports: + - protocol: TCP + port: 80 + targetPort: 8080 +{{- end }} \ No newline at end of file diff --git a/front/values.yaml b/front/values.yaml new file mode 100644 index 0000000..0d4183a --- /dev/null +++ b/front/values.yaml @@ -0,0 +1,20 @@ +# Default values for CDB app. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +# We have only done front for now +name: cdb + +api: + ingress: + tlsEnabled: false + host: api.czheng.takima.school + +front: + enabled: true + image: + repository: registry.gitlab.com/takima-school/images/cdb/www + tag: latest + replicaCount: 1 + ingress: + tlsEnabled: false + host: www.czheng.takima.school -- GitLab