Skip to content

Commit

Permalink
preliminary work on a apache-nas helm chart (#8) (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmauduit authored Oct 26, 2023
1 parent 0712e8d commit 2c8b16d
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 0 deletions.
23 changes: 23 additions & 0 deletions apache-nas/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
6 changes: 6 additions & 0 deletions apache-nas/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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"
62 changes: 62 additions & 0 deletions apache-nas/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 }}
53 changes: 53 additions & 0 deletions apache-nas/templates/apache-nas-depl.yaml
Original file line number Diff line number Diff line change
@@ -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: {}
14 changes: 14 additions & 0 deletions apache-nas/templates/apache-nas-pvc.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
10 changes: 10 additions & 0 deletions apache-nas/templates/apache-nas-svc.yaml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions apache-nas/values.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2c8b16d

Please sign in to comment.