From 32b78af930d5355a5251bd200eac6859671cc606 Mon Sep 17 00:00:00 2001 From: Martyn Date: Thu, 7 Dec 2023 15:28:12 +0000 Subject: [PATCH] Add the old drupal site --- apps-helm/drupal/.helmignore | 23 +++++ apps-helm/drupal/Chart.yaml | 24 +++++ apps-helm/drupal/templates/_helpers.tpl | 62 +++++++++++++ apps-helm/drupal/templates/deployment.yaml | 91 +++++++++++++++++++ apps-helm/drupal/templates/hpa.yaml | 28 ++++++ apps-helm/drupal/templates/ingress.yaml | 63 +++++++++++++ apps-helm/drupal/templates/pvc.yaml | 22 +++++ apps-helm/drupal/templates/service.yaml | 15 +++ .../drupal/templates/serviceaccount.yaml | 12 +++ .../templates/tests/test-connection.yaml | 15 +++ apps-helm/drupal/values.yaml | 86 ++++++++++++++++++ everything-app/bikerwitch.yaml | 45 +++++++++ 12 files changed, 486 insertions(+) create mode 100644 apps-helm/drupal/.helmignore create mode 100644 apps-helm/drupal/Chart.yaml create mode 100644 apps-helm/drupal/templates/_helpers.tpl create mode 100644 apps-helm/drupal/templates/deployment.yaml create mode 100644 apps-helm/drupal/templates/hpa.yaml create mode 100644 apps-helm/drupal/templates/ingress.yaml create mode 100644 apps-helm/drupal/templates/pvc.yaml create mode 100644 apps-helm/drupal/templates/service.yaml create mode 100644 apps-helm/drupal/templates/serviceaccount.yaml create mode 100644 apps-helm/drupal/templates/tests/test-connection.yaml create mode 100644 apps-helm/drupal/values.yaml create mode 100644 everything-app/bikerwitch.yaml diff --git a/apps-helm/drupal/.helmignore b/apps-helm/drupal/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/apps-helm/drupal/.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/apps-helm/drupal/Chart.yaml b/apps-helm/drupal/Chart.yaml new file mode 100644 index 0000000..9924eff --- /dev/null +++ b/apps-helm/drupal/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: drupal +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/apps-helm/drupal/templates/_helpers.tpl b/apps-helm/drupal/templates/_helpers.tpl new file mode 100644 index 0000000..e134a2b --- /dev/null +++ b/apps-helm/drupal/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "drupal.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.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.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "drupal.labels" -}} +helm.sh/chart: {{ include "drupal.chart" . }} +{{ include "drupal.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "drupal.selectorLabels" -}} +app.kubernetes.io/name: {{ include "drupal.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "drupal.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "drupal.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/apps-helm/drupal/templates/deployment.yaml b/apps-helm/drupal/templates/deployment.yaml new file mode 100644 index 0000000..640b8cb --- /dev/null +++ b/apps-helm/drupal/templates/deployment.yaml @@ -0,0 +1,91 @@ +{{- $fullName := include "drupal.fullname" . -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "drupal.fullname" . }} + labels: + {{- include "drupal.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "drupal.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "drupal.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "drupal.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + initContainers: + - name: init-sites-volume + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + command: ['/bin/bash', '-c'] + args: ['cp -r /var/www/html/sites/ /data/; chown www-data:www-data /data/ -R'] + volumeMounts: + - mountPath: /data + name: data + 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: 80 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: /var/www/html/modules + name: data + subPath: modules + - mountPath: /var/www/html/profiles + name: data + subPath: profiles + - mountPath: /var/www/html/sites + name: data + subPath: sites + - mountPath: /var/www/html/themes + name: data + subPath: themes + volumes: + - name: data + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ .Values.persistence.existingClaim | default ( print $fullName "-data") }} + {{- else }} + emptyDir: {} + {{- 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/apps-helm/drupal/templates/hpa.yaml b/apps-helm/drupal/templates/hpa.yaml new file mode 100644 index 0000000..0ef0b99 --- /dev/null +++ b/apps-helm/drupal/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "drupal.fullname" . }} + labels: + {{- include "drupal.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "drupal.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/apps-helm/drupal/templates/ingress.yaml b/apps-helm/drupal/templates/ingress.yaml new file mode 100644 index 0000000..0afab72 --- /dev/null +++ b/apps-helm/drupal/templates/ingress.yaml @@ -0,0 +1,63 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "drupal.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- 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 "drupal.labels" . | indent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.ingressClassName }} + ingressClassName: {{ .Values.ingress.ingressClassName }} +{{- end }} +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + pathType: ImplementationSpecific + {{- end }} + {{- end -}} + {{- else -}} + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end -}} +{{- end }} \ No newline at end of file diff --git a/apps-helm/drupal/templates/pvc.yaml b/apps-helm/drupal/templates/pvc.yaml new file mode 100644 index 0000000..2808993 --- /dev/null +++ b/apps-helm/drupal/templates/pvc.yaml @@ -0,0 +1,22 @@ +{{- if .Values.persistence.enabled -}} +{{- $fullName := include "drupal.fullname" . -}} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + labels: + {{- include "drupal.labels" . | nindent 4 }} + name: {{ $fullName }}-data +spec: + accessModes: + - ReadWriteOnce +{{- if .Values.persistence.storageClass }} +{{- if (eq "-" .Values.persistence.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" +{{- end }} +{{- end }} + resources: + requests: + storage: {{ .Values.persistence.size }} +{{ end }} diff --git a/apps-helm/drupal/templates/service.yaml b/apps-helm/drupal/templates/service.yaml new file mode 100644 index 0000000..237a46e --- /dev/null +++ b/apps-helm/drupal/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "drupal.fullname" . }} + labels: + {{- include "drupal.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "drupal.selectorLabels" . | nindent 4 }} diff --git a/apps-helm/drupal/templates/serviceaccount.yaml b/apps-helm/drupal/templates/serviceaccount.yaml new file mode 100644 index 0000000..f7329e2 --- /dev/null +++ b/apps-helm/drupal/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "drupal.serviceAccountName" . }} + labels: + {{- include "drupal.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/apps-helm/drupal/templates/tests/test-connection.yaml b/apps-helm/drupal/templates/tests/test-connection.yaml new file mode 100644 index 0000000..40be4fc --- /dev/null +++ b/apps-helm/drupal/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "drupal.fullname" . }}-test-connection" + labels: + {{- include "drupal.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "drupal.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/apps-helm/drupal/values.yaml b/apps-helm/drupal/values.yaml new file mode 100644 index 0000000..45c1504 --- /dev/null +++ b/apps-helm/drupal/values.yaml @@ -0,0 +1,86 @@ +# Default values for drupal. +# 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: "" + +persistence: + enabled: false + size: 1Gi + +serviceAccount: + # Specifies whether a service account should be created + create: 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: {} + +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 + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/everything-app/bikerwitch.yaml b/everything-app/bikerwitch.yaml new file mode 100644 index 0000000..e78625c --- /dev/null +++ b/everything-app/bikerwitch.yaml @@ -0,0 +1,45 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: bikerwitch + namespace: argocd +spec: + destination: + namespace: bikerwitch + server: https://kubernetes.default.svc + project: default + source: + helm: + parameters: + - name: service.type + value: LoadBalancer + - name: persistence.enabled + value: "true" + - name: persistence.storageClass + value: "rook-ceph-block-ssd" + - name: image.repository + value: drupal + - name: image.tag + value: 9.4-php8.0-apache + values: |- + ingress: + enabled: true + annotations: + cert-manager.io/cluster-issuer: letsencrypt + kubernetes.io/ingress.class: nginx + external-dns.alpha.kubernetes.io/target: armnleg.martyn.berlin + hosts: + - host: bikerwitch.martyn.berlin + paths: + - / + - host: www.bikerwitch.org.uk + paths: + - / + tls: + - secretName: bikerwitch-tls + hosts: + - bikerwitch.martyn.berlin + - www.bikerwitch.org.uk + path: apps-helm/drupal + repoURL: https://git.martyn.berlin/martyn/infra4talos.git + targetRevision: HEAD