From 2c8b16dde5cbbd1ce8b3bb7317b63aa09799e2bb Mon Sep 17 00:00:00 2001 From: Pierre Mauduit Date: Thu, 26 Oct 2023 10:42:48 +0200 Subject: [PATCH] preliminary work on a apache-nas helm chart (#8) (#9) --- apache-nas/.helmignore | 23 +++++++++ apache-nas/Chart.yaml | 6 +++ apache-nas/templates/_helpers.tpl | 62 +++++++++++++++++++++++ apache-nas/templates/apache-nas-depl.yaml | 53 +++++++++++++++++++ apache-nas/templates/apache-nas-pvc.yaml | 14 +++++ apache-nas/templates/apache-nas-svc.yaml | 10 ++++ apache-nas/values.yaml | 11 ++++ 7 files changed, 179 insertions(+) create mode 100644 apache-nas/.helmignore create mode 100644 apache-nas/Chart.yaml create mode 100644 apache-nas/templates/_helpers.tpl create mode 100644 apache-nas/templates/apache-nas-depl.yaml create mode 100644 apache-nas/templates/apache-nas-pvc.yaml create mode 100644 apache-nas/templates/apache-nas-svc.yaml create mode 100644 apache-nas/values.yaml diff --git a/apache-nas/.helmignore b/apache-nas/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/apache-nas/.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/apache-nas/Chart.yaml b/apache-nas/Chart.yaml new file mode 100644 index 0000000..b16ae09 --- /dev/null +++ b/apache-nas/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: apache-nas +description: A Helm chart for deploying a Apache-httpd server +type: application +version: 0.1.0 +appVersion: "1.16.0" diff --git a/apache-nas/templates/_helpers.tpl b/apache-nas/templates/_helpers.tpl new file mode 100644 index 0000000..9e6d4fb --- /dev/null +++ b/apache-nas/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "apache-nas.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 "apache-nas.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 "apache-nas.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "apache-nas.labels" -}} +helm.sh/chart: {{ include "apache-nas.chart" . }} +{{ include "apache-nas.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "apache-nas.selectorLabels" -}} +app.kubernetes.io/name: {{ include "apache-nas.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "apache-nas.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "apache-nas.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/apache-nas/templates/apache-nas-depl.yaml b/apache-nas/templates/apache-nas-depl.yaml new file mode 100644 index 0000000..a201a5d --- /dev/null +++ b/apache-nas/templates/apache-nas-depl.yaml @@ -0,0 +1,53 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + creationTimestamp: null + labels: + app.camptocamp.com/name: apache-nas + name: apache-nas +spec: + replicas: 1 + selector: + matchLabels: + app.camptocamp.com/name: apache-nas + strategy: {} + template: + metadata: + creationTimestamp: null + labels: + app.camptocamp.com/name: apache-nas + spec: + containers: + - image: {{ .Values.docker_image }} + name: apache-nas + resources: {} + {{- with .Values.env_variables }} + env: + {{- toYaml . | nindent 8 }} + {{- end }} + volumeMounts: + - name: apache-nas-data + mountPath: /var/www/html + command: + - /bin/bash + args: + - -c + - apt update ; + apt install -y libpq-dev ssmtp ; + sed -i "s/mailhub=mail/mailhub=georchestra-smtp-svc/" /etc/ssmtp/ssmtp.conf ; + sed -i 's/#FromLineOverride=YES/FromLineOverride=YES/' /etc/ssmtp/ssmtp.conf ; + printf "[mail function]\nsendmail_path = /usr/sbin/ssmtp -t\n" > /usr/local/etc/php/conf.d/sendmail.ini ; + docker-php-ext-install pgsql pdo_pgsql ; + apt-get clean ; + rm -rf /var/lib/apt/lists/* ; + groupmod --gid 999 www-data ; + usermod --non-unique --uid 999 --gid 999 www-data ; + chown -R www-data /run/apache2 /run/lock/apache2 /var/cache/apache2/mod_cache_disk /var/log/apache2 ; + printf "upload_max_filesize=50M\npost_max_size=50M\n" > /usr/local/etc/php/conf.d/upload-size-customizations.ini ; + a2enmod rewrite ; + exec apache2-foreground + volumes: + - name: apache-nas-data + persistentVolumeClaim: + claimName: {{ .Values.nas.volume.pvc_name }} +status: {} diff --git a/apache-nas/templates/apache-nas-pvc.yaml b/apache-nas/templates/apache-nas-pvc.yaml new file mode 100644 index 0000000..6030c91 --- /dev/null +++ b/apache-nas/templates/apache-nas-pvc.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Values.nas.volume.pvc_name }} + labels: + app.camptocamp.com/name: apache-nas +spec: + accessModes: + - ReadWriteOnce + storageClassName: {{ .Values.nas.volume.storage_class_name }} + volumeName: {{ .Values.nas.volume.pv_name }} + resources: + requests: + storage: {{ .Values.nas.volume.storage_size }} diff --git a/apache-nas/templates/apache-nas-svc.yaml b/apache-nas/templates/apache-nas-svc.yaml new file mode 100644 index 0000000..e8d69f5 --- /dev/null +++ b/apache-nas/templates/apache-nas-svc.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Service +metadata: + name: apache-nas-svc +spec: + selector: + app.camptocamp.com/name: apache-nas + ports: + - port: 80 + targetPort: 80 diff --git a/apache-nas/values.yaml b/apache-nas/values.yaml new file mode 100644 index 0000000..62dd498 --- /dev/null +++ b/apache-nas/values.yaml @@ -0,0 +1,11 @@ +--- +nas: + volume: + pv_name: c2c-com-apache-nas-data + pvc_name: apache-nas-data + storage_class_name: local + storage_size: 5Gi + +env_variables: [] + +docker_image: php:7.4-apache