[stable/moodle] ingress,existingClaims,affinity,ImageVerUpdate,singleMountPoint (#1534)

- adds `Ingress` controller support
 - defines single mountpoint for persistence at `/bitnami`
 - adds support for `existingClaim`, `affinity`, etc.
This commit is contained in:
ReSearchITEng
2017-07-25 11:04:11 +05:30
committed by Sameer Naik
parent 7af81dc53e
commit f7c408d4e5
9 changed files with 242 additions and 86 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
name: moodle
version: 0.1.11
version: 0.2.0
appVersion: 3.3.1
description: Moodle is a learning platform designed to provide educators, administrators and learners with a single robust, secure and integrated system to create personalised learning environments
keywords:
+82 -27
View File
@@ -45,32 +45,38 @@ The command removes all the Kubernetes components associated with the chart and
The following tables lists the configurable parameters of the Moodle chart and their default values.
| Parameter | Description | Default |
|------------------------------------|----------------------------------------|---------------------------------------------|
| `image` | Moodle image | `bitnami/moodle:{VERSION}` |
| `imagePullPolicy` | Image pull policy | `IfNotPresent` |
| `moodleUsername` | User of the application | `user` |
| `moodlePassword` | Application password | _random 10 character alphanumeric string_ |
| `moodleEmail` | Admin email | `user@example.com` |
| `smtpHost` | SMTP host | `nil` |
| `smtpPort` | SMTP port | `nil` |
| `smtpProtocol` | SMTP Protocol | `nil` |
| `smtpUser` | SMTP user | `nil` |
| `smtpPassword` | SMTP password | `nil` |
| `serviceType` | Kubernetes Service type | `LoadBalancer` |
| `resources` | CPU/Memory resource requests/limits | Memory: `512Mi`, CPU: `300m` |
| `persistence.enabled` | Enable persistence using PVC | `true` |
| `persistence.apache.storageClass` | PVC Storage Class for Apache volume | `nil` (uses alpha storage class annotation) |
| `persistence.apache.accessMode` | PVC Access Mode for Apache volume | `ReadWriteOnce` |
| `persistence.apache.size` | PVC Storage Request for Apache volume | `1Gi` |
| `persistence.moodle.storageClass` | PVC Storage Class for Moodle volume | `nil` (uses alpha storage class annotation) |
| `persistence.moodle.accessMode` | PVC Access Mode for Moodle volume | `ReadWriteOnce` |
| `persistence.moodle.size` | PVC Storage Request for Moodle volume | `8Gi` |
| `mariadb.mariadbRootPassword` | MariaDB admin password | `nil` (uses alpha storage class annotation) |
| `mariadb.persistence.enabled` | Enable MariaDB persistence using PVC | `true` |
| `mariadb.persistence.storageClass` | PVC Storage Class for MariaDB volume | `generic` |
| `mariadb.persistence.accessMode` | PVC Access Mode for MariaDB volume | `ReadWriteOnce` |
| `mariadb.persistence.size` | PVC Storage Request for MariaDB volume | `8Gi` |
| Parameter | Description | Default |
|-------------------------------------|-----------------------------------------|---------------------------------------------|
| `image` | Moodle image | `bitnami/moodle:{VERSION}` |
| `imagePullPolicy` | Image pull policy | `IfNotPresent` |
| `moodleUsername` | User of the application | `user` |
| `moodlePassword` | Application password | _random 10 character alphanumeric string_ |
| `moodleEmail` | Admin email | `user@example.com` |
| `smtpHost` | SMTP host | `nil` |
| `smtpPort` | SMTP port | `nil` (but moodle internal default is 25) |
| `smtpProtocol` | SMTP Protocol (options: ssl,tls, nil) | `nil` |
| `smtpUser` | SMTP user | `nil` |
| `smtpPassword` | SMTP password | `nil` |
| `serviceType` | Kubernetes Service type | `LoadBalancer` |
| `ingress.enabled` | If ingress should be created | `false` |
| `ingress.annotations` | Any ingress annotations | `nil` |
| `ingress.hosts` | List of Ingress hosts | `nil` |
| `ingress.tls` | List of certs. If defined, https is set | `nil` |
| `affinity` | Set affinity for the moodle pods | `nil` |
| `resources` | CPU/Memory resource requests/limits | Memory: `512Mi`, CPU: `300m` |
| `persistence.enabled` | Enable persistence using PVC | `true` |
| `persistence.storageClass` | PVC Storage Class for Moodle volume | `nil` (uses alpha storage class annotation) |
| `persistence.accessMode` | PVC Access Mode for Moodle volume | `ReadWriteOnce` |
| `persistence.size` | PVC Storage Request for Moodle volume | `8Gi` |
| `persistence.existingClaim` | If PVC exists&bounded for Moodle | `nil` (when nil, new one is requested) |
| `mariadb.mariadbRootPassword` | MariaDB admin password | `nil` (uses alpha storage class annotation) |
| `mariadb.persistence.enabled` | Enable MariaDB persistence using PVC | `true` |
| `mariadb.persistence.storageClass` | PVC Storage Class for MariaDB volume | `generic` |
| `mariadb.persistence.accessMode` | PVC Access Mode for MariaDB volume | `ReadWriteOnce` |
| `mariadb.persistence.size` | PVC Storage Request for MariaDB volume | `8Gi` |
| `mariadb.persistence.existingClaim` | If PVC exists&bounded for MariaDB | `nil` (when nil, new one is requested) |
| `mariadb.affinity` | Set affinity for the MariaDB pods | `nil` |
| `mariadb.resources` | CPU/Memory resource requests/limits | Memory: `256Mi`, CPU: `250m` |
The above parameters map to the env variables defined in [bitnami/moodle](http://github.com/bitnami/bitnami-docker-moodle). For more information please refer to the [bitnami/moodle](http://github.com/bitnami/bitnami-docker-moodle) image documentation.
@@ -92,9 +98,58 @@ $ helm install --name my-release -f values.yaml stable/moodle
> **Tip**: You can use the default [values.yaml](values.yaml)
### Ingress without TLS
For using ingress (example without tls):
```console
$ helm install --name my-release \
--set ingress.enabled=True,ingress.hosts[0]=moodle.domain.com,serviceType=ClusterIP,moodleUsername=admin,moodlePassword=password,mariadb.mariadbRootPassword=secretpassword stable/moodle
```
These are the *3 mandatory parameters* when *Ingress* is desired:
`ingress.enabled=True,ingress.hosts[0]=moodle.domain.com,serviceType=ClusterIP`
### Ingress TLS
If your cluster allows automatic creation/retrieval of TLS certificates (e.g. [kube-lego](https://github.com/jetstack/kube-lego)), please refer to the documentation for that mechanism.
To manually configure TLS, first create/retrieve a key & certificate pair for the address(es) you wish to protect. Then create a TLS secret in the namespace:
```console
$ kubectl create secret tls moodle-server-tls --cert=path/to/tls.cert --key=path/to/tls.key
```
Include the secret's name, along with the desired hostnames, in the Ingress TLS section of your custom `values.yaml` file:
```console
ingress:
## If true, Moodle server Ingress will be created
##
enabled: true
## Moodle server Ingress annotations
##
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: 'true'
## Moodle server Ingress hostnames
## Must be provided if Ingress is enabled
##
hosts:
- moodle.domain.com
## Moodle server Ingress TLS configuration
## Secrets must be manually created in the namespace
##
tls:
- secretName: moodle-server-tls
hosts:
- moodle.domain.com
```
## Persistence
The [Bitnami Moodle](https://github.com/bitnami/bitnami-docker-moodle) image stores the Moodle data and configurations at the `/bitnami/moodle` and `/bitnami/apache` paths of the container.
Persistent Volume Claims are used to keep the data across deployments. This is known to work in GCE, AWS, and minikube.
Persistent Volume Claims are used to keep the data across deployments. This is known to work in GCE, AWS, vpshere, and minikube.
See the [Configuration](#configuration) section to configure the PVC or to disable persistence.
You may want to review the [PV reclaim policy](https://kubernetes.io/docs/tasks/administer-cluster/change-pv-reclaim-policy/), and update as required. By default it's set to delete, and when moodle is uninstalled, data is also removed.
+15 -3
View File
@@ -1,10 +1,22 @@
** Please be patient while the chart is being deployed **
{{- if and .Values.ingress.enabled (ne .Values.serviceType "ClusterIP") }}
** Notice : Usually with ingress the serviceType should be set to ClusterIP, which is not the case to this deployment! **
{{- end }}
1. Get the Moodle URL by running:
{{- if contains "NodePort" .Values.serviceType }}
1. Access you Moodle instance with:
{{- if .Values.ingress.enabled }}
{{ if .Values.ingress.tls }}
{{- range .Values.ingress.hosts }}
- https://{{ . }}
{{- end }}
{{- else }}
{{- range .Values.ingress.hosts }}
- http://{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.serviceType }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT/
+10
View File
@@ -22,3 +22,13 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this
{{- define "mariadb.fullname" -}}
{{- printf "%s-%s" .Release.Name "mariadb" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "moodle.fullname" -}}
{{- printf "%s-%s" .Release.Name "moodle" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
+6 -11
View File
@@ -13,6 +13,10 @@ spec:
labels:
app: {{ template "fullname" . }}
spec:
{{- if .Values.affinity }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
containers:
- name: {{ template "fullname" . }}
image: "{{ .Values.image }}"
@@ -72,21 +76,12 @@ spec:
{{ toYaml .Values.resources | indent 10 }}
volumeMounts:
- name: moodle-data
mountPath: /bitnami/moodle
- name: apache-data
mountPath: /bitnami/apache
mountPath: /bitnami
volumes:
- name: moodle-data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ template "fullname" . }}-moodle
{{- else }}
emptyDir: {}
{{- end }}
- name: apache-data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ template "fullname" . }}-apache
claimName: {{ .Values.persistence.existingClaim | default (include "moodle.fullname" . ) }}
{{- else }}
emptyDir: {}
{{- end }}
+38
View File
@@ -0,0 +1,38 @@
{{- if .Values.ingress.enabled -}}
{{- $releaseName := .Release.Name -}}
{{- $serviceName := include "fullname" . }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
{{- if .Values.ingress.annotations }}
annotations:
{{ toYaml .Values.ingress.annotations | indent 4}}
{{- end }}
labels:
app: {{ template "fullname" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
component: "{{ .Values.name }}"
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
name: {{ template "fullname" . }}
spec:
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . }}
http:
paths:
- backend:
serviceName: {{ $serviceName }}
servicePort: 80
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
backend:
serviceName: {{ $serviceName }}
servicePort: 80
{{- end -}}
{{- end -}}
-23
View File
@@ -1,23 +0,0 @@
{{- if .Values.persistence.enabled -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "fullname" . }}-moodle
labels:
app: {{ template "fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
annotations:
{{- if .Values.persistence.moodle.storageClass }}
volume.beta.kubernetes.io/storage-class: {{ .Values.persistence.moodle.storageClass | quote }}
{{- else }}
volume.alpha.kubernetes.io/storage-class: default
{{- end }}
spec:
accessModes:
- {{ .Values.persistence.moodle.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.moodle.size | quote }}
{{- end -}}
@@ -1,23 +1,23 @@
{{- if .Values.persistence.enabled -}}
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "fullname" . }}-apache
name: {{ template "fullname" . }}
labels:
app: {{ template "fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
annotations:
{{- if .Values.persistence.apache.storageClass }}
volume.beta.kubernetes.io/storage-class: {{ .Values.persistence.apache.storageClass | quote }}
{{- if .Values.persistence.storageClass }}
volume.beta.kubernetes.io/storage-class: {{ .Values.persistence.storageClass | quote }}
{{- else }}
volume.alpha.kubernetes.io/storage-class: default
{{- end }}
spec:
accessModes:
- {{ .Values.persistence.apache.accessMode | quote }}
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.apache.size | quote }}
storage: {{ .Values.persistence.size | quote }}
{{- end -}}
+84 -15
View File
@@ -52,31 +52,100 @@ mariadb:
# storageClass:
accessMode: ReadWriteOnce
size: 8Gi
# existingClaim: ""
## Define affinity for the pod
## Sometimes required when persistent volumes are defined externally
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
# affinity:
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: node-role.kubernetes.io/master
# operator: Exists
# values:
# - machine01
# preferredDuringSchedulingIgnoredDuringExecution:
# - weight: 1
# preference:
# matchExpressions:
# - key: another-node-label-key
# operator: In
# values:
# - another-node-label-value
#
# resources:
# requests:
# memory: 768Mi
# cpu: 750m
## Kubernetes configuration
## For minikube, set this to NodePort, elsewhere use LoadBalancer
## For minikube, set this to NodePort, for ingress ClusterIP, elsewhere use LoadBalancer
##
serviceType: LoadBalancer
## Optionally, create ingress controller
ingress:
## If true, Moodle server Ingress will be created
##
enabled: false
## Moodle server Ingress annotations
##
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: 'true'
## Moodle server Ingress hostnames
## Must be provided if Ingress is enabled
##
hosts: []
# - moodle.domain.com
## Moodle server Ingress TLS configuration
## Secrets must be manually created in the namespace
## kubectl create secret tls moodle-server-tls --cert=tls.crt --key=tls.key
##
tls: []
# - secretName: moodle-server-tls
# hosts:
# - moodle.domain.com
## Enable persistence using Persistent Volume Claims
## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
##
persistence:
enabled: true
apache:
## If defined, volume.beta.kubernetes.io/storage-class: <storageClass>
## Default: volume.alpha.kubernetes.io/storage-class: default
##
# storageClass:
accessMode: ReadWriteOnce
size: 1Gi
moodle:
## If defined, volume.beta.kubernetes.io/storage-class: <storageClass>
## Default: volume.alpha.kubernetes.io/storage-class: default
##
# storageClass:
accessMode: ReadWriteOnce
size: 8Gi
## If defined, volume.beta.kubernetes.io/storage-class: <storageClass>
## Default: volume.alpha.kubernetes.io/storage-class: default
##
# storageClass:
accessMode: ReadWriteOnce
size: 8Gi
#existingClaim: ""
## Define affinity for the moodle pod
## Sometimes required when persistent volumes are defined externally
## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
# affinity:
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: node-role.kubernetes.io/master
# operator: In
# values:
# - machine01
# preferredDuringSchedulingIgnoredDuringExecution:
# - weight: 1
# preference:
# matchExpressions:
# - key: another-node-label-key
# operator: In
# values:
# - another-node-label-value
## Configure resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/