From 4947df01f389fe9bf0c1c18f8a9374f376912c39 Mon Sep 17 00:00:00 2001 From: Rishab <33950743+rishabjasrotia@users.noreply.github.com> Date: Mon, 22 Jan 2024 03:58:41 +0000 Subject: [PATCH] #36 - Helm Charts Added --- iac/docker/helm/charts/drupal-fpm/Chart.yaml | 21 +++++ .../charts/drupal-fpm/templates/_helpers.tpl | 62 ++++++++++++++ .../drupal-fpm/templates/deployment.yaml | 82 +++++++++++++++++++ .../drupal-fpm/templates/drupal-fpm.yaml | 18 ++++ iac/docker/helm/charts/drupal-fpm/values.yaml | 12 +++ iac/docker/helm/charts/mysql/Chart.yaml | 21 +++++ .../helm/charts/mysql/templates/_helpers.tpl | 62 ++++++++++++++ .../mysql/templates/mysql-deployment.yaml | 78 ++++++++++++++++++ .../charts/mysql/templates/mysql-service.yaml | 17 ++++ iac/docker/helm/charts/mysql/values.yaml | 14 ++++ iac/docker/helm/charts/ngnix/Chart.yaml | 21 +++++ .../helm/charts/ngnix/templates/_helpers.tpl | 62 ++++++++++++++ .../helm/charts/ngnix/templates/ingress.yaml | 20 +++++ .../ngnix/templates/ngnix-deployment.yaml | 38 +++++++++ .../charts/ngnix/templates/ngnix-service.yaml | 17 ++++ iac/docker/helm/charts/ngnix/values.yaml | 11 +++ iac/docker/helm/charts/phpmyadmin/Chart.yaml | 21 +++++ .../charts/phpmyadmin/templates/_helpers.tpl | 62 ++++++++++++++ .../templates/phpmyadmin-deployment.yaml | 42 ++++++++++ .../templates/phpmyadmin-service.yaml | 17 ++++ iac/docker/helm/charts/phpmyadmin/values.yaml | 16 ++++ iac/docker/helm/nginx/ngnix-service.yaml | 2 +- 22 files changed, 715 insertions(+), 1 deletion(-) create mode 100644 iac/docker/helm/charts/drupal-fpm/Chart.yaml create mode 100644 iac/docker/helm/charts/drupal-fpm/templates/_helpers.tpl create mode 100644 iac/docker/helm/charts/drupal-fpm/templates/deployment.yaml create mode 100644 iac/docker/helm/charts/drupal-fpm/templates/drupal-fpm.yaml create mode 100644 iac/docker/helm/charts/drupal-fpm/values.yaml create mode 100644 iac/docker/helm/charts/mysql/Chart.yaml create mode 100644 iac/docker/helm/charts/mysql/templates/_helpers.tpl create mode 100644 iac/docker/helm/charts/mysql/templates/mysql-deployment.yaml create mode 100644 iac/docker/helm/charts/mysql/templates/mysql-service.yaml create mode 100644 iac/docker/helm/charts/mysql/values.yaml create mode 100644 iac/docker/helm/charts/ngnix/Chart.yaml create mode 100644 iac/docker/helm/charts/ngnix/templates/_helpers.tpl create mode 100644 iac/docker/helm/charts/ngnix/templates/ingress.yaml create mode 100644 iac/docker/helm/charts/ngnix/templates/ngnix-deployment.yaml create mode 100644 iac/docker/helm/charts/ngnix/templates/ngnix-service.yaml create mode 100644 iac/docker/helm/charts/ngnix/values.yaml create mode 100644 iac/docker/helm/charts/phpmyadmin/Chart.yaml create mode 100644 iac/docker/helm/charts/phpmyadmin/templates/_helpers.tpl create mode 100644 iac/docker/helm/charts/phpmyadmin/templates/phpmyadmin-deployment.yaml create mode 100644 iac/docker/helm/charts/phpmyadmin/templates/phpmyadmin-service.yaml create mode 100644 iac/docker/helm/charts/phpmyadmin/values.yaml diff --git a/iac/docker/helm/charts/drupal-fpm/Chart.yaml b/iac/docker/helm/charts/drupal-fpm/Chart.yaml new file mode 100644 index 0000000..6aa7d43 --- /dev/null +++ b/iac/docker/helm/charts/drupal-fpm/Chart.yaml @@ -0,0 +1,21 @@ +apiVersion: v2 +name: drupal-fpm +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: "0.1.0" diff --git a/iac/docker/helm/charts/drupal-fpm/templates/_helpers.tpl b/iac/docker/helm/charts/drupal-fpm/templates/_helpers.tpl new file mode 100644 index 0000000..536b6ae --- /dev/null +++ b/iac/docker/helm/charts/drupal-fpm/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "drupal-fpm.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 "drupal-fpm.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 "drupal-fpm.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "drupal-fpm.labels" -}} +helm.sh/chart: {{ include "drupal-fpm.chart" . }} +{{ include "drupal-fpm.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "drupal-fpm.selectorLabels" -}} +app.kubernetes.io/name: {{ include "drupal-fpm.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "drupal-fpm.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "drupal-fpm.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/iac/docker/helm/charts/drupal-fpm/templates/deployment.yaml b/iac/docker/helm/charts/drupal-fpm/templates/deployment.yaml new file mode 100644 index 0000000..993c17a --- /dev/null +++ b/iac/docker/helm/charts/drupal-fpm/templates/deployment.yaml @@ -0,0 +1,82 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "drupal-fpm.fullname" . }} + labels: + io.kompose.service: drupal-fpm + {{- include "drupal-fpm.labels" . | nindent 4 }} + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.0 (40646f47) +spec: + replicas: {{ .Values.drupalFpm.replicas }} + selector: + matchLabels: + io.kompose.service: drupal-fpm + {{- include "drupal-fpm.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + app: drupal-fpm + io.kompose.network/external: "true" + io.kompose.network/internal: "true" + io.kompose.service: drupal-fpm + {{- include "drupal-fpm.selectorLabels" . | nindent 8 }} + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.0 (40646f47) + spec: + containers: + - env: + - name: DB_URL + valueFrom: + configMapKeyRef: + key: DB_URL + name: env + - name: DRUPAL_PASSWORD + valueFrom: + configMapKeyRef: + key: DRUPAL_PASSWORD + name: env + - name: DRUPAL_USER + valueFrom: + configMapKeyRef: + key: DRUPAL_USER + name: env + - name: MYSQL_DATABASE + valueFrom: + configMapKeyRef: + key: MYSQL_DATABASE + name: env + - name: MYSQL_PASSWORD + valueFrom: + configMapKeyRef: + key: MYSQL_PASSWORD + name: env + - name: MYSQL_ROOT_PASSWORD + valueFrom: + configMapKeyRef: + key: MYSQL_ROOT_PASSWORD + name: env + - name: MYSQL_USER + valueFrom: + configMapKeyRef: + key: MYSQL_USER + name: env + - name: SITE_NAME + valueFrom: + configMapKeyRef: + key: SITE_NAME + name: env + - name: KS + valueFrom: + configMapKeyRef: + key: KS + name: env + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + image: {{ .Values.drupalFpm.drupalFpm.image.repository }}:{{ .Values.drupalFpm.drupalFpm.image.tag + | default .Chart.AppVersion }} + name: drupal-fpm + resources: {} + restartPolicy: Always \ No newline at end of file diff --git a/iac/docker/helm/charts/drupal-fpm/templates/drupal-fpm.yaml b/iac/docker/helm/charts/drupal-fpm/templates/drupal-fpm.yaml new file mode 100644 index 0000000..d0bf95a --- /dev/null +++ b/iac/docker/helm/charts/drupal-fpm/templates/drupal-fpm.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "drupal-fpm.fullname" . }}-drupal-fpm + labels: + io.kompose.service: drupal-fpm + {{- include "drupal-fpm.labels" . | nindent 4 }} + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.0 (40646f47) +spec: + type: {{ .Values.drupalFpm.type }} + selector: + io.kompose.service: drupal-fpm + {{- include "drupal-fpm.selectorLabels" . | nindent 4 }} + ports: + {{- .Values.drupalFpm.ports | toYaml | nindent 2 -}} + diff --git a/iac/docker/helm/charts/drupal-fpm/values.yaml b/iac/docker/helm/charts/drupal-fpm/values.yaml new file mode 100644 index 0000000..ca6c57f --- /dev/null +++ b/iac/docker/helm/charts/drupal-fpm/values.yaml @@ -0,0 +1,12 @@ +drupalFpm: + drupalFpm: + image: + repository: rishabgit/drupal-docker + tag: php-fpm + replicas: 1 + ports: + - name: "9000" + port: 9000 + targetPort: 9000 + type: ClusterIP +kubernetesClusterDomain: cluster.local diff --git a/iac/docker/helm/charts/mysql/Chart.yaml b/iac/docker/helm/charts/mysql/Chart.yaml new file mode 100644 index 0000000..7ea13a8 --- /dev/null +++ b/iac/docker/helm/charts/mysql/Chart.yaml @@ -0,0 +1,21 @@ +apiVersion: v2 +name: mysql +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: "0.1.0" diff --git a/iac/docker/helm/charts/mysql/templates/_helpers.tpl b/iac/docker/helm/charts/mysql/templates/_helpers.tpl new file mode 100644 index 0000000..f3d6a37 --- /dev/null +++ b/iac/docker/helm/charts/mysql/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "mysql.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 "mysql.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 "mysql.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "mysql.labels" -}} +helm.sh/chart: {{ include "mysql.chart" . }} +{{ include "mysql.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "mysql.selectorLabels" -}} +app.kubernetes.io/name: {{ include "mysql.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "mysql.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "mysql.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/iac/docker/helm/charts/mysql/templates/mysql-deployment.yaml b/iac/docker/helm/charts/mysql/templates/mysql-deployment.yaml new file mode 100644 index 0000000..00ff89a --- /dev/null +++ b/iac/docker/helm/charts/mysql/templates/mysql-deployment.yaml @@ -0,0 +1,78 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mysql + labels: + io.kompose.service: mysql + {{- include "mysql.labels" . | nindent 4 }} + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.0 (40646f47) +spec: + replicas: {{ .Values.mysql.replicas }} + selector: + matchLabels: + io.kompose.service: mysql + {{- include "mysql.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + io.kompose.network/internal: "true" + io.kompose.service: mysql + {{- include "mysql.selectorLabels" . | nindent 8 }} + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.0 (40646f47) + spec: + containers: + - args: {{- toYaml .Values.mysql.mysql.args | nindent 8 }} + env: + - name: DB_URL + valueFrom: + configMapKeyRef: + key: DB_URL + name: env + - name: DRUPAL_PASSWORD + valueFrom: + configMapKeyRef: + key: DRUPAL_PASSWORD + name: env + - name: DRUPAL_USER + valueFrom: + configMapKeyRef: + key: DRUPAL_USER + name: env + - name: MYSQL_DATABASE + valueFrom: + configMapKeyRef: + key: MYSQL_DATABASE + name: env + - name: MYSQL_PASSWORD + valueFrom: + configMapKeyRef: + key: MYSQL_PASSWORD + name: env + - name: MYSQL_ROOT_PASSWORD + valueFrom: + configMapKeyRef: + key: MYSQL_ROOT_PASSWORD + name: env + - name: MYSQL_USER + valueFrom: + configMapKeyRef: + key: MYSQL_USER + name: env + - name: SITE_NAME + valueFrom: + configMapKeyRef: + key: SITE_NAME + name: env + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + image: {{ .Values.mysql.mysql.image.repository }}:{{ .Values.mysql.mysql.image.tag + | default .Chart.AppVersion }} + name: mysql + ports: + - containerPort: 3306 + resources: {} + restartPolicy: Always \ No newline at end of file diff --git a/iac/docker/helm/charts/mysql/templates/mysql-service.yaml b/iac/docker/helm/charts/mysql/templates/mysql-service.yaml new file mode 100644 index 0000000..288a06a --- /dev/null +++ b/iac/docker/helm/charts/mysql/templates/mysql-service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: mysql + labels: + io.kompose.service: mysql + {{- include "mysql.labels" . | nindent 4 }} + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.0 (40646f47) +spec: + type: {{ .Values.mysql.type }} + selector: + io.kompose.service: mysql + {{- include "mysql.selectorLabels" . | nindent 4 }} + ports: + {{- .Values.mysql.ports | toYaml | nindent 2 -}} \ No newline at end of file diff --git a/iac/docker/helm/charts/mysql/values.yaml b/iac/docker/helm/charts/mysql/values.yaml new file mode 100644 index 0000000..c75a5c9 --- /dev/null +++ b/iac/docker/helm/charts/mysql/values.yaml @@ -0,0 +1,14 @@ +kubernetesClusterDomain: cluster.local +mysql: + mysql: + args: + - --default-authentication-plugin=mysql_native_password + image: + repository: mysql + tag: "8.0" + ports: + - name: "3306" + port: 3306 + targetPort: 3306 + replicas: 1 + type: ClusterIP diff --git a/iac/docker/helm/charts/ngnix/Chart.yaml b/iac/docker/helm/charts/ngnix/Chart.yaml new file mode 100644 index 0000000..2997947 --- /dev/null +++ b/iac/docker/helm/charts/ngnix/Chart.yaml @@ -0,0 +1,21 @@ +apiVersion: v2 +name: ngnix +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: "0.1.0" diff --git a/iac/docker/helm/charts/ngnix/templates/_helpers.tpl b/iac/docker/helm/charts/ngnix/templates/_helpers.tpl new file mode 100644 index 0000000..568676e --- /dev/null +++ b/iac/docker/helm/charts/ngnix/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "ngnix.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 "ngnix.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 "ngnix.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "ngnix.labels" -}} +helm.sh/chart: {{ include "ngnix.chart" . }} +{{ include "ngnix.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "ngnix.selectorLabels" -}} +app.kubernetes.io/name: {{ include "ngnix.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "ngnix.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "ngnix.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/iac/docker/helm/charts/ngnix/templates/ingress.yaml b/iac/docker/helm/charts/ngnix/templates/ingress.yaml new file mode 100644 index 0000000..2d46244 --- /dev/null +++ b/iac/docker/helm/charts/ngnix/templates/ingress.yaml @@ -0,0 +1,20 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "ngnix.fullname" . }}-ingress + labels: + {{- include "ngnix.labels" . | nindent 4 }} + annotations: + nginx.ingress.kubernetes.io/rewrite-target: /$1 +spec: + rules: + - host: drupal-local.info + http: + paths: + - backend: + service: + name: '{{ include "ngnix.fullname" . }}-ngnix' + port: + number: 8080 + path: / + pathType: Prefix \ No newline at end of file diff --git a/iac/docker/helm/charts/ngnix/templates/ngnix-deployment.yaml b/iac/docker/helm/charts/ngnix/templates/ngnix-deployment.yaml new file mode 100644 index 0000000..7f51cc9 --- /dev/null +++ b/iac/docker/helm/charts/ngnix/templates/ngnix-deployment.yaml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ngnix + labels: + io.kompose.service: ngnix + {{- include "ngnix.labels" . | nindent 4 }} + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.0 (40646f47) +spec: + replicas: {{ .Values.ngnix.replicas }} + selector: + matchLabels: + io.kompose.service: ngnix + {{- include "ngnix.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + app: ngnix + io.kompose.network/external: "true" + io.kompose.service: ngnix + {{- include "ngnix.selectorLabels" . | nindent 8 }} + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.0 (40646f47) + spec: + containers: + - env: + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + image: {{ .Values.ngnix.ngnix.image.repository }}:{{ .Values.ngnix.ngnix.image.tag + | default .Chart.AppVersion }} + name: ngnix + ports: + - containerPort: 80 + resources: {} + restartPolicy: Always \ No newline at end of file diff --git a/iac/docker/helm/charts/ngnix/templates/ngnix-service.yaml b/iac/docker/helm/charts/ngnix/templates/ngnix-service.yaml new file mode 100644 index 0000000..644e76e --- /dev/null +++ b/iac/docker/helm/charts/ngnix/templates/ngnix-service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: ngnix + labels: + io.kompose.service: ngnix + {{- include "ngnix.labels" . | nindent 4 }} + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.0 (40646f47) +spec: + type: {{ .Values.ngnix.type }} + selector: + io.kompose.service: ngnix + {{- include "ngnix.selectorLabels" . | nindent 4 }} + ports: + {{- .Values.ngnix.ports | toYaml | nindent 2 -}} \ No newline at end of file diff --git a/iac/docker/helm/charts/ngnix/values.yaml b/iac/docker/helm/charts/ngnix/values.yaml new file mode 100644 index 0000000..875cfb0 --- /dev/null +++ b/iac/docker/helm/charts/ngnix/values.yaml @@ -0,0 +1,11 @@ +kubernetesClusterDomain: cluster.local +ngnix: + ngnix: + image: + repository: nginx + tag: alpine-perl + ports: + - port: 80 + targetPort: 80 + replicas: 1 + type: LoadBalancer diff --git a/iac/docker/helm/charts/phpmyadmin/Chart.yaml b/iac/docker/helm/charts/phpmyadmin/Chart.yaml new file mode 100644 index 0000000..ecef4c6 --- /dev/null +++ b/iac/docker/helm/charts/phpmyadmin/Chart.yaml @@ -0,0 +1,21 @@ +apiVersion: v2 +name: phpmyadmin +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: "0.1.0" diff --git a/iac/docker/helm/charts/phpmyadmin/templates/_helpers.tpl b/iac/docker/helm/charts/phpmyadmin/templates/_helpers.tpl new file mode 100644 index 0000000..8cace0f --- /dev/null +++ b/iac/docker/helm/charts/phpmyadmin/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "phpmyadmin.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 "phpmyadmin.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 "phpmyadmin.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "phpmyadmin.labels" -}} +helm.sh/chart: {{ include "phpmyadmin.chart" . }} +{{ include "phpmyadmin.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "phpmyadmin.selectorLabels" -}} +app.kubernetes.io/name: {{ include "phpmyadmin.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "phpmyadmin.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "phpmyadmin.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/iac/docker/helm/charts/phpmyadmin/templates/phpmyadmin-deployment.yaml b/iac/docker/helm/charts/phpmyadmin/templates/phpmyadmin-deployment.yaml new file mode 100644 index 0000000..fa22838 --- /dev/null +++ b/iac/docker/helm/charts/phpmyadmin/templates/phpmyadmin-deployment.yaml @@ -0,0 +1,42 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: phpmyadmin + labels: + io.kompose.service: phpmyadmin + {{- include "phpmyadmin.labels" . | nindent 4 }} + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.0 (40646f47) +spec: + replicas: {{ .Values.phpmyadmin.replicas }} + selector: + matchLabels: + io.kompose.service: phpmyadmin + {{- include "phpmyadmin.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + io.kompose.service: phpmyadmin + {{- include "phpmyadmin.selectorLabels" . | nindent 8 }} + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.0 (40646f47) + spec: + containers: + - env: + - name: PMA_HOST + value: {{ quote .Values.phpmyadmin.phpmyadmin.env.pmaHost }} + - name: PMA_PASSWORD + value: {{ quote .Values.phpmyadmin.phpmyadmin.env.pmaPassword }} + - name: PMA_USER + value: {{ quote .Values.phpmyadmin.phpmyadmin.env.pmaUser }} + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + image: {{ .Values.phpmyadmin.phpmyadmin.image.repository }}:{{ .Values.phpmyadmin.phpmyadmin.image.tag + | default .Chart.AppVersion }} + name: phpmyadmin + ports: + - containerPort: 80 + resources: {} + restartPolicy: Always \ No newline at end of file diff --git a/iac/docker/helm/charts/phpmyadmin/templates/phpmyadmin-service.yaml b/iac/docker/helm/charts/phpmyadmin/templates/phpmyadmin-service.yaml new file mode 100644 index 0000000..bf82847 --- /dev/null +++ b/iac/docker/helm/charts/phpmyadmin/templates/phpmyadmin-service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: phpmyadmin + labels: + io.kompose.service: phpmyadmin + {{- include "phpmyadmin.labels" . | nindent 4 }} + annotations: + kompose.cmd: kompose convert + kompose.version: 1.26.0 (40646f47) +spec: + type: {{ .Values.phpmyadmin.type }} + selector: + io.kompose.service: phpmyadmin + {{- include "phpmyadmin.selectorLabels" . | nindent 4 }} + ports: + {{- .Values.phpmyadmin.ports | toYaml | nindent 2 -}} \ No newline at end of file diff --git a/iac/docker/helm/charts/phpmyadmin/values.yaml b/iac/docker/helm/charts/phpmyadmin/values.yaml new file mode 100644 index 0000000..dcc37b4 --- /dev/null +++ b/iac/docker/helm/charts/phpmyadmin/values.yaml @@ -0,0 +1,16 @@ +kubernetesClusterDomain: cluster.local +phpmyadmin: + phpmyadmin: + env: + pmaHost: mysql + pmaPassword: root_password + pmaUser: root + image: + repository: phpmyadmin/phpmyadmin + tag: latest + ports: + - name: "8080" + port: 8080 + targetPort: 80 + replicas: 1 + type: ClusterIP diff --git a/iac/docker/helm/nginx/ngnix-service.yaml b/iac/docker/helm/nginx/ngnix-service.yaml index 8af8992..6702886 100644 --- a/iac/docker/helm/nginx/ngnix-service.yaml +++ b/iac/docker/helm/nginx/ngnix-service.yaml @@ -9,7 +9,7 @@ metadata: io.kompose.service: ngnix name: ngnix spec: - type: NodePort + type: LoadBalancer ports: - targetPort: 80 port: 80