From bcdafda9a378fe1c8856feb9bea3cf6760ed7a3d Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Thu, 8 Feb 2024 23:52:34 +0100 Subject: [PATCH 01/56] helm create --- helm/.helmignore | 23 +++++ helm/Chart.yaml | 24 +++++ helm/templates/NOTES.txt | 22 +++++ helm/templates/_helpers.tpl | 62 +++++++++++++ helm/templates/deployment.yaml | 68 ++++++++++++++ helm/templates/hpa.yaml | 32 +++++++ helm/templates/ingress.yaml | 61 ++++++++++++ helm/templates/service.yaml | 15 +++ helm/templates/serviceaccount.yaml | 13 +++ helm/templates/tests/test-connection.yaml | 15 +++ helm/values.yaml | 107 ++++++++++++++++++++++ 11 files changed, 442 insertions(+) create mode 100644 helm/.helmignore create mode 100644 helm/Chart.yaml create mode 100644 helm/templates/NOTES.txt create mode 100644 helm/templates/_helpers.tpl create mode 100644 helm/templates/deployment.yaml create mode 100644 helm/templates/hpa.yaml create mode 100644 helm/templates/ingress.yaml create mode 100644 helm/templates/service.yaml create mode 100644 helm/templates/serviceaccount.yaml create mode 100644 helm/templates/tests/test-connection.yaml create mode 100644 helm/values.yaml diff --git a/helm/.helmignore b/helm/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 0000000..fc38992 --- /dev/null +++ b/helm/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: helm +description: A Helm chart for Kubernetes + +# 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. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt new file mode 100644 index 0000000..892e8dc --- /dev/null +++ b/helm/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "helm.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "helm.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "helm.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "helm.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl new file mode 100644 index 0000000..ba04c30 --- /dev/null +++ b/helm/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "helm.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "helm.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "helm.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "helm.labels" -}} +helm.sh/chart: {{ include "helm.chart" . }} +{{ include "helm.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "helm.selectorLabels" -}} +app.kubernetes.io/name: {{ include "helm.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "helm.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "helm.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml new file mode 100644 index 0000000..feb4b02 --- /dev/null +++ b/helm/templates/deployment.yaml @@ -0,0 +1,68 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "helm.fullname" . }} + labels: + {{- include "helm.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "helm.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "helm.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "helm.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/helm/templates/hpa.yaml b/helm/templates/hpa.yaml new file mode 100644 index 0000000..28c087e --- /dev/null +++ b/helm/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "helm.fullname" . }} + labels: + {{- include "helm.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "helm.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml new file mode 100644 index 0000000..014f7c6 --- /dev/null +++ b/helm/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "helm.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "helm.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml new file mode 100644 index 0000000..de450fc --- /dev/null +++ b/helm/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "helm.fullname" . }} + labels: + {{- include "helm.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "helm.selectorLabels" . | nindent 4 }} diff --git a/helm/templates/serviceaccount.yaml b/helm/templates/serviceaccount.yaml new file mode 100644 index 0000000..d470465 --- /dev/null +++ b/helm/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "helm.serviceAccountName" . }} + labels: + {{- include "helm.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/helm/templates/tests/test-connection.yaml b/helm/templates/tests/test-connection.yaml new file mode 100644 index 0000000..bf1c65f --- /dev/null +++ b/helm/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "helm.fullname" . }}-test-connection" + labels: + {{- include "helm.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "helm.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm/values.yaml b/helm/values.yaml new file mode 100644 index 0000000..0ed6db0 --- /dev/null +++ b/helm/values.yaml @@ -0,0 +1,107 @@ +# Default values for helm. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: nginx + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +livenessProbe: + httpGet: + path: / + port: http +readinessProbe: + httpGet: + path: / + port: http + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} From 7d1685384df8af066ccef731f4c58af085d2cec7 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Mon, 12 Feb 2024 01:01:00 +0100 Subject: [PATCH 02/56] Add release message input to release workflow --- .github/workflows/release.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8fe4e9a..78c2cd1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,6 +22,11 @@ on: required: false default: false type: boolean + releaseMessage: + description: 'Release Message' + required: false + default: '' + type: string jobs: release: @@ -76,5 +81,6 @@ jobs: with: tag_name: ${{ steps.next_version.outputs.version }} release_name: Release v${{ steps.next_version.outputs.version }} + body: ${{ github.event.inputs.releaseMessage }} draft: ${{ github.event.inputs.draft }} prerelease: ${{ github.event.inputs.prerelease }} From 27abffafdf96bf56d738fc3af0c0bed4d2554897 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Tue, 13 Feb 2024 12:48:34 +0400 Subject: [PATCH 03/56] Rename github actions workflows --- .github/workflows/{deploy.yml => deploy.yaml} | 0 .github/workflows/{django_check.yml => django_check.yaml} | 0 .github/workflows/{lint.yml => lint.yaml} | 0 .github/workflows/{publish.yml => publish.yaml} | 0 .github/workflows/{release.yml => release.yaml} | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{deploy.yml => deploy.yaml} (100%) rename .github/workflows/{django_check.yml => django_check.yaml} (100%) rename .github/workflows/{lint.yml => lint.yaml} (100%) rename .github/workflows/{publish.yml => publish.yaml} (100%) rename .github/workflows/{release.yml => release.yaml} (100%) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yaml similarity index 100% rename from .github/workflows/deploy.yml rename to .github/workflows/deploy.yaml diff --git a/.github/workflows/django_check.yml b/.github/workflows/django_check.yaml similarity index 100% rename from .github/workflows/django_check.yml rename to .github/workflows/django_check.yaml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yaml similarity index 100% rename from .github/workflows/lint.yml rename to .github/workflows/lint.yaml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yaml similarity index 100% rename from .github/workflows/publish.yml rename to .github/workflows/publish.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yaml similarity index 100% rename from .github/workflows/release.yml rename to .github/workflows/release.yaml From b8bf48906c53d2a088ec9723a88e93104f43b191 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Tue, 13 Feb 2024 12:49:13 +0400 Subject: [PATCH 04/56] Rename docker compose files --- docker-compose.yml => docker-compose.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docker-compose.yml => docker-compose.yaml (100%) diff --git a/docker-compose.yml b/docker-compose.yaml similarity index 100% rename from docker-compose.yml rename to docker-compose.yaml From ba3cab3e6f6e3a4717faac286a37cc95d3e55d6c Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Tue, 13 Feb 2024 12:50:45 +0400 Subject: [PATCH 05/56] Rename k8s yaml files --- k8s/db/{config.yml => config.yaml} | 0 k8s/db/{deployment.yml => deployment.yaml} | 0 k8s/db/{pv.yml => pv.yaml} | 0 k8s/db/{pvc.yml => pvc.yaml} | 0 k8s/db/{service.yml => service.yaml} | 0 k8s/ingress/{ingress.yml => ingress.yaml} | 0 k8s/static/{config.yml => config.yaml} | 0 k8s/static/{deployment.yml => deployment.yaml} | 0 k8s/static/{service.yml => service.yaml} | 0 k8s/web/{config.yml => config.yaml} | 0 k8s/web/{deployment.yml => deployment.yaml} | 0 k8s/web/{pv.yml => pv.yaml} | 0 k8s/web/{pvc.yml => pvc.yaml} | 0 k8s/web/{service.yml => service.yaml} | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename k8s/db/{config.yml => config.yaml} (100%) rename k8s/db/{deployment.yml => deployment.yaml} (100%) rename k8s/db/{pv.yml => pv.yaml} (100%) rename k8s/db/{pvc.yml => pvc.yaml} (100%) rename k8s/db/{service.yml => service.yaml} (100%) rename k8s/ingress/{ingress.yml => ingress.yaml} (100%) rename k8s/static/{config.yml => config.yaml} (100%) rename k8s/static/{deployment.yml => deployment.yaml} (100%) rename k8s/static/{service.yml => service.yaml} (100%) rename k8s/web/{config.yml => config.yaml} (100%) rename k8s/web/{deployment.yml => deployment.yaml} (100%) rename k8s/web/{pv.yml => pv.yaml} (100%) rename k8s/web/{pvc.yml => pvc.yaml} (100%) rename k8s/web/{service.yml => service.yaml} (100%) diff --git a/k8s/db/config.yml b/k8s/db/config.yaml similarity index 100% rename from k8s/db/config.yml rename to k8s/db/config.yaml diff --git a/k8s/db/deployment.yml b/k8s/db/deployment.yaml similarity index 100% rename from k8s/db/deployment.yml rename to k8s/db/deployment.yaml diff --git a/k8s/db/pv.yml b/k8s/db/pv.yaml similarity index 100% rename from k8s/db/pv.yml rename to k8s/db/pv.yaml diff --git a/k8s/db/pvc.yml b/k8s/db/pvc.yaml similarity index 100% rename from k8s/db/pvc.yml rename to k8s/db/pvc.yaml diff --git a/k8s/db/service.yml b/k8s/db/service.yaml similarity index 100% rename from k8s/db/service.yml rename to k8s/db/service.yaml diff --git a/k8s/ingress/ingress.yml b/k8s/ingress/ingress.yaml similarity index 100% rename from k8s/ingress/ingress.yml rename to k8s/ingress/ingress.yaml diff --git a/k8s/static/config.yml b/k8s/static/config.yaml similarity index 100% rename from k8s/static/config.yml rename to k8s/static/config.yaml diff --git a/k8s/static/deployment.yml b/k8s/static/deployment.yaml similarity index 100% rename from k8s/static/deployment.yml rename to k8s/static/deployment.yaml diff --git a/k8s/static/service.yml b/k8s/static/service.yaml similarity index 100% rename from k8s/static/service.yml rename to k8s/static/service.yaml diff --git a/k8s/web/config.yml b/k8s/web/config.yaml similarity index 100% rename from k8s/web/config.yml rename to k8s/web/config.yaml diff --git a/k8s/web/deployment.yml b/k8s/web/deployment.yaml similarity index 100% rename from k8s/web/deployment.yml rename to k8s/web/deployment.yaml diff --git a/k8s/web/pv.yml b/k8s/web/pv.yaml similarity index 100% rename from k8s/web/pv.yml rename to k8s/web/pv.yaml diff --git a/k8s/web/pvc.yml b/k8s/web/pvc.yaml similarity index 100% rename from k8s/web/pvc.yml rename to k8s/web/pvc.yaml diff --git a/k8s/web/service.yml b/k8s/web/service.yaml similarity index 100% rename from k8s/web/service.yml rename to k8s/web/service.yaml From b5dc76c9f567f7995268ad58a21da95feb168c33 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Tue, 13 Feb 2024 13:04:14 +0400 Subject: [PATCH 06/56] Move old k8s yaml to helm templates --- helm/templates/NOTES.txt | 22 ------ helm/templates/_helpers.tpl | 62 ----------------- {k8s => helm/templates}/db/config.yaml | 0 {k8s => helm/templates}/db/deployment.yaml | 0 {k8s => helm/templates}/db/pv.yaml | 0 {k8s => helm/templates}/db/pvc.yaml | 0 {k8s => helm/templates}/db/service.yaml | 0 helm/templates/deployment.yaml | 68 ------------------- helm/templates/hpa.yaml | 32 --------- helm/templates/ingress.yaml | 61 ----------------- {k8s => helm/templates}/ingress/ingress.yaml | 0 helm/templates/service.yaml | 15 ---- helm/templates/serviceaccount.yaml | 13 ---- {k8s => helm/templates}/static/config.yaml | 0 .../templates}/static/deployment.yaml | 0 {k8s => helm/templates}/static/service.yaml | 0 helm/templates/tests/test-connection.yaml | 15 ---- {k8s => helm/templates}/web/config.yaml | 0 {k8s => helm/templates}/web/deployment.yaml | 0 {k8s => helm/templates}/web/pv.yaml | 0 {k8s => helm/templates}/web/pvc.yaml | 0 {k8s => helm/templates}/web/service.yaml | 0 22 files changed, 288 deletions(-) delete mode 100644 helm/templates/NOTES.txt delete mode 100644 helm/templates/_helpers.tpl rename {k8s => helm/templates}/db/config.yaml (100%) rename {k8s => helm/templates}/db/deployment.yaml (100%) rename {k8s => helm/templates}/db/pv.yaml (100%) rename {k8s => helm/templates}/db/pvc.yaml (100%) rename {k8s => helm/templates}/db/service.yaml (100%) delete mode 100644 helm/templates/deployment.yaml delete mode 100644 helm/templates/hpa.yaml delete mode 100644 helm/templates/ingress.yaml rename {k8s => helm/templates}/ingress/ingress.yaml (100%) delete mode 100644 helm/templates/service.yaml delete mode 100644 helm/templates/serviceaccount.yaml rename {k8s => helm/templates}/static/config.yaml (100%) rename {k8s => helm/templates}/static/deployment.yaml (100%) rename {k8s => helm/templates}/static/service.yaml (100%) delete mode 100644 helm/templates/tests/test-connection.yaml rename {k8s => helm/templates}/web/config.yaml (100%) rename {k8s => helm/templates}/web/deployment.yaml (100%) rename {k8s => helm/templates}/web/pv.yaml (100%) rename {k8s => helm/templates}/web/pvc.yaml (100%) rename {k8s => helm/templates}/web/service.yaml (100%) diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt deleted file mode 100644 index 892e8dc..0000000 --- a/helm/templates/NOTES.txt +++ /dev/null @@ -1,22 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "helm.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "helm.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "helm.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "helm.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT -{{- end }} diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl deleted file mode 100644 index ba04c30..0000000 --- a/helm/templates/_helpers.tpl +++ /dev/null @@ -1,62 +0,0 @@ -{{/* -Expand the name of the chart. -*/}} -{{- define "helm.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "helm.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "helm.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "helm.labels" -}} -helm.sh/chart: {{ include "helm.chart" . }} -{{ include "helm.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "helm.selectorLabels" -}} -app.kubernetes.io/name: {{ include "helm.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "helm.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} -{{- default (include "helm.fullname" .) .Values.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.serviceAccount.name }} -{{- end }} -{{- end }} diff --git a/k8s/db/config.yaml b/helm/templates/db/config.yaml similarity index 100% rename from k8s/db/config.yaml rename to helm/templates/db/config.yaml diff --git a/k8s/db/deployment.yaml b/helm/templates/db/deployment.yaml similarity index 100% rename from k8s/db/deployment.yaml rename to helm/templates/db/deployment.yaml diff --git a/k8s/db/pv.yaml b/helm/templates/db/pv.yaml similarity index 100% rename from k8s/db/pv.yaml rename to helm/templates/db/pv.yaml diff --git a/k8s/db/pvc.yaml b/helm/templates/db/pvc.yaml similarity index 100% rename from k8s/db/pvc.yaml rename to helm/templates/db/pvc.yaml diff --git a/k8s/db/service.yaml b/helm/templates/db/service.yaml similarity index 100% rename from k8s/db/service.yaml rename to helm/templates/db/service.yaml diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml deleted file mode 100644 index feb4b02..0000000 --- a/helm/templates/deployment.yaml +++ /dev/null @@ -1,68 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "helm.fullname" . }} - labels: - {{- include "helm.labels" . | nindent 4 }} -spec: - {{- if not .Values.autoscaling.enabled }} - replicas: {{ .Values.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- include "helm.selectorLabels" . | nindent 6 }} - template: - metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "helm.labels" . | nindent 8 }} - {{- with .Values.podLabels }} - {{- toYaml . | nindent 8 }} - {{- end }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "helm.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: {{ .Values.service.port }} - protocol: TCP - livenessProbe: - {{- toYaml .Values.livenessProbe | nindent 12 }} - readinessProbe: - {{- toYaml .Values.readinessProbe | nindent 12 }} - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.volumeMounts }} - volumeMounts: - {{- toYaml . | nindent 12 }} - {{- end }} - {{- with .Values.volumes }} - volumes: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/helm/templates/hpa.yaml b/helm/templates/hpa.yaml deleted file mode 100644 index 28c087e..0000000 --- a/helm/templates/hpa.yaml +++ /dev/null @@ -1,32 +0,0 @@ -{{- if .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ include "helm.fullname" . }} - labels: - {{- include "helm.labels" . | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ include "helm.fullname" . }} - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - - type: Resource - resource: - name: cpu - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- end }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - target: - type: Utilization - averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} -{{- end }} diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml deleted file mode 100644 index 014f7c6..0000000 --- a/helm/templates/ingress.yaml +++ /dev/null @@ -1,61 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "helm.fullname" . -}} -{{- $svcPort := .Values.service.port -}} -{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} - {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} - {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} - {{- end }} -{{- end }} -{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1 -{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1beta1 -{{- else -}} -apiVersion: extensions/v1beta1 -{{- end }} -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - {{- include "helm.labels" . | nindent 4 }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} - ingressClassName: {{ .Values.ingress.className }} - {{- end }} - {{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} - {{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ .host | quote }} - http: - paths: - {{- range .paths }} - - path: {{ .path }} - {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} - pathType: {{ .pathType }} - {{- end }} - backend: - {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} - service: - name: {{ $fullName }} - port: - number: {{ $svcPort }} - {{- else }} - serviceName: {{ $fullName }} - servicePort: {{ $svcPort }} - {{- end }} - {{- end }} - {{- end }} -{{- end }} diff --git a/k8s/ingress/ingress.yaml b/helm/templates/ingress/ingress.yaml similarity index 100% rename from k8s/ingress/ingress.yaml rename to helm/templates/ingress/ingress.yaml diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml deleted file mode 100644 index de450fc..0000000 --- a/helm/templates/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "helm.fullname" . }} - labels: - {{- include "helm.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "helm.selectorLabels" . | nindent 4 }} diff --git a/helm/templates/serviceaccount.yaml b/helm/templates/serviceaccount.yaml deleted file mode 100644 index d470465..0000000 --- a/helm/templates/serviceaccount.yaml +++ /dev/null @@ -1,13 +0,0 @@ -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "helm.serviceAccountName" . }} - labels: - {{- include "helm.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -automountServiceAccountToken: {{ .Values.serviceAccount.automount }} -{{- end }} diff --git a/k8s/static/config.yaml b/helm/templates/static/config.yaml similarity index 100% rename from k8s/static/config.yaml rename to helm/templates/static/config.yaml diff --git a/k8s/static/deployment.yaml b/helm/templates/static/deployment.yaml similarity index 100% rename from k8s/static/deployment.yaml rename to helm/templates/static/deployment.yaml diff --git a/k8s/static/service.yaml b/helm/templates/static/service.yaml similarity index 100% rename from k8s/static/service.yaml rename to helm/templates/static/service.yaml diff --git a/helm/templates/tests/test-connection.yaml b/helm/templates/tests/test-connection.yaml deleted file mode 100644 index bf1c65f..0000000 --- a/helm/templates/tests/test-connection.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "helm.fullname" . }}-test-connection" - labels: - {{- include "helm.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": test -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "helm.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never diff --git a/k8s/web/config.yaml b/helm/templates/web/config.yaml similarity index 100% rename from k8s/web/config.yaml rename to helm/templates/web/config.yaml diff --git a/k8s/web/deployment.yaml b/helm/templates/web/deployment.yaml similarity index 100% rename from k8s/web/deployment.yaml rename to helm/templates/web/deployment.yaml diff --git a/k8s/web/pv.yaml b/helm/templates/web/pv.yaml similarity index 100% rename from k8s/web/pv.yaml rename to helm/templates/web/pv.yaml diff --git a/k8s/web/pvc.yaml b/helm/templates/web/pvc.yaml similarity index 100% rename from k8s/web/pvc.yaml rename to helm/templates/web/pvc.yaml diff --git a/k8s/web/service.yaml b/helm/templates/web/service.yaml similarity index 100% rename from k8s/web/service.yaml rename to helm/templates/web/service.yaml From 1b2861abfb7c09a8e934d8322df38b306760f902 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Tue, 13 Feb 2024 13:33:29 +0400 Subject: [PATCH 07/56] Update database container image to use latest version --- helm/templates/db/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/templates/db/deployment.yaml b/helm/templates/db/deployment.yaml index 581f11d..ffa02a7 100644 --- a/helm/templates/db/deployment.yaml +++ b/helm/templates/db/deployment.yaml @@ -14,7 +14,7 @@ spec: spec: containers: - name: phrinifluent-db - image: postgres + image: postgres:latest ports: - containerPort: 5432 envFrom: From d27a80e4e0416faea7087ea134701451a817989e Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Tue, 13 Feb 2024 13:35:04 +0400 Subject: [PATCH 08/56] Initialize values helm config --- helm/values.yaml | 174 ++++++++++++++++++----------------------------- 1 file changed, 68 insertions(+), 106 deletions(-) diff --git a/helm/values.yaml b/helm/values.yaml index 0ed6db0..f9e41db 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -1,107 +1,69 @@ -# Default values for helm. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -image: - repository: nginx - pullPolicy: IfNotPresent - # Overrides the image tag whose default is the chart appVersion. - tag: "" - -imagePullSecrets: [] -nameOverride: "" -fullnameOverride: "" - -serviceAccount: - # Specifies whether a service account should be created - create: true - # Automatically mount a ServiceAccount's API credentials? - automount: true - # Annotations to add to the service account - annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template - name: "" - -podAnnotations: {} -podLabels: {} - -podSecurityContext: {} - # fsGroup: 2000 - -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 - -service: +backendConfig: + environment: production +backendDeployment: + phrinifluentBackend: + image: + repository: ghcr.io/flagro/phrinifluentbackend + tag: latest + phrinifluentBackendSetup: + args: + - | + python manage.py migrate && + python manage.py createadmin && + python manage.py collectstatic --noinput + image: + repository: ghcr.io/flagro/phrinifluentbackend + tag: latest + replicas: 1 +backendService: + ports: + - port: 80 + protocol: TCP + targetPort: 8000 type: ClusterIP - port: 80 - -ingress: - enabled: false - className: "" - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - hosts: - - host: chart-example.local - paths: - - path: / - pathType: ImplementationSpecific - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -livenessProbe: - httpGet: - path: / - port: http -readinessProbe: - httpGet: - path: / - port: http - -autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - -# Additional volumes on the output Deployment definition. -volumes: [] -# - name: foo -# secret: -# secretName: mysecret -# optional: false - -# Additional volumeMounts on the output Deployment definition. -volumeMounts: [] -# - name: foo -# mountPath: "/etc/foo" -# readOnly: true - -nodeSelector: {} - -tolerations: [] - -affinity: {} +dbConfig: + postgresHost: phrinifluent-db-service + postgresName: postgres + postgresPort: "5432" +dbDeployment: + phrinifluentDb: + image: + repository: postgres + tag: latest + replicas: 1 +dbService: + ports: + - port: 5432 + protocol: TCP + targetPort: 5432 + type: ClusterIP +kubernetesClusterDomain: cluster.local +nginxConfig: + defaultConf: |- + server { + listen 80; + server_name _; + location /static { + alias /usr/share/nginx/html/static; + } + } +nginxDeployment: + nginx: + image: + repository: nginx + tag: latest + replicas: 1 +pvc: + dbPvc: + storageClass: standard + storageRequest: 5Gi + staticPvc: + storageClass: standard + storageRequest: 2Gi +staticService: + ports: + - port: 80 + protocol: TCP + targetPort: 80 + type: ClusterIP + \ No newline at end of file From 1bcd10cc7686556b51503cab93d21340a52aec59 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Tue, 13 Feb 2024 13:46:43 +0400 Subject: [PATCH 09/56] Remove empty line at end of file in values.yaml --- helm/values.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/helm/values.yaml b/helm/values.yaml index f9e41db..93c7188 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -66,4 +66,3 @@ staticService: protocol: TCP targetPort: 80 type: ClusterIP - \ No newline at end of file From 3e7e4504d2103296d3444416b6e9638d86102df5 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Tue, 13 Feb 2024 13:53:31 +0400 Subject: [PATCH 10/56] Flatten the helm templates --- helm/templates/{db/config.yaml => db_config.yaml} | 0 helm/templates/{db/deployment.yaml => db_deployment.yaml} | 0 helm/templates/{db/pv.yaml => db_pv.yaml} | 0 helm/templates/{db/pvc.yaml => db_pvc.yaml} | 0 helm/templates/{db/service.yaml => db_service.yaml} | 0 helm/templates/{ingress => }/ingress.yaml | 0 helm/templates/{static/config.yaml => static_config.yaml} | 0 helm/templates/{static/deployment.yaml => static_deployment.yaml} | 0 helm/templates/{static/service.yaml => static_service.yaml} | 0 helm/templates/{web/config.yaml => web_config.yaml} | 0 helm/templates/{web/deployment.yaml => web_deployment.yaml} | 0 helm/templates/{web/pv.yaml => web_pv.yaml} | 0 helm/templates/{web/pvc.yaml => web_pvc.yaml} | 0 helm/templates/{web/service.yaml => web_service.yaml} | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename helm/templates/{db/config.yaml => db_config.yaml} (100%) rename helm/templates/{db/deployment.yaml => db_deployment.yaml} (100%) rename helm/templates/{db/pv.yaml => db_pv.yaml} (100%) rename helm/templates/{db/pvc.yaml => db_pvc.yaml} (100%) rename helm/templates/{db/service.yaml => db_service.yaml} (100%) rename helm/templates/{ingress => }/ingress.yaml (100%) rename helm/templates/{static/config.yaml => static_config.yaml} (100%) rename helm/templates/{static/deployment.yaml => static_deployment.yaml} (100%) rename helm/templates/{static/service.yaml => static_service.yaml} (100%) rename helm/templates/{web/config.yaml => web_config.yaml} (100%) rename helm/templates/{web/deployment.yaml => web_deployment.yaml} (100%) rename helm/templates/{web/pv.yaml => web_pv.yaml} (100%) rename helm/templates/{web/pvc.yaml => web_pvc.yaml} (100%) rename helm/templates/{web/service.yaml => web_service.yaml} (100%) diff --git a/helm/templates/db/config.yaml b/helm/templates/db_config.yaml similarity index 100% rename from helm/templates/db/config.yaml rename to helm/templates/db_config.yaml diff --git a/helm/templates/db/deployment.yaml b/helm/templates/db_deployment.yaml similarity index 100% rename from helm/templates/db/deployment.yaml rename to helm/templates/db_deployment.yaml diff --git a/helm/templates/db/pv.yaml b/helm/templates/db_pv.yaml similarity index 100% rename from helm/templates/db/pv.yaml rename to helm/templates/db_pv.yaml diff --git a/helm/templates/db/pvc.yaml b/helm/templates/db_pvc.yaml similarity index 100% rename from helm/templates/db/pvc.yaml rename to helm/templates/db_pvc.yaml diff --git a/helm/templates/db/service.yaml b/helm/templates/db_service.yaml similarity index 100% rename from helm/templates/db/service.yaml rename to helm/templates/db_service.yaml diff --git a/helm/templates/ingress/ingress.yaml b/helm/templates/ingress.yaml similarity index 100% rename from helm/templates/ingress/ingress.yaml rename to helm/templates/ingress.yaml diff --git a/helm/templates/static/config.yaml b/helm/templates/static_config.yaml similarity index 100% rename from helm/templates/static/config.yaml rename to helm/templates/static_config.yaml diff --git a/helm/templates/static/deployment.yaml b/helm/templates/static_deployment.yaml similarity index 100% rename from helm/templates/static/deployment.yaml rename to helm/templates/static_deployment.yaml diff --git a/helm/templates/static/service.yaml b/helm/templates/static_service.yaml similarity index 100% rename from helm/templates/static/service.yaml rename to helm/templates/static_service.yaml diff --git a/helm/templates/web/config.yaml b/helm/templates/web_config.yaml similarity index 100% rename from helm/templates/web/config.yaml rename to helm/templates/web_config.yaml diff --git a/helm/templates/web/deployment.yaml b/helm/templates/web_deployment.yaml similarity index 100% rename from helm/templates/web/deployment.yaml rename to helm/templates/web_deployment.yaml diff --git a/helm/templates/web/pv.yaml b/helm/templates/web_pv.yaml similarity index 100% rename from helm/templates/web/pv.yaml rename to helm/templates/web_pv.yaml diff --git a/helm/templates/web/pvc.yaml b/helm/templates/web_pvc.yaml similarity index 100% rename from helm/templates/web/pvc.yaml rename to helm/templates/web_pvc.yaml diff --git a/helm/templates/web/service.yaml b/helm/templates/web_service.yaml similarity index 100% rename from helm/templates/web/service.yaml rename to helm/templates/web_service.yaml From b510ea7e7b8338b510a2993a5c5756f684366f73 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Tue, 13 Feb 2024 14:01:39 +0400 Subject: [PATCH 11/56] Helmify yaml templates --- helm/templates/_helpers.tpl | 62 +++++++++++++++++ helm/templates/db_config.yaml | 10 +-- helm/templates/db_deployment.yaml | 43 +++++++----- helm/templates/db_pv.yaml | 12 ++-- helm/templates/db_pvc.yaml | 10 +-- helm/templates/db_service.yaml | 10 +-- helm/templates/ingress.yaml | 44 ++++++------ helm/templates/static_config.yaml | 14 ++-- helm/templates/static_deployment.yaml | 45 ++++++++----- helm/templates/static_service.yaml | 10 +-- helm/templates/web_config.yaml | 6 +- helm/templates/web_deployment.yaml | 96 +++++++++++++++------------ helm/templates/web_pv.yaml | 12 ++-- helm/templates/web_pvc.yaml | 10 +-- helm/templates/web_service.yaml | 10 +-- 15 files changed, 251 insertions(+), 143 deletions(-) create mode 100644 helm/templates/_helpers.tpl diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl new file mode 100644 index 0000000..f57eb03 --- /dev/null +++ b/helm/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "flatchart.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "flatchart.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "flatchart.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "flatchart.labels" -}} +helm.sh/chart: {{ include "flatchart.chart" . }} +{{ include "flatchart.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "flatchart.selectorLabels" -}} +app.kubernetes.io/name: {{ include "flatchart.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "flatchart.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "flatchart.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm/templates/db_config.yaml b/helm/templates/db_config.yaml index b183415..d458dc0 100644 --- a/helm/templates/db_config.yaml +++ b/helm/templates/db_config.yaml @@ -1,8 +1,10 @@ apiVersion: v1 kind: ConfigMap metadata: - name: phrinifluent-db-config + name: {{ include "flatchart.fullname" . }}-db-config + labels: + {{- include "flatchart.labels" . | nindent 4 }} data: - POSTGRES_NAME: "postgres" - POSTGRES_HOST: "phrinifluent-db-service" - POSTGRES_PORT: "5432" + POSTGRES_HOST: {{ .Values.dbConfig.postgresHost | quote }} + POSTGRES_NAME: {{ .Values.dbConfig.postgresName | quote }} + POSTGRES_PORT: {{ .Values.dbConfig.postgresPort | quote }} diff --git a/helm/templates/db_deployment.yaml b/helm/templates/db_deployment.yaml index ffa02a7..793ebca 100644 --- a/helm/templates/db_deployment.yaml +++ b/helm/templates/db_deployment.yaml @@ -1,31 +1,40 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: phrinifluent-db-deployment + name: {{ include "flatchart.fullname" . }}-db-deployment + labels: + {{- include "flatchart.labels" . | nindent 4 }} spec: - replicas: 1 + replicas: {{ .Values.dbDeployment.replicas }} selector: matchLabels: app: phrinifluent-db + {{- include "flatchart.selectorLabels" . | nindent 6 }} template: metadata: labels: app: phrinifluent-db + {{- include "flatchart.selectorLabels" . | nindent 8 }} spec: containers: - - name: phrinifluent-db - image: postgres:latest - ports: - - containerPort: 5432 - envFrom: - - secretRef: - name: phrinifluent-db-secrets - - configMapRef: - name: phrinifluent-db-config - volumeMounts: - - name: phrinifluent-db-storage - mountPath: /var/lib/postgresql/data + - env: + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + envFrom: + - secretRef: + name: phrinifluent-db-secrets + - configMapRef: + name: {{ include "flatchart.fullname" . }}-db-config + image: {{ .Values.dbDeployment.phrinifluentDb.image.repository }}:{{ .Values.dbDeployment.phrinifluentDb.image.tag + | default .Chart.AppVersion }} + name: phrinifluent-db + ports: + - containerPort: 5432 + resources: {} + volumeMounts: + - mountPath: /var/lib/postgresql/data + name: phrinifluent-db-storage volumes: - - name: phrinifluent-db-storage - persistentVolumeClaim: - claimName: phrinifluent-db-pvc + - name: phrinifluent-db-storage + persistentVolumeClaim: + claimName: {{ include "flatchart.fullname" . }}-db-pvc diff --git a/helm/templates/db_pv.yaml b/helm/templates/db_pv.yaml index d94339b..5c77b54 100644 --- a/helm/templates/db_pv.yaml +++ b/helm/templates/db_pv.yaml @@ -1,13 +1,15 @@ apiVersion: v1 kind: PersistentVolume metadata: - name: phrinifluent-db-pv + name: {{ include "flatchart.fullname" . }}-db-pv + labels: + {{- include "flatchart.labels" . | nindent 4 }} spec: + accessModes: + - ReadWriteOnce capacity: storage: 5Gi - accessModes: - - ReadWriteOnce + hostPath: + path: /var/lib/docker/volumes/phrinifluent-db-pv/_data persistentVolumeReclaimPolicy: Retain storageClassName: standard - hostPath: - path: "/var/lib/docker/volumes/phrinifluent-db-pv/_data" diff --git a/helm/templates/db_pvc.yaml b/helm/templates/db_pvc.yaml index d68d860..de02acb 100644 --- a/helm/templates/db_pvc.yaml +++ b/helm/templates/db_pvc.yaml @@ -1,11 +1,13 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: phrinifluent-db-pvc + name: {{ include "flatchart.fullname" . }}-db-pvc + labels: + {{- include "flatchart.labels" . | nindent 4 }} spec: accessModes: - - ReadWriteOnce + - ReadWriteOnce resources: requests: - storage: 5Gi - storageClassName: standard + storage: {{ .Values.pvc.dbPvc.storageRequest | quote }} + storageClassName: {{ .Values.pvc.dbPvc.storageClass | quote }} diff --git a/helm/templates/db_service.yaml b/helm/templates/db_service.yaml index 8d750e2..b1c2fac 100644 --- a/helm/templates/db_service.yaml +++ b/helm/templates/db_service.yaml @@ -1,11 +1,13 @@ apiVersion: v1 kind: Service metadata: - name: phrinifluent-db-service + name: {{ include "flatchart.fullname" . }}-db-service + labels: + {{- include "flatchart.labels" . | nindent 4 }} spec: + type: {{ .Values.dbService.type }} selector: app: phrinifluent-db + {{- include "flatchart.selectorLabels" . | nindent 4 }} ports: - - protocol: TCP - port: 5432 - targetPort: 5432 + {{- .Values.dbService.ports | toYaml | nindent 2 -}} diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml index 848763b..5169ece 100644 --- a/helm/templates/ingress.yaml +++ b/helm/templates/ingress.yaml @@ -1,27 +1,29 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: phrinifluent-ingress + name: {{ include "flatchart.fullname" . }}-ingress + labels: + {{- include "flatchart.labels" . | nindent 4 }} spec: rules: - - host: api.phrinifluent.com - http: - paths: - - path: /static - pathType: Prefix - backend: - service: - name: phrinifluent-static-service - port: - number: 80 - - path: / - pathType: Prefix - backend: - service: - name: phrinifluent-backend-service - port: - number: 80 + - host: api.phrinifluent.com + http: + paths: + - backend: + service: + name: '{{ include "flatchart.fullname" . }}-static-service' + port: + number: 80 + path: /static + pathType: Prefix + - backend: + service: + name: '{{ include "flatchart.fullname" . }}-backend-service' + port: + number: 80 + path: / + pathType: Prefix tls: - - hosts: - - api.phrinifluent.com - secretName: phrinifluent-tls-secrets + - hosts: + - api.phrinifluent.com + secretName: phrinifluent-tls-secrets diff --git a/helm/templates/static_config.yaml b/helm/templates/static_config.yaml index ff31b66..49a8751 100644 --- a/helm/templates/static_config.yaml +++ b/helm/templates/static_config.yaml @@ -1,14 +1,8 @@ apiVersion: v1 kind: ConfigMap metadata: - name: phrinifluent-nginx-config + name: {{ include "flatchart.fullname" . }}-nginx-config + labels: + {{- include "flatchart.labels" . | nindent 4 }} data: - default.conf: | - server { - listen 80; - server_name _; - - location /static { - alias /usr/share/nginx/html/static; - } - } + default.conf: {{ .Values.nginxConfig.defaultConf | toYaml | indent 1 }} diff --git a/helm/templates/static_deployment.yaml b/helm/templates/static_deployment.yaml index bad941a..cb35c27 100644 --- a/helm/templates/static_deployment.yaml +++ b/helm/templates/static_deployment.yaml @@ -1,32 +1,41 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: phrinifluent-nginx-deployment + name: {{ include "flatchart.fullname" . }}-nginx-deployment + labels: + {{- include "flatchart.labels" . | nindent 4 }} spec: - replicas: 1 + replicas: {{ .Values.nginxDeployment.replicas }} selector: matchLabels: app: nginx + {{- include "flatchart.selectorLabels" . | nindent 6 }} template: metadata: labels: app: nginx + {{- include "flatchart.selectorLabels" . | nindent 8 }} spec: containers: - - name: nginx - image: nginx:latest - ports: - - containerPort: 80 - volumeMounts: - - name: phrinifluent-static-storage - mountPath: /usr/share/nginx/html/static - - name: phrinifluent-nginx-config-storage - mountPath: /etc/nginx/conf.d - readOnly: true + - env: + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + image: {{ .Values.nginxDeployment.nginx.image.repository }}:{{ .Values.nginxDeployment.nginx.image.tag + | default .Chart.AppVersion }} + name: nginx + ports: + - containerPort: 80 + resources: {} + volumeMounts: + - mountPath: /usr/share/nginx/html/static + name: phrinifluent-static-storage + - mountPath: /etc/nginx/conf.d + name: phrinifluent-nginx-config-storage + readOnly: true volumes: - - name: phrinifluent-static-storage - persistentVolumeClaim: - claimName: phrinifluent-static-pvc - - name: phrinifluent-nginx-config-storage - configMap: - name: phrinifluent-nginx-config + - name: phrinifluent-static-storage + persistentVolumeClaim: + claimName: {{ include "flatchart.fullname" . }}-static-pvc + - configMap: + name: {{ include "flatchart.fullname" . }}-nginx-config + name: phrinifluent-nginx-config-storage diff --git a/helm/templates/static_service.yaml b/helm/templates/static_service.yaml index ff34acd..651b43d 100644 --- a/helm/templates/static_service.yaml +++ b/helm/templates/static_service.yaml @@ -1,11 +1,13 @@ apiVersion: v1 kind: Service metadata: - name: phrinifluent-static-service + name: {{ include "flatchart.fullname" . }}-static-service + labels: + {{- include "flatchart.labels" . | nindent 4 }} spec: + type: {{ .Values.staticService.type }} selector: app: nginx + {{- include "flatchart.selectorLabels" . | nindent 4 }} ports: - - protocol: TCP - port: 80 - targetPort: 80 + {{- .Values.staticService.ports | toYaml | nindent 2 -}} diff --git a/helm/templates/web_config.yaml b/helm/templates/web_config.yaml index 037ee9a..32110c4 100644 --- a/helm/templates/web_config.yaml +++ b/helm/templates/web_config.yaml @@ -1,6 +1,8 @@ apiVersion: v1 kind: ConfigMap metadata: - name: phrinifluent-backend-config + name: {{ include "flatchart.fullname" . }}-backend-config + labels: + {{- include "flatchart.labels" . | nindent 4 }} data: - ENVIRONMENT: "production" + ENVIRONMENT: {{ .Values.backendConfig.environment | quote }} diff --git a/helm/templates/web_deployment.yaml b/helm/templates/web_deployment.yaml index c8dcb50..892d20b 100644 --- a/helm/templates/web_deployment.yaml +++ b/helm/templates/web_deployment.yaml @@ -1,54 +1,68 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: phrinifluent-backend-deployment + name: {{ include "flatchart.fullname" . }}-backend-deployment + labels: + {{- include "flatchart.labels" . | nindent 4 }} spec: - replicas: 1 + replicas: {{ .Values.backendDeployment.replicas }} selector: matchLabels: app: phrinifluent-backend + {{- include "flatchart.selectorLabels" . | nindent 6 }} template: metadata: labels: app: phrinifluent-backend + {{- include "flatchart.selectorLabels" . | nindent 8 }} spec: - volumes: - - name: phrinifluent-static-storage - persistentVolumeClaim: - claimName: phrinifluent-static-pvc - initContainers: - - name: phrinifluent-backend-setup - image: ghcr.io/flagro/phrinifluentbackend:latest - command: ["/bin/sh", "-c"] - args: - - | - python manage.py migrate && - python manage.py createadmin && - python manage.py collectstatic --noinput - envFrom: - - secretRef: - name: phrinifluent-backend-secrets - - secretRef: - name: phrinifluent-db-secrets - - configMapRef: - name: phrinifluent-backend-config - - configMapRef: - name: phrinifluent-db-config - volumeMounts: - - name: phrinifluent-static-storage - mountPath: /app/staticfiles/ - containers: - - name: phrinifluent-backend - image: ghcr.io/flagro/phrinifluentbackend:latest - ports: - - containerPort: 8000 - envFrom: - - secretRef: - name: phrinifluent-backend-secrets - - secretRef: - name: phrinifluent-db-secrets - - configMapRef: - name: phrinifluent-backend-config - - configMapRef: - name: phrinifluent-db-config + - env: + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + envFrom: + - secretRef: + name: phrinifluent-backend-secrets + - secretRef: + name: phrinifluent-db-secrets + - configMapRef: + name: {{ include "flatchart.fullname" . }}-backend-config + - configMapRef: + name: {{ include "flatchart.fullname" . }}-db-config + image: {{ .Values.backendDeployment.phrinifluentBackend.image.repository }}:{{ + .Values.backendDeployment.phrinifluentBackend.image.tag | default .Chart.AppVersion + }} + name: phrinifluent-backend + ports: + - containerPort: 8000 + resources: {} + initContainers: + - args: {{- toYaml .Values.backendDeployment.phrinifluentBackendSetup.args | nindent + 8 }} + command: + - /bin/sh + - -c + env: + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + envFrom: + - secretRef: + name: phrinifluent-backend-secrets + - secretRef: + name: phrinifluent-db-secrets + - configMapRef: + name: {{ include "flatchart.fullname" . }}-backend-config + - configMapRef: + name: {{ include "flatchart.fullname" . }}-db-config + image: {{ .Values.backendDeployment.phrinifluentBackendSetup.image.repository }}:{{ + .Values.backendDeployment.phrinifluentBackendSetup.image.tag | default .Chart.AppVersion + }} + name: phrinifluent-backend-setup + resources: {} + volumeMounts: + - mountPath: /app/staticfiles/ + name: phrinifluent-static-storage + volumes: + - name: phrinifluent-static-storage + persistentVolumeClaim: + claimName: {{ include "flatchart.fullname" . }}-static-pvc diff --git a/helm/templates/web_pv.yaml b/helm/templates/web_pv.yaml index 1e21953..7b70203 100644 --- a/helm/templates/web_pv.yaml +++ b/helm/templates/web_pv.yaml @@ -1,13 +1,15 @@ apiVersion: v1 kind: PersistentVolume metadata: - name: phrinifluent-static-pv + name: {{ include "flatchart.fullname" . }}-static-pv + labels: + {{- include "flatchart.labels" . | nindent 4 }} spec: + accessModes: + - ReadWriteMany capacity: storage: 2Gi - accessModes: - - ReadWriteMany + hostPath: + path: /var/lib/docker/volumes/phrinifluent-static-pv/_data persistentVolumeReclaimPolicy: Retain storageClassName: standard - hostPath: - path: "/var/lib/docker/volumes/phrinifluent-static-pv/_data" diff --git a/helm/templates/web_pvc.yaml b/helm/templates/web_pvc.yaml index 5f0273d..3db7485 100644 --- a/helm/templates/web_pvc.yaml +++ b/helm/templates/web_pvc.yaml @@ -1,11 +1,13 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: phrinifluent-static-pvc + name: {{ include "flatchart.fullname" . }}-static-pvc + labels: + {{- include "flatchart.labels" . | nindent 4 }} spec: accessModes: - - ReadWriteMany + - ReadWriteMany resources: requests: - storage: 2Gi - storageClassName: standard + storage: {{ .Values.pvc.staticPvc.storageRequest | quote }} + storageClassName: {{ .Values.pvc.staticPvc.storageClass | quote }} diff --git a/helm/templates/web_service.yaml b/helm/templates/web_service.yaml index 7d43de0..7681249 100644 --- a/helm/templates/web_service.yaml +++ b/helm/templates/web_service.yaml @@ -1,11 +1,13 @@ apiVersion: v1 kind: Service metadata: - name: phrinifluent-backend-service + name: {{ include "flatchart.fullname" . }}-backend-service + labels: + {{- include "flatchart.labels" . | nindent 4 }} spec: + type: {{ .Values.backendService.type }} selector: app: phrinifluent-backend + {{- include "flatchart.selectorLabels" . | nindent 4 }} ports: - - protocol: TCP - port: 80 - targetPort: 8000 + {{- .Values.backendService.ports | toYaml | nindent 2 -}} From 9cebb8e33a13feda0aa6fcdea00d4258ca6f59e2 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Thu, 15 Feb 2024 13:22:15 +0400 Subject: [PATCH 12/56] Add Dmitry Trofumushkin as a copyright holder in LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 88c866e..2899c89 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Anton Potapov +Copyright (c) 2023 Anton Potapov and Dmitry Trofumushkin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 6719b700bd27a1033c14a71c9f50d71fe2cb1d3b Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 19:58:22 +0100 Subject: [PATCH 13/56] Fix order in db config --- helm/templates/db_config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/templates/db_config.yaml b/helm/templates/db_config.yaml index d458dc0..71e87a9 100644 --- a/helm/templates/db_config.yaml +++ b/helm/templates/db_config.yaml @@ -5,6 +5,6 @@ metadata: labels: {{- include "flatchart.labels" . | nindent 4 }} data: - POSTGRES_HOST: {{ .Values.dbConfig.postgresHost | quote }} POSTGRES_NAME: {{ .Values.dbConfig.postgresName | quote }} + POSTGRES_HOST: {{ .Values.dbConfig.postgresHost | quote }} POSTGRES_PORT: {{ .Values.dbConfig.postgresPort | quote }} From c1f70c7420643c33f0687ca8ae92d5cc6ad8bd88 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 19:58:43 +0100 Subject: [PATCH 14/56] Add .yamllint configuration file --- .yamllint | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .yamllint diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..c1cf40a --- /dev/null +++ b/.yamllint @@ -0,0 +1,8 @@ +extends: default + +rules: + document-start: + present: false + braces: + max-spaces-inside: 1 + level: warning From f714dc801c41c9922552a6cf8c7ebe847a0ece47 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:00:22 +0100 Subject: [PATCH 15/56] Fix order and indents in db deployment --- helm/templates/db_deployment.yaml | 39 +++++++++++++++---------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/helm/templates/db_deployment.yaml b/helm/templates/db_deployment.yaml index 793ebca..e0615e2 100644 --- a/helm/templates/db_deployment.yaml +++ b/helm/templates/db_deployment.yaml @@ -17,24 +17,23 @@ spec: {{- include "flatchart.selectorLabels" . | nindent 8 }} spec: containers: - - env: - - name: KUBERNETES_CLUSTER_DOMAIN - value: {{ quote .Values.kubernetesClusterDomain }} - envFrom: - - secretRef: - name: phrinifluent-db-secrets - - configMapRef: - name: {{ include "flatchart.fullname" . }}-db-config - image: {{ .Values.dbDeployment.phrinifluentDb.image.repository }}:{{ .Values.dbDeployment.phrinifluentDb.image.tag - | default .Chart.AppVersion }} - name: phrinifluent-db - ports: - - containerPort: 5432 - resources: {} - volumeMounts: - - mountPath: /var/lib/postgresql/data - name: phrinifluent-db-storage + - name: phrinifluent-db + image: {{ .Values.dbDeployment.phrinifluentDb.image.repository }}:{{ .Values.dbDeployment.phrinifluentDb.image.tag | default .Chart.AppVersion }} + ports: + - containerPort: 5432 + envFrom: + - secretRef: + name: phrinifluent-db-secrets + - configMapRef: + name: {{ include "flatchart.fullname" . }}-db-config + - env: + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + resources: {} + volumeMounts: + - mountPath: /var/lib/postgresql/data + name: phrinifluent-db-storage volumes: - - name: phrinifluent-db-storage - persistentVolumeClaim: - claimName: {{ include "flatchart.fullname" . }}-db-pvc + - name: phrinifluent-db-storage + persistentVolumeClaim: + claimName: {{ include "flatchart.fullname" . }}-db-pvc From 729381cc0164e4dbcb65fb035a55579a416ff852 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:01:40 +0100 Subject: [PATCH 16/56] Fix order in db_deployment --- helm/templates/db_deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/templates/db_deployment.yaml b/helm/templates/db_deployment.yaml index e0615e2..e88357c 100644 --- a/helm/templates/db_deployment.yaml +++ b/helm/templates/db_deployment.yaml @@ -31,8 +31,8 @@ spec: value: {{ quote .Values.kubernetesClusterDomain }} resources: {} volumeMounts: - - mountPath: /var/lib/postgresql/data - name: phrinifluent-db-storage + - name: phrinifluent-db-storage + mountPath: /var/lib/postgresql/data volumes: - name: phrinifluent-db-storage persistentVolumeClaim: From a992c700e095d8b0fcfd7ff7593ad034aa0c72ce Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:04:26 +0100 Subject: [PATCH 17/56] Fix indentations --- helm/templates/db_deployment.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helm/templates/db_deployment.yaml b/helm/templates/db_deployment.yaml index e88357c..e89f789 100644 --- a/helm/templates/db_deployment.yaml +++ b/helm/templates/db_deployment.yaml @@ -3,18 +3,18 @@ kind: Deployment metadata: name: {{ include "flatchart.fullname" . }}-db-deployment labels: - {{- include "flatchart.labels" . | nindent 4 }} + {{- include "flatchart.labels" . | nindent 4 }} spec: replicas: {{ .Values.dbDeployment.replicas }} selector: matchLabels: app: phrinifluent-db - {{- include "flatchart.selectorLabels" . | nindent 6 }} + {{- include "flatchart.selectorLabels" . | nindent 6 }} template: metadata: labels: app: phrinifluent-db - {{- include "flatchart.selectorLabels" . | nindent 8 }} + {{- include "flatchart.selectorLabels" . | nindent 8 }} spec: containers: - name: phrinifluent-db From 19e2f89bfa963d9a5819408d86dc40e455107223 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:06:15 +0100 Subject: [PATCH 18/56] Fix identations and order in db_pv --- helm/templates/db_pv.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/helm/templates/db_pv.yaml b/helm/templates/db_pv.yaml index 5c77b54..1b0f6b0 100644 --- a/helm/templates/db_pv.yaml +++ b/helm/templates/db_pv.yaml @@ -3,13 +3,13 @@ kind: PersistentVolume metadata: name: {{ include "flatchart.fullname" . }}-db-pv labels: - {{- include "flatchart.labels" . | nindent 4 }} + {{- include "flatchart.labels" . | nindent 4 }} spec: - accessModes: - - ReadWriteOnce capacity: storage: 5Gi - hostPath: - path: /var/lib/docker/volumes/phrinifluent-db-pv/_data + accessModes: + - ReadWriteOnce persistentVolumeReclaimPolicy: Retain storageClassName: standard + hostPath: + path: /var/lib/docker/volumes/phrinifluent-db-pv/_data From b73e18fc4ede9079cf1301f6844ac922a688c1ad Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:07:31 +0100 Subject: [PATCH 19/56] Fix order and indents in db_pvc --- helm/templates/db_pvc.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/templates/db_pvc.yaml b/helm/templates/db_pvc.yaml index de02acb..0961a5d 100644 --- a/helm/templates/db_pvc.yaml +++ b/helm/templates/db_pvc.yaml @@ -3,10 +3,10 @@ kind: PersistentVolumeClaim metadata: name: {{ include "flatchart.fullname" . }}-db-pvc labels: - {{- include "flatchart.labels" . | nindent 4 }} + {{- include "flatchart.labels" . | nindent 4 }} spec: accessModes: - - ReadWriteOnce + - ReadWriteOnce resources: requests: storage: {{ .Values.pvc.dbPvc.storageRequest | quote }} From 5adf6b5661f40751f427472824331b400765b65e Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:10:37 +0100 Subject: [PATCH 20/56] Fix indentation in db_service.yaml --- helm/templates/db_service.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helm/templates/db_service.yaml b/helm/templates/db_service.yaml index b1c2fac..0198ab4 100644 --- a/helm/templates/db_service.yaml +++ b/helm/templates/db_service.yaml @@ -3,11 +3,11 @@ kind: Service metadata: name: {{ include "flatchart.fullname" . }}-db-service labels: - {{- include "flatchart.labels" . | nindent 4 }} + {{- include "flatchart.labels" . | nindent 4 }} spec: type: {{ .Values.dbService.type }} selector: app: phrinifluent-db - {{- include "flatchart.selectorLabels" . | nindent 4 }} + {{- include "flatchart.selectorLabels" . | nindent 4 }} ports: - {{- .Values.dbService.ports | toYaml | nindent 2 -}} + {{- .Values.dbService.ports | toYaml | nindent 2 -}} From ac46d23e88aa43405c87dd3cd0797db040708b74 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:13:58 +0100 Subject: [PATCH 21/56] Refactor ingress.yaml to update paths and add TLS configuration --- helm/templates/ingress.yaml | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml index 5169ece..745e282 100644 --- a/helm/templates/ingress.yaml +++ b/helm/templates/ingress.yaml @@ -3,27 +3,27 @@ kind: Ingress metadata: name: {{ include "flatchart.fullname" . }}-ingress labels: - {{- include "flatchart.labels" . | nindent 4 }} + {{- include "flatchart.labels" . | nindent 4 }} spec: rules: - - host: api.phrinifluent.com - http: - paths: - - backend: - service: - name: '{{ include "flatchart.fullname" . }}-static-service' - port: - number: 80 - path: /static - pathType: Prefix - - backend: - service: - name: '{{ include "flatchart.fullname" . }}-backend-service' - port: - number: 80 - path: / - pathType: Prefix + - host: api.phrinifluent.com + http: + paths: + - path: /static + pathType: Prefix + backend: + service: + name: '{{ include "flatchart.fullname" . }}-static-service' + port: + number: 80 + - path: / + pathType: Prefix + backend: + service: + name: '{{ include "flatchart.fullname" . }}-backend-service' + port: + number: 80 tls: - - hosts: - - api.phrinifluent.com - secretName: phrinifluent-tls-secrets + - hosts: + - api.phrinifluent.com + secretName: phrinifluent-tls-secrets From bf042211d3da4d35169e4202de510bae8976ad0e Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:14:36 +0100 Subject: [PATCH 22/56] Fix indentation in static_config.yaml --- helm/templates/static_config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/templates/static_config.yaml b/helm/templates/static_config.yaml index 49a8751..d80b9f7 100644 --- a/helm/templates/static_config.yaml +++ b/helm/templates/static_config.yaml @@ -3,6 +3,6 @@ kind: ConfigMap metadata: name: {{ include "flatchart.fullname" . }}-nginx-config labels: - {{- include "flatchart.labels" . | nindent 4 }} + {{- include "flatchart.labels" . | nindent 4 }} data: default.conf: {{ .Values.nginxConfig.defaultConf | toYaml | indent 1 }} From 2aa3c7a6e6c974a8b32d3c0dc9d48fb63ff0b578 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:19:23 +0100 Subject: [PATCH 23/56] Refactor static_deployment.yaml file --- helm/templates/static_deployment.yaml | 47 +++++++++++++-------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/helm/templates/static_deployment.yaml b/helm/templates/static_deployment.yaml index cb35c27..8a6716d 100644 --- a/helm/templates/static_deployment.yaml +++ b/helm/templates/static_deployment.yaml @@ -3,39 +3,38 @@ kind: Deployment metadata: name: {{ include "flatchart.fullname" . }}-nginx-deployment labels: - {{- include "flatchart.labels" . | nindent 4 }} + {{- include "flatchart.labels" . | nindent 4 }} spec: replicas: {{ .Values.nginxDeployment.replicas }} selector: matchLabels: app: nginx - {{- include "flatchart.selectorLabels" . | nindent 6 }} + {{- include "flatchart.selectorLabels" . | nindent 6 }} template: metadata: labels: app: nginx - {{- include "flatchart.selectorLabels" . | nindent 8 }} + {{- include "flatchart.selectorLabels" . | nindent 8 }} spec: containers: - - env: - - name: KUBERNETES_CLUSTER_DOMAIN - value: {{ quote .Values.kubernetesClusterDomain }} - image: {{ .Values.nginxDeployment.nginx.image.repository }}:{{ .Values.nginxDeployment.nginx.image.tag - | default .Chart.AppVersion }} - name: nginx - ports: - - containerPort: 80 - resources: {} - volumeMounts: - - mountPath: /usr/share/nginx/html/static - name: phrinifluent-static-storage - - mountPath: /etc/nginx/conf.d - name: phrinifluent-nginx-config-storage - readOnly: true + - name: nginx + image: {{ .Values.nginxDeployment.nginx.image.repository }}:{{ .Values.nginxDeployment.nginx.image.tag | default .Chart.AppVersion }} + ports: + - containerPort: 80 + env: + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + resources: {} + volumeMounts: + - name: phrinifluent-static-storage + mountPath: /usr/share/nginx/html/static + - name: phrinifluent-nginx-config-storage + mountPath: /etc/nginx/conf.d + readOnly: true volumes: - - name: phrinifluent-static-storage - persistentVolumeClaim: - claimName: {{ include "flatchart.fullname" . }}-static-pvc - - configMap: - name: {{ include "flatchart.fullname" . }}-nginx-config - name: phrinifluent-nginx-config-storage + - name: phrinifluent-static-storage + persistentVolumeClaim: + claimName: {{ include "flatchart.fullname" . }}-static-pvc + - name: phrinifluent-nginx-config-storage + configMap: + name: {{ include "flatchart.fullname" . }}-nginx-config From 03e7f9b42c9587d3e7860c2348ea92b205d32be0 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:20:18 +0100 Subject: [PATCH 24/56] Fix indentation in static_service.yaml --- helm/templates/static_service.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helm/templates/static_service.yaml b/helm/templates/static_service.yaml index 651b43d..afb0e79 100644 --- a/helm/templates/static_service.yaml +++ b/helm/templates/static_service.yaml @@ -3,11 +3,11 @@ kind: Service metadata: name: {{ include "flatchart.fullname" . }}-static-service labels: - {{- include "flatchart.labels" . | nindent 4 }} + {{- include "flatchart.labels" . | nindent 4 }} spec: type: {{ .Values.staticService.type }} selector: app: nginx - {{- include "flatchart.selectorLabels" . | nindent 4 }} + {{- include "flatchart.selectorLabels" . | nindent 4 }} ports: - {{- .Values.staticService.ports | toYaml | nindent 2 -}} + {{- .Values.staticService.ports | toYaml | nindent 2 -}} From 39001f06689b9198ffdc1ea1c7b5fd88068ab044 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:20:45 +0100 Subject: [PATCH 25/56] Fix indentation in web_config.yaml --- helm/templates/web_config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/templates/web_config.yaml b/helm/templates/web_config.yaml index 32110c4..59ce39d 100644 --- a/helm/templates/web_config.yaml +++ b/helm/templates/web_config.yaml @@ -3,6 +3,6 @@ kind: ConfigMap metadata: name: {{ include "flatchart.fullname" . }}-backend-config labels: - {{- include "flatchart.labels" . | nindent 4 }} + {{- include "flatchart.labels" . | nindent 4 }} data: ENVIRONMENT: {{ .Values.backendConfig.environment | quote }} From 384a80f3e9b46813f497880a8d689b1c569b4965 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:27:42 +0100 Subject: [PATCH 26/56] Refactor web_deployment.yaml file structure --- helm/templates/web_deployment.yaml | 97 ++++++++++++++---------------- 1 file changed, 45 insertions(+), 52 deletions(-) diff --git a/helm/templates/web_deployment.yaml b/helm/templates/web_deployment.yaml index 892d20b..db0828b 100644 --- a/helm/templates/web_deployment.yaml +++ b/helm/templates/web_deployment.yaml @@ -3,66 +3,59 @@ kind: Deployment metadata: name: {{ include "flatchart.fullname" . }}-backend-deployment labels: - {{- include "flatchart.labels" . | nindent 4 }} + {{- include "flatchart.labels" . | nindent 4 }} spec: replicas: {{ .Values.backendDeployment.replicas }} selector: matchLabels: app: phrinifluent-backend - {{- include "flatchart.selectorLabels" . | nindent 6 }} + {{- include "flatchart.selectorLabels" . | nindent 6 }} template: metadata: labels: app: phrinifluent-backend - {{- include "flatchart.selectorLabels" . | nindent 8 }} + {{- include "flatchart.selectorLabels" . | nindent 8 }} spec: - containers: - - env: - - name: KUBERNETES_CLUSTER_DOMAIN - value: {{ quote .Values.kubernetesClusterDomain }} - envFrom: - - secretRef: - name: phrinifluent-backend-secrets - - secretRef: - name: phrinifluent-db-secrets - - configMapRef: - name: {{ include "flatchart.fullname" . }}-backend-config - - configMapRef: - name: {{ include "flatchart.fullname" . }}-db-config - image: {{ .Values.backendDeployment.phrinifluentBackend.image.repository }}:{{ - .Values.backendDeployment.phrinifluentBackend.image.tag | default .Chart.AppVersion - }} - name: phrinifluent-backend - ports: - - containerPort: 8000 - resources: {} - initContainers: - - args: {{- toYaml .Values.backendDeployment.phrinifluentBackendSetup.args | nindent - 8 }} - command: - - /bin/sh - - -c - env: - - name: KUBERNETES_CLUSTER_DOMAIN - value: {{ quote .Values.kubernetesClusterDomain }} - envFrom: - - secretRef: - name: phrinifluent-backend-secrets - - secretRef: - name: phrinifluent-db-secrets - - configMapRef: - name: {{ include "flatchart.fullname" . }}-backend-config - - configMapRef: - name: {{ include "flatchart.fullname" . }}-db-config - image: {{ .Values.backendDeployment.phrinifluentBackendSetup.image.repository }}:{{ - .Values.backendDeployment.phrinifluentBackendSetup.image.tag | default .Chart.AppVersion - }} - name: phrinifluent-backend-setup - resources: {} - volumeMounts: - - mountPath: /app/staticfiles/ - name: phrinifluent-static-storage volumes: - - name: phrinifluent-static-storage - persistentVolumeClaim: - claimName: {{ include "flatchart.fullname" . }}-static-pvc + - name: phrinifluent-static-storage + persistentVolumeClaim: + claimName: {{ include "flatchart.fullname" . }}-static-pvc + initContainers: + - name: phrinifluent-backend-setup + image: {{ .Values.backendDeployment.phrinifluentBackendSetup.image.repository }}:{{.Values.backendDeployment.phrinifluentBackendSetup.image.tag | default .Chart.AppVersion}} + command: ["/bin/sh", "-c"] + args: {{- toYaml .Values.backendDeployment.phrinifluentBackendSetup.args | nindent 8 }} + envFrom: + - secretRef: + name: phrinifluent-backend-secrets + - secretRef: + name: phrinifluent-db-secrets + - configMapRef: + name: {{ include "flatchart.fullname" . }}-backend-config + - configMapRef: + name: {{ include "flatchart.fullname" . }}-db-config + env: + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + resources: {} + volumeMounts: + - mountPath: /app/staticfiles/ + name: phrinifluent-static-storage + containers: + - name: phrinifluent-backend + image: {{ .Values.backendDeployment.phrinifluentBackend.image.repository }}:{{.Values.backendDeployment.phrinifluentBackend.image.tag | default .Chart.AppVersion}} + ports: + - containerPort: 8000 + envFrom: + - secretRef: + name: phrinifluent-backend-secrets + - secretRef: + name: phrinifluent-db-secrets + - configMapRef: + name: {{ include "flatchart.fullname" . }}-backend-config + - configMapRef: + name: {{ include "flatchart.fullname" . }}-db-config + env: + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + resources: {} From ab1db516db8ff91885b55aa23849daab3501b950 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:29:32 +0100 Subject: [PATCH 27/56] Fix indentation and access mode in web_pv.yaml --- helm/templates/web_pv.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/helm/templates/web_pv.yaml b/helm/templates/web_pv.yaml index 7b70203..f0e1414 100644 --- a/helm/templates/web_pv.yaml +++ b/helm/templates/web_pv.yaml @@ -3,13 +3,13 @@ kind: PersistentVolume metadata: name: {{ include "flatchart.fullname" . }}-static-pv labels: - {{- include "flatchart.labels" . | nindent 4 }} + {{- include "flatchart.labels" . | nindent 4 }} spec: - accessModes: - - ReadWriteMany capacity: storage: 2Gi - hostPath: - path: /var/lib/docker/volumes/phrinifluent-static-pv/_data + accessModes: + - ReadWriteMany persistentVolumeReclaimPolicy: Retain storageClassName: standard + hostPath: + path: /var/lib/docker/volumes/phrinifluent-static-pv/_data From 9bac0edd12e4f65e10a342bdde84c964b3abd2fa Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:30:04 +0100 Subject: [PATCH 28/56] Fix indentation in web_pvc.yaml --- helm/templates/web_pvc.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/templates/web_pvc.yaml b/helm/templates/web_pvc.yaml index 3db7485..3c681c4 100644 --- a/helm/templates/web_pvc.yaml +++ b/helm/templates/web_pvc.yaml @@ -3,10 +3,10 @@ kind: PersistentVolumeClaim metadata: name: {{ include "flatchart.fullname" . }}-static-pvc labels: - {{- include "flatchart.labels" . | nindent 4 }} + {{- include "flatchart.labels" . | nindent 4 }} spec: accessModes: - - ReadWriteMany + - ReadWriteMany resources: requests: storage: {{ .Values.pvc.staticPvc.storageRequest | quote }} From 325229040fa06cfbbf2b4518d49ecd6ba55be380 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:30:33 +0100 Subject: [PATCH 29/56] Fix indentation in web_service.yaml --- helm/templates/web_service.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helm/templates/web_service.yaml b/helm/templates/web_service.yaml index 7681249..7d25a00 100644 --- a/helm/templates/web_service.yaml +++ b/helm/templates/web_service.yaml @@ -3,11 +3,11 @@ kind: Service metadata: name: {{ include "flatchart.fullname" . }}-backend-service labels: - {{- include "flatchart.labels" . | nindent 4 }} + {{- include "flatchart.labels" . | nindent 4 }} spec: type: {{ .Values.backendService.type }} selector: app: phrinifluent-backend - {{- include "flatchart.selectorLabels" . | nindent 4 }} + {{- include "flatchart.selectorLabels" . | nindent 4 }} ports: - {{- .Values.backendService.ports | toYaml | nindent 2 -}} + {{- .Values.backendService.ports | toYaml | nindent 2 -}} From 75226eb669a78c0d87579abac26827e78794a9b9 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:31:12 +0100 Subject: [PATCH 30/56] Fix indentation in db_config.yaml --- helm/templates/db_config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/templates/db_config.yaml b/helm/templates/db_config.yaml index 71e87a9..497ce8e 100644 --- a/helm/templates/db_config.yaml +++ b/helm/templates/db_config.yaml @@ -3,7 +3,7 @@ kind: ConfigMap metadata: name: {{ include "flatchart.fullname" . }}-db-config labels: - {{- include "flatchart.labels" . | nindent 4 }} + {{- include "flatchart.labels" . | nindent 4 }} data: POSTGRES_NAME: {{ .Values.dbConfig.postgresName | quote }} POSTGRES_HOST: {{ .Values.dbConfig.postgresHost | quote }} From ca2620e3e04a908a34a8e8d5f33d9f3e819c7ca8 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:32:31 +0100 Subject: [PATCH 31/56] Update path for db_pv.yaml file --- helm/templates/db_pv.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/templates/db_pv.yaml b/helm/templates/db_pv.yaml index 1b0f6b0..733749d 100644 --- a/helm/templates/db_pv.yaml +++ b/helm/templates/db_pv.yaml @@ -12,4 +12,4 @@ spec: persistentVolumeReclaimPolicy: Retain storageClassName: standard hostPath: - path: /var/lib/docker/volumes/phrinifluent-db-pv/_data + path: "/var/lib/docker/volumes/phrinifluent-db-pv/_data" From 3fa049f52ade45a7aa39725d0505da8ecb3c5607 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:33:21 +0100 Subject: [PATCH 32/56] Refactor ingress.yaml to update paths and backend services --- helm/templates/ingress.yaml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml index 745e282..47de353 100644 --- a/helm/templates/ingress.yaml +++ b/helm/templates/ingress.yaml @@ -9,20 +9,20 @@ spec: - host: api.phrinifluent.com http: paths: - - path: /static - pathType: Prefix - backend: - service: - name: '{{ include "flatchart.fullname" . }}-static-service' - port: - number: 80 - - path: / - pathType: Prefix - backend: - service: - name: '{{ include "flatchart.fullname" . }}-backend-service' - port: - number: 80 + - path: /static + pathType: Prefix + backend: + service: + name: '{{ include "flatchart.fullname" . }}-static-service' + port: + number: 80 + - path: / + pathType: Prefix + backend: + service: + name: '{{ include "flatchart.fullname" . }}-backend-service' + port: + number: 80 tls: - hosts: - api.phrinifluent.com From a8642772f41f170f8de17bf189de5e069505e1ba Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:34:23 +0100 Subject: [PATCH 33/56] Update environment variables in web_deployment.yaml --- helm/templates/web_deployment.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/helm/templates/web_deployment.yaml b/helm/templates/web_deployment.yaml index db0828b..40f0367 100644 --- a/helm/templates/web_deployment.yaml +++ b/helm/templates/web_deployment.yaml @@ -47,14 +47,14 @@ spec: ports: - containerPort: 8000 envFrom: - - secretRef: - name: phrinifluent-backend-secrets - - secretRef: - name: phrinifluent-db-secrets - - configMapRef: - name: {{ include "flatchart.fullname" . }}-backend-config - - configMapRef: - name: {{ include "flatchart.fullname" . }}-db-config + - secretRef: + name: phrinifluent-backend-secrets + - secretRef: + name: phrinifluent-db-secrets + - configMapRef: + name: {{ include "flatchart.fullname" . }}-backend-config + - configMapRef: + name: {{ include "flatchart.fullname" . }}-db-config env: - name: KUBERNETES_CLUSTER_DOMAIN value: {{ quote .Values.kubernetesClusterDomain }} From a75d7ba384de62a018d9ed3a477cb1134e3d418d Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:35:14 +0100 Subject: [PATCH 34/56] Update path in web_pv.yaml file --- helm/templates/web_pv.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/templates/web_pv.yaml b/helm/templates/web_pv.yaml index f0e1414..67b7019 100644 --- a/helm/templates/web_pv.yaml +++ b/helm/templates/web_pv.yaml @@ -12,4 +12,4 @@ spec: persistentVolumeReclaimPolicy: Retain storageClassName: standard hostPath: - path: /var/lib/docker/volumes/phrinifluent-static-pv/_data + path: "/var/lib/docker/volumes/phrinifluent-static-pv/_data" From ecb18edbbc72d32283d8577c35421b609ffe324b Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:57:00 +0100 Subject: [PATCH 35/56] Update storage and access modes for PV and PVC --- helm/templates/db_pv.yaml | 4 ++-- helm/templates/web_pv.yaml | 4 ++-- helm/values.yaml | 7 +++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/helm/templates/db_pv.yaml b/helm/templates/db_pv.yaml index 733749d..0e85c95 100644 --- a/helm/templates/db_pv.yaml +++ b/helm/templates/db_pv.yaml @@ -6,9 +6,9 @@ metadata: {{- include "flatchart.labels" . | nindent 4 }} spec: capacity: - storage: 5Gi + storage: {{ .Values.pv.dbPv.storageRequest }} accessModes: - - ReadWriteOnce + - {{ .Values.pv.dbPv.accessModes }} persistentVolumeReclaimPolicy: Retain storageClassName: standard hostPath: diff --git a/helm/templates/web_pv.yaml b/helm/templates/web_pv.yaml index 67b7019..5bf249e 100644 --- a/helm/templates/web_pv.yaml +++ b/helm/templates/web_pv.yaml @@ -6,9 +6,9 @@ metadata: {{- include "flatchart.labels" . | nindent 4 }} spec: capacity: - storage: 2Gi + storage: {{ .Values.pvc.staticPvc.storageClass }} accessModes: - - ReadWriteMany + - {{ .Values.pvc.staticPvc.accessModes }} persistentVolumeReclaimPolicy: Retain storageClassName: standard hostPath: diff --git a/helm/values.yaml b/helm/values.yaml index 93c7188..b394e20 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -53,6 +53,13 @@ nginxDeployment: repository: nginx tag: latest replicas: 1 +pv: + dbPv: + storageRequest: 5Gi + accessModes: ReadWriteOnce + staticPv: + storageRequest: 2Gi + accessModes: ReadWriteMany pvc: dbPvc: storageClass: standard From b68c258320b6dcbd6e68e03ea0b099352b99b60d Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:03:45 +0100 Subject: [PATCH 36/56] Update hostPath in db_pv.yaml and web_pv.yaml --- helm/templates/db_pv.yaml | 2 +- helm/templates/web_pv.yaml | 6 +++--- helm/values.yaml | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/helm/templates/db_pv.yaml b/helm/templates/db_pv.yaml index 0e85c95..cfa07f6 100644 --- a/helm/templates/db_pv.yaml +++ b/helm/templates/db_pv.yaml @@ -12,4 +12,4 @@ spec: persistentVolumeReclaimPolicy: Retain storageClassName: standard hostPath: - path: "/var/lib/docker/volumes/phrinifluent-db-pv/_data" + path: {{ .Values.pv.dbPv.hostPath | quote }} diff --git a/helm/templates/web_pv.yaml b/helm/templates/web_pv.yaml index 5bf249e..4997c95 100644 --- a/helm/templates/web_pv.yaml +++ b/helm/templates/web_pv.yaml @@ -6,10 +6,10 @@ metadata: {{- include "flatchart.labels" . | nindent 4 }} spec: capacity: - storage: {{ .Values.pvc.staticPvc.storageClass }} + storage: {{ .Values.pv.staticPv.storageRequest }} accessModes: - - {{ .Values.pvc.staticPvc.accessModes }} + - {{ .Values.pv.staticPv.accessModes }} persistentVolumeReclaimPolicy: Retain storageClassName: standard hostPath: - path: "/var/lib/docker/volumes/phrinifluent-static-pv/_data" + path: {{ .Values.pv.staticPv.hostPath | quote }} diff --git a/helm/values.yaml b/helm/values.yaml index b394e20..3fdc2ce 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -57,9 +57,11 @@ pv: dbPv: storageRequest: 5Gi accessModes: ReadWriteOnce + hostPath: /var/lib/docker/volumes/phrinifluent-db-pv/_data staticPv: storageRequest: 2Gi accessModes: ReadWriteMany + hostPath: /var/lib/docker/volumes/phrinifluent-static-pv/_data pvc: dbPvc: storageClass: standard From 3c8a3b0e18179e2d348ff18305575ca8622cae00 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:09:54 +0100 Subject: [PATCH 37/56] Update storage and reclaim policies for PVs --- helm/templates/db_pv.yaml | 4 ++-- helm/templates/web_pv.yaml | 4 ++-- helm/values.yaml | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/helm/templates/db_pv.yaml b/helm/templates/db_pv.yaml index cfa07f6..69448a0 100644 --- a/helm/templates/db_pv.yaml +++ b/helm/templates/db_pv.yaml @@ -9,7 +9,7 @@ spec: storage: {{ .Values.pv.dbPv.storageRequest }} accessModes: - {{ .Values.pv.dbPv.accessModes }} - persistentVolumeReclaimPolicy: Retain - storageClassName: standard + persistentVolumeReclaimPolicy: {{ .Values.pv.dbPv.reclaimPolicy }} + storageClassName: {{ .Values.pv.dbPv.storageClass }} hostPath: path: {{ .Values.pv.dbPv.hostPath | quote }} diff --git a/helm/templates/web_pv.yaml b/helm/templates/web_pv.yaml index 4997c95..2da6017 100644 --- a/helm/templates/web_pv.yaml +++ b/helm/templates/web_pv.yaml @@ -9,7 +9,7 @@ spec: storage: {{ .Values.pv.staticPv.storageRequest }} accessModes: - {{ .Values.pv.staticPv.accessModes }} - persistentVolumeReclaimPolicy: Retain - storageClassName: standard + persistentVolumeReclaimPolicy: {{ .Values.pv.staticPv.reclaimPolicy }} + storageClassName: {{ .Values.pv.staticPv.storageClass }} hostPath: path: {{ .Values.pv.staticPv.hostPath | quote }} diff --git a/helm/values.yaml b/helm/values.yaml index 3fdc2ce..8f3c1b4 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -56,10 +56,14 @@ nginxDeployment: pv: dbPv: storageRequest: 5Gi + storageClass: standard + reclaimPolicy: Retain accessModes: ReadWriteOnce hostPath: /var/lib/docker/volumes/phrinifluent-db-pv/_data staticPv: storageRequest: 2Gi + storageClass: standard + reclaimPolicy: Retain accessModes: ReadWriteMany hostPath: /var/lib/docker/volumes/phrinifluent-static-pv/_data pvc: From 05d901125afd2e4bbe6060a9ab36c9a1dd2d4f56 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:15:58 +0100 Subject: [PATCH 38/56] Fix indentation in staticService ports definition --- helm/values.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helm/values.yaml b/helm/values.yaml index 8f3c1b4..127a9ca 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -75,7 +75,7 @@ pvc: storageRequest: 2Gi staticService: ports: - - port: 80 - protocol: TCP - targetPort: 80 + - port: 80 + protocol: TCP + targetPort: 80 type: ClusterIP From fa0979589b778d9b1d9e207e5580e5fc5e85771b Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:38:14 +0100 Subject: [PATCH 39/56] Standartize the ports in kubernetes configs --- helm/templates/db_config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/templates/db_config.yaml b/helm/templates/db_config.yaml index 497ce8e..da5d5c9 100644 --- a/helm/templates/db_config.yaml +++ b/helm/templates/db_config.yaml @@ -5,6 +5,6 @@ metadata: labels: {{- include "flatchart.labels" . | nindent 4 }} data: - POSTGRES_NAME: {{ .Values.dbConfig.postgresName | quote }} + POSTGRES_NAME: postgres POSTGRES_HOST: {{ .Values.dbConfig.postgresHost | quote }} - POSTGRES_PORT: {{ .Values.dbConfig.postgresPort | quote }} + POSTGRES_PORT: "5432" From 5e9f30c2a529d5b412ffc80b5a5c76f1207130f0 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:38:50 +0100 Subject: [PATCH 40/56] Standartize the persistent volume variables --- helm/templates/db_pv.yaml | 6 +++--- helm/templates/db_pvc.yaml | 2 +- helm/templates/web_pv.yaml | 6 +++--- helm/templates/web_pvc.yaml | 2 +- helm/values.yaml | 10 ---------- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/helm/templates/db_pv.yaml b/helm/templates/db_pv.yaml index 69448a0..e50eb2a 100644 --- a/helm/templates/db_pv.yaml +++ b/helm/templates/db_pv.yaml @@ -8,8 +8,8 @@ spec: capacity: storage: {{ .Values.pv.dbPv.storageRequest }} accessModes: - - {{ .Values.pv.dbPv.accessModes }} - persistentVolumeReclaimPolicy: {{ .Values.pv.dbPv.reclaimPolicy }} - storageClassName: {{ .Values.pv.dbPv.storageClass }} + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + storageClassName: standard hostPath: path: {{ .Values.pv.dbPv.hostPath | quote }} diff --git a/helm/templates/db_pvc.yaml b/helm/templates/db_pvc.yaml index 0961a5d..20463e2 100644 --- a/helm/templates/db_pvc.yaml +++ b/helm/templates/db_pvc.yaml @@ -10,4 +10,4 @@ spec: resources: requests: storage: {{ .Values.pvc.dbPvc.storageRequest | quote }} - storageClassName: {{ .Values.pvc.dbPvc.storageClass | quote }} + storageClassName: standard diff --git a/helm/templates/web_pv.yaml b/helm/templates/web_pv.yaml index 2da6017..4a1fc6d 100644 --- a/helm/templates/web_pv.yaml +++ b/helm/templates/web_pv.yaml @@ -8,8 +8,8 @@ spec: capacity: storage: {{ .Values.pv.staticPv.storageRequest }} accessModes: - - {{ .Values.pv.staticPv.accessModes }} - persistentVolumeReclaimPolicy: {{ .Values.pv.staticPv.reclaimPolicy }} - storageClassName: {{ .Values.pv.staticPv.storageClass }} + - ReadWriteMany + persistentVolumeReclaimPolicy: Retain + storageClassName: standard hostPath: path: {{ .Values.pv.staticPv.hostPath | quote }} diff --git a/helm/templates/web_pvc.yaml b/helm/templates/web_pvc.yaml index 3c681c4..ace4a51 100644 --- a/helm/templates/web_pvc.yaml +++ b/helm/templates/web_pvc.yaml @@ -10,4 +10,4 @@ spec: resources: requests: storage: {{ .Values.pvc.staticPvc.storageRequest | quote }} - storageClassName: {{ .Values.pvc.staticPvc.storageClass | quote }} + storageClassName: standard diff --git a/helm/values.yaml b/helm/values.yaml index 127a9ca..a8751f7 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -23,8 +23,6 @@ backendService: type: ClusterIP dbConfig: postgresHost: phrinifluent-db-service - postgresName: postgres - postgresPort: "5432" dbDeployment: phrinifluentDb: image: @@ -56,22 +54,14 @@ nginxDeployment: pv: dbPv: storageRequest: 5Gi - storageClass: standard - reclaimPolicy: Retain - accessModes: ReadWriteOnce hostPath: /var/lib/docker/volumes/phrinifluent-db-pv/_data staticPv: storageRequest: 2Gi - storageClass: standard - reclaimPolicy: Retain - accessModes: ReadWriteMany hostPath: /var/lib/docker/volumes/phrinifluent-static-pv/_data pvc: dbPvc: - storageClass: standard storageRequest: 5Gi staticPvc: - storageClass: standard storageRequest: 2Gi staticService: ports: From 3fc45d2d86e4d7262f5348051c45573483b16766 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:39:57 +0100 Subject: [PATCH 41/56] Update static_service.yaml and values.yaml --- helm/templates/static_service.yaml | 6 ++++-- helm/values.yaml | 6 ------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/helm/templates/static_service.yaml b/helm/templates/static_service.yaml index afb0e79..5e1261b 100644 --- a/helm/templates/static_service.yaml +++ b/helm/templates/static_service.yaml @@ -5,9 +5,11 @@ metadata: labels: {{- include "flatchart.labels" . | nindent 4 }} spec: - type: {{ .Values.staticService.type }} + type: ClusterIP selector: app: nginx {{- include "flatchart.selectorLabels" . | nindent 4 }} ports: - {{- .Values.staticService.ports | toYaml | nindent 2 -}} + - port: 80 + protocol: TCP + targetPort: 80 diff --git a/helm/values.yaml b/helm/values.yaml index a8751f7..d045ba8 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -63,9 +63,3 @@ pvc: storageRequest: 5Gi staticPvc: storageRequest: 2Gi -staticService: - ports: - - port: 80 - protocol: TCP - targetPort: 80 - type: ClusterIP From 10072b3be5c42556e90289cb2708c19b88788847 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:41:24 +0100 Subject: [PATCH 42/56] Update nginx configuration to serve static files --- helm/templates/static_config.yaml | 10 +++++++++- helm/values.yaml | 9 --------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/helm/templates/static_config.yaml b/helm/templates/static_config.yaml index d80b9f7..b17aa64 100644 --- a/helm/templates/static_config.yaml +++ b/helm/templates/static_config.yaml @@ -5,4 +5,12 @@ metadata: labels: {{- include "flatchart.labels" . | nindent 4 }} data: - default.conf: {{ .Values.nginxConfig.defaultConf | toYaml | indent 1 }} + default.conf: | + server { + listen 80; + server_name _; + + location /static { + alias /usr/share/nginx/html/static; + } + } diff --git a/helm/values.yaml b/helm/values.yaml index d045ba8..e0886ec 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -36,15 +36,6 @@ dbService: targetPort: 5432 type: ClusterIP kubernetesClusterDomain: cluster.local -nginxConfig: - defaultConf: |- - server { - listen 80; - server_name _; - location /static { - alias /usr/share/nginx/html/static; - } - } nginxDeployment: nginx: image: From 9a1daf0b970a27c1049b99b06de48c59c0ec1910 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:42:26 +0100 Subject: [PATCH 43/56] Update db_service.yaml and values.yaml --- helm/templates/db_service.yaml | 6 ++++-- helm/values.yaml | 6 ------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/helm/templates/db_service.yaml b/helm/templates/db_service.yaml index 0198ab4..04f9910 100644 --- a/helm/templates/db_service.yaml +++ b/helm/templates/db_service.yaml @@ -5,9 +5,11 @@ metadata: labels: {{- include "flatchart.labels" . | nindent 4 }} spec: - type: {{ .Values.dbService.type }} + type: ClusterIP selector: app: phrinifluent-db {{- include "flatchart.selectorLabels" . | nindent 4 }} ports: - {{- .Values.dbService.ports | toYaml | nindent 2 -}} + - port: 5432 + protocol: TCP + targetPort: 5432 diff --git a/helm/values.yaml b/helm/values.yaml index e0886ec..94f8be9 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -29,12 +29,6 @@ dbDeployment: repository: postgres tag: latest replicas: 1 -dbService: - ports: - - port: 5432 - protocol: TCP - targetPort: 5432 - type: ClusterIP kubernetesClusterDomain: cluster.local nginxDeployment: nginx: From da1dc7a13d65d5d410a6ad593a7b3bba31971bf3 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:44:45 +0100 Subject: [PATCH 44/56] Update web_service.yaml and values.yaml --- helm/templates/web_service.yaml | 6 ++++-- helm/values.yaml | 6 ------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/helm/templates/web_service.yaml b/helm/templates/web_service.yaml index 7d25a00..1dea64b 100644 --- a/helm/templates/web_service.yaml +++ b/helm/templates/web_service.yaml @@ -5,9 +5,11 @@ metadata: labels: {{- include "flatchart.labels" . | nindent 4 }} spec: - type: {{ .Values.backendService.type }} + type: ClusterIP selector: app: phrinifluent-backend {{- include "flatchart.selectorLabels" . | nindent 4 }} ports: - {{- .Values.backendService.ports | toYaml | nindent 2 -}} + - port: 80 + protocol: TCP + targetPort: 8000 diff --git a/helm/values.yaml b/helm/values.yaml index 94f8be9..657ff89 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -15,12 +15,6 @@ backendDeployment: repository: ghcr.io/flagro/phrinifluentbackend tag: latest replicas: 1 -backendService: - ports: - - port: 80 - protocol: TCP - targetPort: 8000 - type: ClusterIP dbConfig: postgresHost: phrinifluent-db-service dbDeployment: From 46037179055d0096be2d7ec3b89d921a82879e1e Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:45:45 +0100 Subject: [PATCH 45/56] Refactor backendDeployment args in values.yaml --- helm/values.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/helm/values.yaml b/helm/values.yaml index 657ff89..1f182da 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -7,10 +7,10 @@ backendDeployment: tag: latest phrinifluentBackendSetup: args: - - | - python manage.py migrate && - python manage.py createadmin && - python manage.py collectstatic --noinput + - | + python manage.py migrate && + python manage.py createadmin && + python manage.py collectstatic --noinput image: repository: ghcr.io/flagro/phrinifluentbackend tag: latest From b10dee8b502828e361364a17ae28693709b2a04e Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:46:23 +0100 Subject: [PATCH 46/56] Fix POSTGRES_NAME value in db_config.yaml --- helm/templates/db_config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/templates/db_config.yaml b/helm/templates/db_config.yaml index da5d5c9..77bb787 100644 --- a/helm/templates/db_config.yaml +++ b/helm/templates/db_config.yaml @@ -5,6 +5,6 @@ metadata: labels: {{- include "flatchart.labels" . | nindent 4 }} data: - POSTGRES_NAME: postgres + POSTGRES_NAME: "postgres" POSTGRES_HOST: {{ .Values.dbConfig.postgresHost | quote }} POSTGRES_PORT: "5432" From a2538b1fd19558f9eec78adbec56b2ecd855c397 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:47:50 +0100 Subject: [PATCH 47/56] Fix port order in service templates --- helm/templates/db_service.yaml | 4 ++-- helm/templates/static_service.yaml | 4 ++-- helm/templates/web_service.yaml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/helm/templates/db_service.yaml b/helm/templates/db_service.yaml index 04f9910..a38c728 100644 --- a/helm/templates/db_service.yaml +++ b/helm/templates/db_service.yaml @@ -10,6 +10,6 @@ spec: app: phrinifluent-db {{- include "flatchart.selectorLabels" . | nindent 4 }} ports: - - port: 5432 - protocol: TCP + - protocol: TCP + port: 5432 targetPort: 5432 diff --git a/helm/templates/static_service.yaml b/helm/templates/static_service.yaml index 5e1261b..b4acf86 100644 --- a/helm/templates/static_service.yaml +++ b/helm/templates/static_service.yaml @@ -10,6 +10,6 @@ spec: app: nginx {{- include "flatchart.selectorLabels" . | nindent 4 }} ports: - - port: 80 - protocol: TCP + - protocol: TCP + port: 80 targetPort: 80 diff --git a/helm/templates/web_service.yaml b/helm/templates/web_service.yaml index 1dea64b..585acb7 100644 --- a/helm/templates/web_service.yaml +++ b/helm/templates/web_service.yaml @@ -10,6 +10,6 @@ spec: app: phrinifluent-backend {{- include "flatchart.selectorLabels" . | nindent 4 }} ports: - - port: 80 - protocol: TCP + - protocol: TCP + port: 80 targetPort: 8000 From 1680378b05163086cbb81b21bb0e11078c18824d Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:50:23 +0100 Subject: [PATCH 48/56] Update ingress host in helm templates and values.yaml --- helm/templates/ingress.yaml | 4 ++-- helm/values.yaml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml index 47de353..6bfbf0c 100644 --- a/helm/templates/ingress.yaml +++ b/helm/templates/ingress.yaml @@ -6,7 +6,7 @@ metadata: {{- include "flatchart.labels" . | nindent 4 }} spec: rules: - - host: api.phrinifluent.com + - host: {{ .Values.ingress.host }} http: paths: - path: /static @@ -25,5 +25,5 @@ spec: number: 80 tls: - hosts: - - api.phrinifluent.com + - {{ .Values.ingress.host }} secretName: phrinifluent-tls-secrets diff --git a/helm/values.yaml b/helm/values.yaml index 1f182da..d9fc2b9 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -42,3 +42,5 @@ pvc: storageRequest: 5Gi staticPvc: storageRequest: 2Gi +ingress: + host: api.phrinifluent.com From edde610c9c944003ebed008ed7a729be1a268662 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:54:16 +0100 Subject: [PATCH 49/56] Update database configuration and remove unused code --- helm/templates/db_config.yaml | 2 +- helm/values.yaml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/helm/templates/db_config.yaml b/helm/templates/db_config.yaml index 77bb787..dc72e54 100644 --- a/helm/templates/db_config.yaml +++ b/helm/templates/db_config.yaml @@ -6,5 +6,5 @@ metadata: {{- include "flatchart.labels" . | nindent 4 }} data: POSTGRES_NAME: "postgres" - POSTGRES_HOST: {{ .Values.dbConfig.postgresHost | quote }} + POSTGRES_HOST: "{{ include "flatchart.fullname" . }}-db-service" POSTGRES_PORT: "5432" diff --git a/helm/values.yaml b/helm/values.yaml index d9fc2b9..c8ada05 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -15,8 +15,6 @@ backendDeployment: repository: ghcr.io/flagro/phrinifluentbackend tag: latest replicas: 1 -dbConfig: - postgresHost: phrinifluent-db-service dbDeployment: phrinifluentDb: image: From c307b24829246d2adbf1f73187f85bdb6a0f4a5b Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 22:09:40 +0100 Subject: [PATCH 50/56] Add configuration files and services for web, database, static, and ingress --- helm/templates/{ => db}/db_config.yaml | 0 helm/templates/{ => db}/db_deployment.yaml | 0 helm/templates/{ => db}/db_pv.yaml | 0 helm/templates/{ => db}/db_pvc.yaml | 0 helm/templates/{ => db}/db_service.yaml | 0 helm/templates/{ => ingress}/ingress.yaml | 0 helm/templates/{ => static}/static_config.yaml | 0 helm/templates/{ => static}/static_deployment.yaml | 0 helm/templates/{ => static}/static_service.yaml | 0 helm/templates/{ => web}/web_config.yaml | 0 helm/templates/{ => web}/web_deployment.yaml | 0 helm/templates/{ => web}/web_pv.yaml | 0 helm/templates/{ => web}/web_pvc.yaml | 0 helm/templates/{ => web}/web_service.yaml | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename helm/templates/{ => db}/db_config.yaml (100%) rename helm/templates/{ => db}/db_deployment.yaml (100%) rename helm/templates/{ => db}/db_pv.yaml (100%) rename helm/templates/{ => db}/db_pvc.yaml (100%) rename helm/templates/{ => db}/db_service.yaml (100%) rename helm/templates/{ => ingress}/ingress.yaml (100%) rename helm/templates/{ => static}/static_config.yaml (100%) rename helm/templates/{ => static}/static_deployment.yaml (100%) rename helm/templates/{ => static}/static_service.yaml (100%) rename helm/templates/{ => web}/web_config.yaml (100%) rename helm/templates/{ => web}/web_deployment.yaml (100%) rename helm/templates/{ => web}/web_pv.yaml (100%) rename helm/templates/{ => web}/web_pvc.yaml (100%) rename helm/templates/{ => web}/web_service.yaml (100%) diff --git a/helm/templates/db_config.yaml b/helm/templates/db/db_config.yaml similarity index 100% rename from helm/templates/db_config.yaml rename to helm/templates/db/db_config.yaml diff --git a/helm/templates/db_deployment.yaml b/helm/templates/db/db_deployment.yaml similarity index 100% rename from helm/templates/db_deployment.yaml rename to helm/templates/db/db_deployment.yaml diff --git a/helm/templates/db_pv.yaml b/helm/templates/db/db_pv.yaml similarity index 100% rename from helm/templates/db_pv.yaml rename to helm/templates/db/db_pv.yaml diff --git a/helm/templates/db_pvc.yaml b/helm/templates/db/db_pvc.yaml similarity index 100% rename from helm/templates/db_pvc.yaml rename to helm/templates/db/db_pvc.yaml diff --git a/helm/templates/db_service.yaml b/helm/templates/db/db_service.yaml similarity index 100% rename from helm/templates/db_service.yaml rename to helm/templates/db/db_service.yaml diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress/ingress.yaml similarity index 100% rename from helm/templates/ingress.yaml rename to helm/templates/ingress/ingress.yaml diff --git a/helm/templates/static_config.yaml b/helm/templates/static/static_config.yaml similarity index 100% rename from helm/templates/static_config.yaml rename to helm/templates/static/static_config.yaml diff --git a/helm/templates/static_deployment.yaml b/helm/templates/static/static_deployment.yaml similarity index 100% rename from helm/templates/static_deployment.yaml rename to helm/templates/static/static_deployment.yaml diff --git a/helm/templates/static_service.yaml b/helm/templates/static/static_service.yaml similarity index 100% rename from helm/templates/static_service.yaml rename to helm/templates/static/static_service.yaml diff --git a/helm/templates/web_config.yaml b/helm/templates/web/web_config.yaml similarity index 100% rename from helm/templates/web_config.yaml rename to helm/templates/web/web_config.yaml diff --git a/helm/templates/web_deployment.yaml b/helm/templates/web/web_deployment.yaml similarity index 100% rename from helm/templates/web_deployment.yaml rename to helm/templates/web/web_deployment.yaml diff --git a/helm/templates/web_pv.yaml b/helm/templates/web/web_pv.yaml similarity index 100% rename from helm/templates/web_pv.yaml rename to helm/templates/web/web_pv.yaml diff --git a/helm/templates/web_pvc.yaml b/helm/templates/web/web_pvc.yaml similarity index 100% rename from helm/templates/web_pvc.yaml rename to helm/templates/web/web_pvc.yaml diff --git a/helm/templates/web_service.yaml b/helm/templates/web/web_service.yaml similarity index 100% rename from helm/templates/web_service.yaml rename to helm/templates/web/web_service.yaml From fe284a73a7787b6b93af3f41ae1d63fb938fa4e6 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 22:10:53 +0100 Subject: [PATCH 51/56] Add Helm templates for web, db, and static components --- helm/templates/db/{db_config.yaml => config.yaml} | 0 helm/templates/db/{db_deployment.yaml => deployment.yaml} | 0 helm/templates/db/{db_pv.yaml => pv.yaml} | 0 helm/templates/db/{db_pvc.yaml => pvc.yaml} | 0 helm/templates/db/{db_service.yaml => service.yaml} | 0 helm/templates/static/{static_config.yaml => config.yaml} | 0 helm/templates/static/{static_deployment.yaml => deployment.yaml} | 0 helm/templates/static/{static_service.yaml => service.yaml} | 0 helm/templates/web/{web_config.yaml => config.yaml} | 0 helm/templates/web/{web_deployment.yaml => deployment.yaml} | 0 helm/templates/web/{web_pv.yaml => pv.yaml} | 0 helm/templates/web/{web_pvc.yaml => pvc.yaml} | 0 helm/templates/web/{web_service.yaml => service.yaml} | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename helm/templates/db/{db_config.yaml => config.yaml} (100%) rename helm/templates/db/{db_deployment.yaml => deployment.yaml} (100%) rename helm/templates/db/{db_pv.yaml => pv.yaml} (100%) rename helm/templates/db/{db_pvc.yaml => pvc.yaml} (100%) rename helm/templates/db/{db_service.yaml => service.yaml} (100%) rename helm/templates/static/{static_config.yaml => config.yaml} (100%) rename helm/templates/static/{static_deployment.yaml => deployment.yaml} (100%) rename helm/templates/static/{static_service.yaml => service.yaml} (100%) rename helm/templates/web/{web_config.yaml => config.yaml} (100%) rename helm/templates/web/{web_deployment.yaml => deployment.yaml} (100%) rename helm/templates/web/{web_pv.yaml => pv.yaml} (100%) rename helm/templates/web/{web_pvc.yaml => pvc.yaml} (100%) rename helm/templates/web/{web_service.yaml => service.yaml} (100%) diff --git a/helm/templates/db/db_config.yaml b/helm/templates/db/config.yaml similarity index 100% rename from helm/templates/db/db_config.yaml rename to helm/templates/db/config.yaml diff --git a/helm/templates/db/db_deployment.yaml b/helm/templates/db/deployment.yaml similarity index 100% rename from helm/templates/db/db_deployment.yaml rename to helm/templates/db/deployment.yaml diff --git a/helm/templates/db/db_pv.yaml b/helm/templates/db/pv.yaml similarity index 100% rename from helm/templates/db/db_pv.yaml rename to helm/templates/db/pv.yaml diff --git a/helm/templates/db/db_pvc.yaml b/helm/templates/db/pvc.yaml similarity index 100% rename from helm/templates/db/db_pvc.yaml rename to helm/templates/db/pvc.yaml diff --git a/helm/templates/db/db_service.yaml b/helm/templates/db/service.yaml similarity index 100% rename from helm/templates/db/db_service.yaml rename to helm/templates/db/service.yaml diff --git a/helm/templates/static/static_config.yaml b/helm/templates/static/config.yaml similarity index 100% rename from helm/templates/static/static_config.yaml rename to helm/templates/static/config.yaml diff --git a/helm/templates/static/static_deployment.yaml b/helm/templates/static/deployment.yaml similarity index 100% rename from helm/templates/static/static_deployment.yaml rename to helm/templates/static/deployment.yaml diff --git a/helm/templates/static/static_service.yaml b/helm/templates/static/service.yaml similarity index 100% rename from helm/templates/static/static_service.yaml rename to helm/templates/static/service.yaml diff --git a/helm/templates/web/web_config.yaml b/helm/templates/web/config.yaml similarity index 100% rename from helm/templates/web/web_config.yaml rename to helm/templates/web/config.yaml diff --git a/helm/templates/web/web_deployment.yaml b/helm/templates/web/deployment.yaml similarity index 100% rename from helm/templates/web/web_deployment.yaml rename to helm/templates/web/deployment.yaml diff --git a/helm/templates/web/web_pv.yaml b/helm/templates/web/pv.yaml similarity index 100% rename from helm/templates/web/web_pv.yaml rename to helm/templates/web/pv.yaml diff --git a/helm/templates/web/web_pvc.yaml b/helm/templates/web/pvc.yaml similarity index 100% rename from helm/templates/web/web_pvc.yaml rename to helm/templates/web/pvc.yaml diff --git a/helm/templates/web/web_service.yaml b/helm/templates/web/service.yaml similarity index 100% rename from helm/templates/web/web_service.yaml rename to helm/templates/web/service.yaml From 685e85bc402a099640e5388715a68512e636c175 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 22:21:21 +0100 Subject: [PATCH 52/56] Update secrets and labels in Helm templates --- helm/templates/db/deployment.yaml | 2 +- helm/templates/db/secrets.yaml | 11 +++++++++++ helm/templates/ingress/ingress.yaml | 2 +- helm/templates/ingress/secrets.yaml | 10 ++++++++++ helm/templates/web/deployment.yaml | 8 ++++---- helm/templates/web/secrets.yaml | 12 ++++++++++++ 6 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 helm/templates/db/secrets.yaml create mode 100644 helm/templates/ingress/secrets.yaml create mode 100644 helm/templates/web/secrets.yaml diff --git a/helm/templates/db/deployment.yaml b/helm/templates/db/deployment.yaml index e89f789..7a468ff 100644 --- a/helm/templates/db/deployment.yaml +++ b/helm/templates/db/deployment.yaml @@ -23,7 +23,7 @@ spec: - containerPort: 5432 envFrom: - secretRef: - name: phrinifluent-db-secrets + name: {{ include "flatchart.fullname" . }}-db-secrets - configMapRef: name: {{ include "flatchart.fullname" . }}-db-config - env: diff --git a/helm/templates/db/secrets.yaml b/helm/templates/db/secrets.yaml new file mode 100644 index 0000000..a58c762 --- /dev/null +++ b/helm/templates/db/secrets.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "flatchart.fullname" . }}-db-secrets + labels: + {{- include "flatchart.labels" . | nindent 4 }} +type: Opaque +data: + POSTGRES_USER: {{ .Values.dbSecrets.user | b64enc | quote }} + POSTGRES_PASSWORD: {{ .Values.dbSecrets.password | b64enc | quote }} + POSTGRES_DB: {{ .Values.dbSecrets.dbName | b64enc | quote }} diff --git a/helm/templates/ingress/ingress.yaml b/helm/templates/ingress/ingress.yaml index 6bfbf0c..e13d6d9 100644 --- a/helm/templates/ingress/ingress.yaml +++ b/helm/templates/ingress/ingress.yaml @@ -26,4 +26,4 @@ spec: tls: - hosts: - {{ .Values.ingress.host }} - secretName: phrinifluent-tls-secrets + secretName: {{ include "flatchart.fullname" . }}-tls-secrets diff --git a/helm/templates/ingress/secrets.yaml b/helm/templates/ingress/secrets.yaml new file mode 100644 index 0000000..f68d356 --- /dev/null +++ b/helm/templates/ingress/secrets.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "flatchart.fullname" . }}-tls-secrets + labels: + {{- include "flatchart.labels" . | nindent 4 }} +type: kubernetes.io/tls +data: + tls.crt: {{ .Files.Get .Values.tlsSecrets.certFile | b64enc | quote }} + tls.key: {{ .Files.Get .Values.tlsSecrets.keyFile | b64enc | quote }} diff --git a/helm/templates/web/deployment.yaml b/helm/templates/web/deployment.yaml index 40f0367..b36df20 100644 --- a/helm/templates/web/deployment.yaml +++ b/helm/templates/web/deployment.yaml @@ -27,9 +27,9 @@ spec: args: {{- toYaml .Values.backendDeployment.phrinifluentBackendSetup.args | nindent 8 }} envFrom: - secretRef: - name: phrinifluent-backend-secrets + name: {{ include "flatchart.fullname" . }}-backend-secrets - secretRef: - name: phrinifluent-db-secrets + name: {{ include "flatchart.fullname" . }}-db-secrets - configMapRef: name: {{ include "flatchart.fullname" . }}-backend-config - configMapRef: @@ -48,9 +48,9 @@ spec: - containerPort: 8000 envFrom: - secretRef: - name: phrinifluent-backend-secrets + name: {{ include "flatchart.fullname" . }}-backend-secrets - secretRef: - name: phrinifluent-db-secrets + name: {{ include "flatchart.fullname" . }}-db-secrets - configMapRef: name: {{ include "flatchart.fullname" . }}-backend-config - configMapRef: diff --git a/helm/templates/web/secrets.yaml b/helm/templates/web/secrets.yaml new file mode 100644 index 0000000..8a954e5 --- /dev/null +++ b/helm/templates/web/secrets.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "flatchart.fullname" . }}-backend-secrets + labels: + {{- include "flatchart.labels" . | nindent 4 }} +type: Opaque +data: + SECRET_KEY: {{ .Values.backendSecrets.secretKey | b64enc | quote }} + ADMIN_USERNAME: {{ .Values.backendSecrets.adminUsername | b64enc | quote }} + ADMIN_EMAIL: {{ .Values.backendSecrets.adminEmail | b64enc | quote }} + ADMIN_PASSWORD: {{ .Values.backendSecrets.adminPassword | b64enc | quote }} From de98294eb48eb8e3ac15cf66e2055e48ac4eb68b Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 22:25:30 +0100 Subject: [PATCH 53/56] Add Kubernetes cluster domain and update ingress host*** ***Add backend, database, and nginx deployments*** ***Add persistent volumes and persistent volume claims*** ***Add secrets for database, backend, and TLS*** ***Update helm/values.yaml --- helm/values.yaml | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/helm/values.yaml b/helm/values.yaml index c8ada05..8f47cf2 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -1,5 +1,11 @@ backendConfig: environment: production + +kubernetesClusterDomain: cluster.local + +ingress: + host: api.phrinifluent.com + backendDeployment: phrinifluentBackend: image: @@ -15,19 +21,21 @@ backendDeployment: repository: ghcr.io/flagro/phrinifluentbackend tag: latest replicas: 1 + dbDeployment: phrinifluentDb: image: repository: postgres tag: latest replicas: 1 -kubernetesClusterDomain: cluster.local + nginxDeployment: nginx: image: repository: nginx tag: latest replicas: 1 + pv: dbPv: storageRequest: 5Gi @@ -35,10 +43,24 @@ pv: staticPv: storageRequest: 2Gi hostPath: /var/lib/docker/volumes/phrinifluent-static-pv/_data + pvc: dbPvc: storageRequest: 5Gi staticPvc: storageRequest: 2Gi -ingress: - host: api.phrinifluent.com + +dbSecrets: + user: "" + password: "" + dbName: "" + +backendSecrets: + secretKey: "" + adminUsername: "" + adminEmail: "" + adminPassword: "" + +tlsSecrets: + certFile: "cert.pem" + keyFile: "key.pem" From 6725f4de4c9bf89cc9ef9c25586e02f075e41e83 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 22:37:14 +0100 Subject: [PATCH 54/56] Update deployment script to use Helm for Kubernetes deployment --- .github/workflows/deploy.yaml | 50 +++++++++++++---------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index a2b4423..04db0f1 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -32,6 +32,15 @@ jobs: with: kubeconfig: ${{ secrets.KUBE_CONFIG }} + - name: Set up Helm + uses: azure/setup-helm@v1 + + # - name: Add Helm repository + # run: helm repo add myrepo https://mychartrepo.com/charts + + # - name: Update Helm repositories + # run: helm repo update + - name: Create and Apply Kubernetes Secrets env: DB_USER: ${{ secrets.DB_USER }} @@ -43,34 +52,13 @@ jobs: SSL_CERTIFICATE: ${{ secrets.SSL_CERTIFICATE }} SSL_KEY: ${{ secrets.SSL_KEY }} run: | - kubectl create secret generic phrinifluent-db-secrets \ - --from-literal=POSTGRES_USER="$DB_USER" \ - --from-literal=POSTGRES_PASSWORD="$DB_PASSWORD" \ - --from-literal=POSTGRES_DB="$DB_NAME" \ - -o yaml --dry-run=client | kubectl apply -f - - kubectl create secret generic phrinifluent-backend-secrets \ - --from-literal=SECRET_KEY="$SECRET_KEY" \ - --from-literal=ADMIN_USERNAME="$ADMIN_USERNAME" \ - --from-literal=ADMIN_EMAIL="$ADMIN_EMAIL" \ - --from-literal=ADMIN_PASSWORD="$ADMIN_PASSWORD" \ - --from-literal=SSL_CERTIFICATE="$SSL_CERTIFICATE" \ - --from-literal=SSL_KEY="$SSL_KEY" \ - -o yaml --dry-run=client | kubectl apply -f - - echo "$SSL_CERTIFICATE" > cert.pem - echo "$SSL_KEY" > key.pem - kubectl create secret tls phrinifluent-tls-secrets \ - --cert=cert.pem \ - --key=key.pem \ - -o yaml --dry-run=client | kubectl apply -f - - - - name: Update image tags in Kubernetes manifests - run: | - TAG="${{ steps.latest_tag.outputs.tag }}" - sed -i "s|flagro/phrinifluent_web:latest|flagro/phrinifluent_web:$TAG|g" ./k8s/web/deployment.yml - - - name: Deploy to Kubernetes - run: | - kubectl apply -f ./k8s/db/ - kubectl apply -f ./k8s/ingress/ - kubectl apply -f ./k8s/web/ - kubectl apply -f ./k8s/static/ + helm upgrade --install ${{ steps.latest_tag.outputs.tag }} ./helm \ + --set image.tag=${{ steps.latest_tag.outputs.tag }} \ + --set dbSecrets.user=${{ secrets.DB_USER }} \ + --set dbSecrets.password=${{ secrets.DB_PASSWORD }} \ + --set backendSecrets.secretKey=${{ secrets.SECRET_KEY }} \ + --set backendSecrets.adminUsername=${{ secrets.ADMIN_USERNAME }} \ + --set backendSecrets.adminEmail=${{ secrets.ADMIN_EMAIL }} \ + --set backendSecrets.adminPassword=${{ secrets.ADMIN_PASSWORD }} \ + --set-file tlsSecrets.certFile=<(echo "${{ secrets.SSL_CERTIFICATE }}") \ + --set-file tlsSecrets.keyFile=<(echo "${{ secrets.SSL_KEY }}") From 1e78fa88465d76d0a417de387f1c9084b8b1b8eb Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 22:39:10 +0100 Subject: [PATCH 55/56] Add namespace creation step in deploy workflow --- .github/workflows/deploy.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 04db0f1..de2c6a2 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -31,6 +31,10 @@ jobs: uses: azure/k8s-set-context@v1 with: kubeconfig: ${{ secrets.KUBE_CONFIG }} + + - name: Create Namespace (if not exists) + run: | + kubectl get ns phrinifluent || kubectl create ns phrinifluent - name: Set up Helm uses: azure/setup-helm@v1 @@ -53,6 +57,7 @@ jobs: SSL_KEY: ${{ secrets.SSL_KEY }} run: | helm upgrade --install ${{ steps.latest_tag.outputs.tag }} ./helm \ + --namespace phrinifluent \ --set image.tag=${{ steps.latest_tag.outputs.tag }} \ --set dbSecrets.user=${{ secrets.DB_USER }} \ --set dbSecrets.password=${{ secrets.DB_PASSWORD }} \ From a05aa5eebb8971c0284713ac9a155992bd36fd84 Mon Sep 17 00:00:00 2001 From: Anton Potapov <47938145+Flagro@users.noreply.github.com> Date: Sat, 2 Mar 2024 22:48:22 +0100 Subject: [PATCH 56/56] Update deployment workflow to use Helm for deployment --- .github/workflows/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index de2c6a2..8f6b945 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -45,7 +45,7 @@ jobs: # - name: Update Helm repositories # run: helm repo update - - name: Create and Apply Kubernetes Secrets + - name: Deploy with Helm env: DB_USER: ${{ secrets.DB_USER }} DB_PASSWORD: ${{ secrets.DB_PASSWORD }}