From a0d7c959a44c3b71c5e0284bf379776b8994327f Mon Sep 17 00:00:00 2001 From: slaventius Date: Tue, 21 Feb 2023 12:25:28 +0300 Subject: [PATCH] add helm --- deploy/{ => .pre}/auth-config.yaml | 0 deploy/{ => .pre}/auth-deployment.yaml | 7 ++++ deploy/{ => .pre}/auth-secret.yaml | 0 deploy/{ => .pre}/auth-service.yaml | 0 deploy/helm/Chart.yaml | 6 ++++ deploy/helm/templates/config.yaml | 8 +++++ deploy/helm/templates/deployment.yaml | 49 ++++++++++++++++++++++++++ deploy/helm/templates/pv.yaml | 22 ++++++++++++ deploy/helm/templates/pvc.yaml | 11 ++++++ deploy/helm/templates/sc.yaml | 6 ++++ deploy/helm/templates/secret.yaml | 7 ++++ deploy/helm/templates/service.yaml | 13 +++++++ deploy/helm/values.yaml | 4 +++ 13 files changed, 133 insertions(+) rename deploy/{ => .pre}/auth-config.yaml (100%) rename deploy/{ => .pre}/auth-deployment.yaml (83%) rename deploy/{ => .pre}/auth-secret.yaml (100%) rename deploy/{ => .pre}/auth-service.yaml (100%) create mode 100644 deploy/helm/Chart.yaml create mode 100644 deploy/helm/templates/config.yaml create mode 100644 deploy/helm/templates/deployment.yaml create mode 100644 deploy/helm/templates/pv.yaml create mode 100644 deploy/helm/templates/pvc.yaml create mode 100644 deploy/helm/templates/sc.yaml create mode 100644 deploy/helm/templates/secret.yaml create mode 100644 deploy/helm/templates/service.yaml create mode 100644 deploy/helm/values.yaml diff --git a/deploy/auth-config.yaml b/deploy/.pre/auth-config.yaml similarity index 100% rename from deploy/auth-config.yaml rename to deploy/.pre/auth-config.yaml diff --git a/deploy/auth-deployment.yaml b/deploy/.pre/auth-deployment.yaml similarity index 83% rename from deploy/auth-deployment.yaml rename to deploy/.pre/auth-deployment.yaml index c174d2e..23b0e7c 100644 --- a/deploy/auth-deployment.yaml +++ b/deploy/.pre/auth-deployment.yaml @@ -40,3 +40,10 @@ spec: initialDelaySeconds: 4 failureThreshold: 3 successThreshold: 1 + volumeMounts: + - name: auth-storage + mountPath: /mnt + volumes: + - name: auth-storage + persistentVolumeClaim: + claimName: auth-pvc diff --git a/deploy/auth-secret.yaml b/deploy/.pre/auth-secret.yaml similarity index 100% rename from deploy/auth-secret.yaml rename to deploy/.pre/auth-secret.yaml diff --git a/deploy/auth-service.yaml b/deploy/.pre/auth-service.yaml similarity index 100% rename from deploy/auth-service.yaml rename to deploy/.pre/auth-service.yaml diff --git a/deploy/helm/Chart.yaml b/deploy/helm/Chart.yaml new file mode 100644 index 0000000..15d83f6 --- /dev/null +++ b/deploy/helm/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: apps/v1 +name: auth-HelmChart +description: Helm Chart for auth +type: application +version: 0.1.0 +appVersion: "1.0.0" diff --git a/deploy/helm/templates/config.yaml b/deploy/helm/templates/config.yaml new file mode 100644 index 0000000..9611e1b --- /dev/null +++ b/deploy/helm/templates/config.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-config +data: + DB_HOST: "auth-db-service" + DB_PORT: "9995" + APP_PORT: "9994" diff --git a/deploy/helm/templates/deployment.yaml b/deploy/helm/templates/deployment.yaml new file mode 100644 index 0000000..26af63c --- /dev/null +++ b/deploy/helm/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-deployment + labels: + app: {{ .Release.Name }}-deployment +spec: + replicas: {{ .Values.replicas }} + selector: + matchLabels: + app: {{ .Release.Name }}-application + template: + metadata: + labels: + app: {{ .Release.Name }}-application + spec: + containers: + - name: {{ .Release.Name }}-application + image: {{ .Values.container.image }} + imagePullPolicy: Always + ports: + - containerPort: {{ .Values.container.port }} + envFrom: + - secretRef: + name: {{ .Release.Name }}-secret + - configMapRef: + name: {{ .Release.Name }}-config + livenessProbe: + tcpSocket: + port: {{ .Values.container.port }} + periodSeconds: 1 + initialDelaySeconds: 2 + failureThreshold: 3 + successThreshold: 1 + readinessProbe: + httpGet: + path: /api/v1/healthz + port: {{ .Values.container.port }} + periodSeconds: 1 + initialDelaySeconds: 4 + failureThreshold: 3 + successThreshold: 1 + volumeMounts: + - name: {{ .Release.Name }}-storage + mountPath: /mnt + volumes: + - name: {{ .Release.Name }}-storage + persistentVolumeClaim: + claimName: {{ .Release.Name }}-pvc diff --git a/deploy/helm/templates/pv.yaml b/deploy/helm/templates/pv.yaml new file mode 100644 index 0000000..deb7dd7 --- /dev/null +++ b/deploy/helm/templates/pv.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: {{ .Release.Name }}-pv +spec: + capacity: + storage: 1Gi + volumeMode: Filesystem + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + storageClassName: {{ .Release.Name }}-sc + local: + path: /mnt/{{ .Release.Name }}-storage + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - kub-node-1 diff --git a/deploy/helm/templates/pvc.yaml b/deploy/helm/templates/pvc.yaml new file mode 100644 index 0000000..6db978e --- /dev/null +++ b/deploy/helm/templates/pvc.yaml @@ -0,0 +1,11 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ .Release.Name }}-pvc +spec: + accessModes: + - ReadWriteOnce + volumeMode: Filesystem + resources: + requests: + storage: 1Gi diff --git a/deploy/helm/templates/sc.yaml b/deploy/helm/templates/sc.yaml new file mode 100644 index 0000000..a72ab4f --- /dev/null +++ b/deploy/helm/templates/sc.yaml @@ -0,0 +1,6 @@ +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: {{ .Release.Name }}-sc +provisioner: kubernetes.io/no-provisioner +volumeBindingMode: WaitForFirstConsumer diff --git a/deploy/helm/templates/secret.yaml b/deploy/helm/templates/secret.yaml new file mode 100644 index 0000000..85c3dac --- /dev/null +++ b/deploy/helm/templates/secret.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Release.Name }}-secret +type: Opaque +data: + SENTRY_DSN: aHR0cHM6Ly8zZjRiMzFkYmJkOWE0YTZiOGE3MWY5ODgxZDk2MmYyNUBvNDUwNDY1NDU2OTc5OTY4MC5pbmdlc3Quc2VudHJ5LmlvLzQ1MDQ2NTQ1NzI2ODMyNjQ= diff --git a/deploy/helm/templates/service.yaml b/deploy/helm/templates/service.yaml new file mode 100644 index 0000000..369a33f --- /dev/null +++ b/deploy/helm/templates/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-service + labels: + app: {{ .Release.Name }}-application +spec: + type: NodePort + selector: + app: {{ .Release.Name }}-application + ports: + - protocol: TCP + port: {{ .Values.container.port }} diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml new file mode 100644 index 0000000..6966b75 --- /dev/null +++ b/deploy/helm/values.yaml @@ -0,0 +1,4 @@ +container: + image: slaventius/test3k_auth:latest + port: 9994 +replicas: 3