diff --git a/stable/moodle/.helmignore b/stable/moodle/.helmignore new file mode 100644 index 000000000000..f0c131944441 --- /dev/null +++ b/stable/moodle/.helmignore @@ -0,0 +1,21 @@ +# 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 +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/stable/moodle/Chart.yaml b/stable/moodle/Chart.yaml new file mode 100644 index 000000000000..8af6828fc593 --- /dev/null +++ b/stable/moodle/Chart.yaml @@ -0,0 +1,15 @@ +name: moodle +version: 0.1.2 +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: +- moodle +- learning +- php +home: http://www.moodle.org/ +sources: +- https://github.com/bitnami/bitnami-docker-moodle +maintainers: +- name: Bitnami + email: containers@bitnami.com +engine: gotpl +icon: https://bitnami.com/assets/stacks/moodle/img/moodle-stack-110x117.png diff --git a/stable/moodle/README.md b/stable/moodle/README.md new file mode 100644 index 000000000000..bd5ffbe68a50 --- /dev/null +++ b/stable/moodle/README.md @@ -0,0 +1,100 @@ +# Moodle + +[Moodle](https://www.moodle.org) 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 + +## TL;DR; + +```console +$ helm install stable/moodle +``` + +## Introduction + +This chart bootstraps a [Moodle](https://github.com/bitnami/bitnami-docker-moodle) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +It also packages the [Bitnami MariaDB chart](https://github.com/kubernetes/charts/tree/master/stable/mariadb) which is required for bootstrapping a MariaDB deployment for the database requirements of the Moodle application. + +## Prerequisites + +- Kubernetes 1.4+ with Beta APIs enabled +- PV provisioner support in the underlying infrastructure + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +$ helm install --name my-release stable/moodle +``` + +The command deploys Moodle on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + +> **Tip**: List all releases using `helm list` + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```console +$ helm delete my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +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` | + +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. + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```console +$ helm install --name my-release \ + --set moodleUsername=admin,moodlePassword=password,mariadb.mariadbRootPassword=secretpassword \ + stable/moodle +``` + +The above command sets the Moodle administrator account username and password to `admin` and `password` respectively. Additionally it sets the MariaDB `root` user password to `secretpassword`. + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, + +```console +$ helm install --name my-release -f values.yaml stable/moodle +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) + +## 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. +See the [Configuration](#configuration) section to configure the PVC or to disable persistence. diff --git a/stable/moodle/requirements.lock b/stable/moodle/requirements.lock new file mode 100644 index 000000000000..5f6c228b1bf5 --- /dev/null +++ b/stable/moodle/requirements.lock @@ -0,0 +1,9 @@ +dependencies: +- condition: "" + enabled: false + name: mariadb + repository: https://kubernetes-charts.storage.googleapis.com/ + tags: null + version: 0.5.10 +digest: sha256:ffd85614e09ad85c32cff0ab8a60aaf8780c3aaa3c7c46d80548973818bf12d3 +generated: 2017-03-10T09:44:49.316375601+05:30 diff --git a/stable/moodle/requirements.yaml b/stable/moodle/requirements.yaml new file mode 100644 index 000000000000..9303bd388a42 --- /dev/null +++ b/stable/moodle/requirements.yaml @@ -0,0 +1,4 @@ +dependencies: +- name: mariadb + version: 0.5.x + repository: https://kubernetes-charts.storage.googleapis.com/ diff --git a/stable/moodle/templates/NOTES.txt b/stable/moodle/templates/NOTES.txt new file mode 100644 index 000000000000..220c67d7c5d3 --- /dev/null +++ b/stable/moodle/templates/NOTES.txt @@ -0,0 +1,29 @@ + +** Please be patient while the chart is being deployed ** + +1. Get the Moodle URL by running: + +{{- 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/ + +{{- else if contains "LoadBalancer" .Values.serviceType }} + +** Please ensure an external IP is associated to the {{ template "fullname" . }} service before proceeding ** +** Watch the status using: kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "fullname" . }} ** + + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP/ +{{- else if contains "ClusterIP" .Values.serviceType }} + + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "fullname" . }}" -o jsonpath="{.items[0].metadata.name}") + echo http://127.0.0.1:8080/ + kubectl port-forward $POD_NAME 8080:80 +{{- end }} + +2. Login with the following credentials + + echo Username: {{ .Values.moodleUsername }} + echo Password: $(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath="{.data.moodle-password}" | base64 --decode) diff --git a/stable/moodle/templates/_helpers.tpl b/stable/moodle/templates/_helpers.tpl new file mode 100644 index 000000000000..3d76d82dd670 --- /dev/null +++ b/stable/moodle/templates/_helpers.tpl @@ -0,0 +1,24 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "name" -}} +{{- default .Chart.Name .Values.nameOverride | 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 "fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | 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 "mariadb.fullname" -}} +{{- printf "%s-%s" .Release.Name "mariadb" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/stable/moodle/templates/apache-pvc.yaml b/stable/moodle/templates/apache-pvc.yaml new file mode 100644 index 000000000000..166feb8b9f47 --- /dev/null +++ b/stable/moodle/templates/apache-pvc.yaml @@ -0,0 +1,23 @@ +{{- if .Values.persistence.enabled -}} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ template "fullname" . }}-apache + 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 }} + {{- else }} + volume.alpha.kubernetes.io/storage-class: default + {{- end }} +spec: + accessModes: + - {{ .Values.persistence.apache.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.apache.size | quote }} +{{- end -}} diff --git a/stable/moodle/templates/deployment.yaml b/stable/moodle/templates/deployment.yaml new file mode 100644 index 000000000000..f66a41c5248c --- /dev/null +++ b/stable/moodle/templates/deployment.yaml @@ -0,0 +1,90 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + template: + metadata: + labels: + app: {{ template "fullname" . }} + spec: + containers: + - name: {{ template "fullname" . }} + image: "{{ .Values.image }}" + imagePullPolicy: {{ default "" .Values.imagePullPolicy | quote }} + env: + - name: MARIADB_HOST + value: {{ template "mariadb.fullname" . }} + - name: MARIADB_PORT + value: "3306" + - name: MARIADB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "mariadb.fullname" . }} + key: mariadb-root-password + - name: MOODLE_USERNAME + value: {{ default "" .Values.moodleUsername | quote }} + - name: MOODLE_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "fullname" . }} + key: moodle-password + - name: MOODLE_EMAIL + value: {{ default "" .Values.moodleEmail | quote }} + - name: SMTP_HOST + value: {{ default "" .Values.smtpHost | quote }} + - name: SMTP_PORT + value: {{ default "" .Values.smtpPort | quote }} + - name: SMTP_USER + value: {{ default "" .Values.smtpUser | quote }} + - name: SMTP_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "fullname" . }} + key: smtp-password + - name: SMTP_PROTOCOL + value: {{ default "" .Values.smtpProtocol | quote }} + ports: + - name: http + containerPort: 80 + - name: https + containerPort: 443 + livenessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 120 + timeoutSeconds: 5 + readinessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 5 + timeoutSeconds: 1 + resources: +{{ toYaml .Values.resources | indent 10 }} + volumeMounts: + - name: moodle-data + mountPath: /bitnami/moodle + - name: apache-data + mountPath: /bitnami/apache + 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 + {{- else }} + emptyDir: {} + {{- end }} diff --git a/stable/moodle/templates/moodle-pvc.yaml b/stable/moodle/templates/moodle-pvc.yaml new file mode 100644 index 000000000000..493dafaf7254 --- /dev/null +++ b/stable/moodle/templates/moodle-pvc.yaml @@ -0,0 +1,23 @@ +{{- 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 -}} diff --git a/stable/moodle/templates/secrets.yaml b/stable/moodle/templates/secrets.yaml new file mode 100644 index 000000000000..2f560227088e --- /dev/null +++ b/stable/moodle/templates/secrets.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +type: Opaque +data: + {{ if .Values.moodlePassword }} + moodle-password: {{ default "" .Values.moodlePassword | b64enc | quote }} + {{ else }} + moodle-password: {{ randAlphaNum 10 | b64enc | quote }} + {{ end }} + smtp-password: {{ default "" .Values.smtpPassword | b64enc | quote }} diff --git a/stable/moodle/templates/svc.yaml b/stable/moodle/templates/svc.yaml new file mode 100644 index 000000000000..6736e047692a --- /dev/null +++ b/stable/moodle/templates/svc.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + type: {{ .Values.serviceType }} + ports: + - name: http + port: 80 + targetPort: http + - name: https + port: 443 + targetPort: https + selector: + app: {{ template "fullname" . }} diff --git a/stable/moodle/values.yaml b/stable/moodle/values.yaml new file mode 100644 index 000000000000..12f713986ebf --- /dev/null +++ b/stable/moodle/values.yaml @@ -0,0 +1,87 @@ +## Bitnami Moodle` image version +## ref: https://hub.docker.com/r/bitnami/moodle/tags/ +## +image: bitnami/moodle:3.2.1-r3 + +## Specify a imagePullPolicy +## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' +## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images +## +imagePullPolicy: IfNotPresent + +## User of the application +## ref: https://github.com/bitnami/bitnami-docker-moodle#configuration +## +moodleUsername: user + +## Application password +## Defaults to a random 10-character alphanumeric string if not set +## ref: https://github.com/bitnami/bitnami-docker-moodle#configuration +## +# moodlePassword: + +## Admin email +## ref: https://github.com/bitnami/bitnami-docker-moodle#configuration +moodleEmail: user@example.com + +## SMTP mail delivery configuration +## ref: https://github.com/bitnami/bitnami-docker-moodle/#smtp-configuration +# smtpHost: +# smtpPort: +# smtpUser: +# smtpPassword: +# smtpProtocol: + +## +## MariaDB chart configuration +## +mariadb: + ## MariaDB admin password + ## ref: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#setting-the-root-password-on-first-run + ## + # mariadbRootPassword: + + ## Enable persistence using Persistent Volume Claims + ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ + ## + persistence: + enabled: true + ## If defined, volume.beta.kubernetes.io/storage-class: + ## Default: volume.alpha.kubernetes.io/storage-class: default + ## + # storageClass: + accessMode: ReadWriteOnce + size: 8Gi + +## Kubernetes configuration +## For minikube, set this to NodePort, elsewhere use LoadBalancer +## +serviceType: LoadBalancer + +## 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: + ## Default: volume.alpha.kubernetes.io/storage-class: default + ## + # storageClass: + accessMode: ReadWriteOnce + size: 1Gi + moodle: + ## If defined, volume.beta.kubernetes.io/storage-class: + ## Default: volume.alpha.kubernetes.io/storage-class: default + ## + # storageClass: + accessMode: ReadWriteOnce + size: 8Gi + +## Configure resource requests and limits +## ref: http://kubernetes.io/docs/user-guide/compute-resources/ +## +resources: + requests: + memory: 512Mi + cpu: 300m