From c5f6cafba09deb84a7b2c657cd7193fe607633d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20J=2E=20Salmer=C3=B3n-Garc=C3=ADa?= Date: Tue, 20 Nov 2018 18:35:40 +0100 Subject: [PATCH] [stable/moodle] Add service.type to values.yaml (#9404) Signed-off-by: Javier J. Salmeron Garcia --- stable/moodle/Chart.yaml | 2 +- stable/moodle/README.md | 7 ++++++- stable/moodle/templates/NOTES.txt | 18 ++++++++++-------- stable/moodle/templates/svc.yaml | 23 ++++++++++++++++------- stable/moodle/values.yaml | 19 ++++++++++++++++++- 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/stable/moodle/Chart.yaml b/stable/moodle/Chart.yaml index 20847a7410..473450d826 100644 --- a/stable/moodle/Chart.yaml +++ b/stable/moodle/Chart.yaml @@ -1,5 +1,5 @@ name: moodle -version: 3.3.1 +version: 4.0.0 appVersion: 3.5.3 description: Moodle is a learning platform designed to provide educators, administrators and learners with a single robust, secure and integrated system to create personalised diff --git a/stable/moodle/README.md b/stable/moodle/README.md index 7b765c3856..030330926c 100644 --- a/stable/moodle/README.md +++ b/stable/moodle/README.md @@ -63,7 +63,12 @@ The following table lists the configurable parameters of the Moodle chart and th | `smtpProtocol` | SMTP Protocol (options: ssl,tls, nil) | `nil` | | `smtpUser` | SMTP user | `nil` | | `smtpPassword` | SMTP password | `nil` | -| `serviceType` | Kubernetes Service type | `LoadBalancer` | +| `service.type` | Kubernetes Service type | `LoadBalancer` | +| `service.port` | Service HTTP port | `80` | +| `service.httpsPort` | Service HTTPS port | `443` | +| `service.externalTrafficPolicy` | Enable client source IP preservation | `Cluster` | +| `service.nodePorts.http` | Kubernetes http node port | `""` | +| `service.nodePorts.https` | Kubernetes https node port | `""` | | `ingress.enabled` | Enable ingress controller resource | `false` | | `ingress.hosts[0].name` | Hostname to your Moodle installation | `moodle.local` | | `ingress.hosts[0].path` | Path within the url structure | `/` | diff --git a/stable/moodle/templates/NOTES.txt b/stable/moodle/templates/NOTES.txt index 42d464300a..7f6f63cc25 100644 --- a/stable/moodle/templates/NOTES.txt +++ b/stable/moodle/templates/NOTES.txt @@ -1,8 +1,8 @@ {{- if or .Values.mariadb.enabled .Values.externalDatabase.host -}} ** 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! ** +{{- if and .Values.ingress.enabled (ne .Values.service.type "ClusterIP") }} +** Notice : Usually with ingress the service.type should be set to ClusterIP, which is not the case to this deployment! ** {{- end }} 1. Access you Moodle instance with: @@ -17,22 +17,24 @@ - http://{{ . }} {{- end }} {{- end }} -{{- else if contains "NodePort" .Values.serviceType }} +{{- else if contains "NodePort" .Values.service.type }} export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "moodle.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo "Moodle URL: http://$NODE_IP:$NODE_PORT/" -{{- else if contains "LoadBalancer" .Values.serviceType }} +{{- else if contains "LoadBalancer" .Values.service.type }} ** Please ensure an external IP is associated to the {{ template "moodle.fullname" . }} service before proceeding ** ** Watch the status using: kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "moodle.fullname" . }} ** export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "moodle.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo "Moodle URL: http://$SERVICE_IP/" -{{- else if contains "ClusterIP" .Values.serviceType }} +{{- $port:=.Values.service.port | toString }} + echo "Moodle URL: http://$SERVICE_IP{{- if ne $port "80" }}:{{ .Values.service.port }}{{ end }}/" - kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "moodle.fullname" . }} 8080:80 +{{- else if contains "ClusterIP" .Values.service.type }} + + kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "moodle.fullname" . }} 8080:{{ .Values.service.port }} echo "Moodle URL: http://127.0.0.1:8080/" {{- end }} @@ -54,6 +56,6 @@ host. To configure Moodle to use and external database host: 1. Complete your Moodle deployment by running: - helm upgrade {{ .Release.Name }} --set serviceType={{ .Values.serviceType }},mariadb.enabled=false,externalDatabase.host=YOUR_EXTERNAL_DATABASE_HOST stable/moodle + helm upgrade {{ .Release.Name }} --set service.type={{ .Values.service.type }},mariadb.enabled=false,externalDatabase.host=YOUR_EXTERNAL_DATABASE_HOST stable/moodle {{- end }} diff --git a/stable/moodle/templates/svc.yaml b/stable/moodle/templates/svc.yaml index 2a69ef447e..247019ee0a 100644 --- a/stable/moodle/templates/svc.yaml +++ b/stable/moodle/templates/svc.yaml @@ -8,13 +8,22 @@ metadata: release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" spec: - type: {{ .Values.serviceType }} + type: {{ .Values.service.type }} + {{- if (or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort")) }} + externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }} + {{- end }} ports: - - name: http - port: 80 - targetPort: http - - name: https - port: 443 - targetPort: https + - name: http + port: {{ .Values.service.port }} + targetPort: http + {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.http)))}} + nodePort: {{ .Values.service.nodePorts.http }} + {{- end }} + - name: https + port: {{ .Values.service.httpsPort }} + targetPort: https + {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.https)))}} + nodePort: {{ .Values.service.nodePorts.https }} + {{- end }} selector: app: {{ template "moodle.fullname" . }} diff --git a/stable/moodle/values.yaml b/stable/moodle/values.yaml index a1c2df03f3..91e8b63edb 100644 --- a/stable/moodle/values.yaml +++ b/stable/moodle/values.yaml @@ -145,7 +145,24 @@ mariadb: ## Kubernetes configuration ## For minikube, set this to NodePort, for ingress ClusterIP, elsewhere use LoadBalancer ## -serviceType: LoadBalancer +service: + type: LoadBalancer + # HTTP Port + port: 80 + # HTTPS Port + httpsPort: 443 + ## + ## nodePorts: + ## http: + ## https: + nodePorts: + http: "" + https: "" + ## Enable client source IP preservation + ## ref http://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip + ## + externalTrafficPolicy: Cluster + ## Configure the ingress resource that allows you to access the ## Moodle installation. Set up the URL