Skip to content

Commit

Permalink
#36 - Helm Charts Added
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabjasrotia committed Jan 22, 2024
1 parent 8307239 commit 4947df0
Show file tree
Hide file tree
Showing 22 changed files with 715 additions and 1 deletion.
21 changes: 21 additions & 0 deletions 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"
62 changes: 62 additions & 0 deletions 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 }}
82 changes: 82 additions & 0 deletions 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
18 changes: 18 additions & 0 deletions 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 -}}

12 changes: 12 additions & 0 deletions 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
21 changes: 21 additions & 0 deletions 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"
62 changes: 62 additions & 0 deletions 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 }}
78 changes: 78 additions & 0 deletions 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
17 changes: 17 additions & 0 deletions 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 -}}
14 changes: 14 additions & 0 deletions 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

0 comments on commit 4947df0

Please sign in to comment.