From e17e0ac0e4cf7af551616bb516ec8bfa4fa738cc Mon Sep 17 00:00:00 2001 From: Juan Ariza Toledano Date: Thu, 11 Oct 2018 15:06:32 +0200 Subject: [PATCH] [stable/drupal] Simplify ingress configuration for cert-manager (#8352) * Fix typo Signed-off-by: juan131 * [stable/redmine] Simplify drupal configuration for cert-manager Signed-off-by: juan131 * Fix typo Signed-off-by: juan131 * Add 'drupal.chart' macro Signed-off-by: juan131 --- stable/drupal/Chart.yaml | 2 +- stable/drupal/README.md | 84 +++++++++++++------------ stable/drupal/templates/_helpers.tpl | 7 +++ stable/drupal/templates/apache-pvc.yaml | 2 +- stable/drupal/templates/deployment.yaml | 4 +- stable/drupal/templates/drupal-pvc.yaml | 2 +- stable/drupal/templates/ingress.yaml | 38 ++++++----- stable/drupal/templates/secrets.yaml | 2 +- stable/drupal/templates/svc.yaml | 2 +- stable/drupal/values.yaml | 41 +++++++----- 10 files changed, 108 insertions(+), 76 deletions(-) diff --git a/stable/drupal/Chart.yaml b/stable/drupal/Chart.yaml index 425c55ba64..6ea74469e9 100644 --- a/stable/drupal/Chart.yaml +++ b/stable/drupal/Chart.yaml @@ -1,5 +1,5 @@ name: drupal -version: 2.0.3 +version: 2.1.0 appVersion: 8.6.1 description: One of the most versatile open source content management systems. keywords: diff --git a/stable/drupal/README.md b/stable/drupal/README.md index 59bfabe4a3..ea449fb593 100644 --- a/stable/drupal/README.md +++ b/stable/drupal/README.md @@ -47,45 +47,51 @@ The command removes all the Kubernetes components associated with the chart and The following table lists the configurable parameters of the Drupal chart and their default values. -| Parameter | Description | Default | -| --------------------------------- | ------------------------------------- | --------------------------------------------------------- | -| `image.registry` | Drupal image registry | `docker.io` | -| `image.repository` | Drupal Image name | `bitnami/drupal` | -| `image.tag` | Drupal Image tag | `{VERSION}` | -| `image.pullPolicy` | Drupal image pull policy | `Always` if `imageTag` is `latest`, else `IfNotPresent` | -| `image.pullSecrets` | Specify image pull secrets | `nil` (does not add image pull secrets to deployed pods) | -| `drupalProfile` | Drupal installation profile | `standard` | -| `drupalUsername` | User of the application | `user` | -| `drupalPassword` | Application password | _random 10 character long alphanumeric string_ | -| `drupalEmail` | Admin email | `user@example.com` | -| `allowEmptyPassword` | Allow DB blank passwords | `yes` | -| `extraVars` | Extra environment variables | `nil` | -| `ingress.annotations` | Specify ingress class | `kubernetes.io/ingress.class: nginx` | -| `ingress.enabled` | Enable ingress controller resource | `false` | -| `ingress.hostname` | URL for your Drupal installation | `drupal.local` | -| `ingress.tls` | Ingress TLS configuration | `[]` | -| `externalDatabase.host` | Host of the external database | `nil` | -| `externalDatabase.user` | Existing username in the external db | `bn_drupal` | -| `externalDatabase.password` | Password for the above username | `nil` | -| `externalDatabase.database` | Name of the existing database | `bitnami_drupal` | -| `mariadb.enabled` | Whether to use the MariaDB chart | `true` | -| `mariadb.rootUser.password` | MariaDB admin password | `nil` | -| `mariadb.db.name` | Database name to create | `bitnami_drupal` | -| `mariadb.db.user` | Database user to create | `bn_drupal` | -| `mariadb.db.password` | Password for the database | _random 10 character long alphanumeric string_ | -| `serviceType` | Kubernetes Service type | `LoadBalancer` | -| `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.drupal.storageClass` | PVC Storage Class for Drupal volume | `nil` (uses alpha storage class annotation) | -| `persistence.drupal.accessMode` | PVC Access Mode for Drupal volume | `ReadWriteOnce` | -| `persistence.drupal.existingClaim`| An Existing PVC name | `nil` | -| `persistence.drupal.hostPath` | Host mount path for Drupal volume | `nil` (will not mount to a host path) | -| `persistence.drupal.size` | PVC Storage Request for Drupal volume | `8Gi` | -| `resources` | CPU/Memory resource requests/limits | Memory: `512Mi`, CPU: `300m` | -| `volumeMounts.drupal.mountPath` | Drupal data volume mount path | `/bitnami/drupal` | -| `volumeMounts.apache.mountPath` | Apache data volume mount path | `/bitnami/apache` | +| Parameter | Description | Default | +| --------------------------------- | ------------------------------------------ | --------------------------------------------------------- | +| `image.registry` | Drupal image registry | `docker.io` | +| `image.repository` | Drupal Image name | `bitnami/drupal` | +| `image.tag` | Drupal Image tag | `{VERSION}` | +| `image.pullPolicy` | Drupal image pull policy | `Always` if `imageTag` is `latest`, else `IfNotPresent` | +| `image.pullSecrets` | Specify image pull secrets | `nil` (does not add image pull secrets to deployed pods) | +| `drupalProfile` | Drupal installation profile | `standard` | +| `drupalUsername` | User of the application | `user` | +| `drupalPassword` | Application password | _random 10 character long alphanumeric string_ | +| `drupalEmail` | Admin email | `user@example.com` | +| `allowEmptyPassword` | Allow DB blank passwords | `yes` | +| `extraVars` | Extra environment variables | `nil` | +| `ingress.enabled` | Enable ingress controller resource | `false` | +| `ingress.hosts[0].name` | Hostname to your Drupal installation | `drupal.local` | +| `ingress.hosts[0].path` | Path within the url structure | `/` | +| `ingress.hosts[0].tls` | Utilize TLS backend in ingress | `false` | +| `ingress.hosts[0].certManager` | Add annotations for cert-manager | `false` | +| `ingress.hosts[0].tlsSecret` | TLS Secret (certificates) | `drupal.local-tls-secret` | +| `ingress.hosts[0].annotations` | Annotations for this host's ingress record | `[]` | +| `ingress.secrets[0].name` | TLS Secret Name | `nil` | +| `ingress.secrets[0].certificate` | TLS Secret Certificate | `nil` | +| `ingress.secrets[0].key` | TLS Secret Key | `nil` | +| `externalDatabase.host` | Host of the external database | `nil` | +| `externalDatabase.user` | Existing username in the external db | `bn_drupal` | +| `externalDatabase.password` | Password for the above username | `nil` | +| `externalDatabase.database` | Name of the existing database | `bitnami_drupal` | +| `mariadb.enabled` | Whether to use the MariaDB chart | `true` | +| `mariadb.rootUser.password` | MariaDB admin password | `nil` | +| `mariadb.db.name` | Database name to create | `bitnami_drupal` | +| `mariadb.db.user` | Database user to create | `bn_drupal` | +| `mariadb.db.password` | Password for the database | _random 10 character long alphanumeric string_ | +| `serviceType` | Kubernetes Service type | `LoadBalancer` | +| `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.drupal.storageClass` | PVC Storage Class for Drupal volume | `nil` (uses alpha storage class annotation) | +| `persistence.drupal.accessMode` | PVC Access Mode for Drupal volume | `ReadWriteOnce` | +| `persistence.drupal.existingClaim`| An Existing PVC name | `nil` | +| `persistence.drupal.hostPath` | Host mount path for Drupal volume | `nil` (will not mount to a host path) | +| `persistence.drupal.size` | PVC Storage Request for Drupal volume | `8Gi` | +| `resources` | CPU/Memory resource requests/limits | Memory: `512Mi`, CPU: `300m` | +| `volumeMounts.drupal.mountPath` | Drupal data volume mount path | `/bitnami/drupal` | +| `volumeMounts.apache.mountPath` | Apache data volume mount path | `/bitnami/apache` | The above parameters map to the env variables defined in [bitnami/drupal](http://github.com/bitnami/bitnami-docker-drupal). For more information please refer to the [bitnami/drupal](http://github.com/bitnami/bitnami-docker-drupal) image documentation. diff --git a/stable/drupal/templates/_helpers.tpl b/stable/drupal/templates/_helpers.tpl index 0c876fb0c9..33decfbd9d 100644 --- a/stable/drupal/templates/_helpers.tpl +++ b/stable/drupal/templates/_helpers.tpl @@ -22,3 +22,10 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- define "drupal.mariadb.fullname" -}} {{- printf "%s-%s" .Release.Name "mariadb" | trunc 63 | trimSuffix "-" -}} {{- 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 -}} \ No newline at end of file diff --git a/stable/drupal/templates/apache-pvc.yaml b/stable/drupal/templates/apache-pvc.yaml index dd302f40bd..d3a49f3c64 100644 --- a/stable/drupal/templates/apache-pvc.yaml +++ b/stable/drupal/templates/apache-pvc.yaml @@ -5,7 +5,7 @@ metadata: name: {{ template "drupal.fullname" . }}-apache labels: app: {{ template "drupal.fullname" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + chart: {{ template "drupal.chart" . }} release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" spec: diff --git a/stable/drupal/templates/deployment.yaml b/stable/drupal/templates/deployment.yaml index 70e71a1e6a..661d83e227 100644 --- a/stable/drupal/templates/deployment.yaml +++ b/stable/drupal/templates/deployment.yaml @@ -4,7 +4,7 @@ metadata: name: {{ template "drupal.fullname" . }} labels: app: {{ template "drupal.fullname" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + chart: {{ template "drupal.chart" . }} release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" spec: @@ -17,7 +17,7 @@ spec: metadata: labels: app: {{ template "drupal.fullname" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + chart: {{ template "drupal.chart" . }} release: "{{ .Release.Name }}" spec: {{- if .Values.image.pullSecrets }} diff --git a/stable/drupal/templates/drupal-pvc.yaml b/stable/drupal/templates/drupal-pvc.yaml index 39c2d1f7f0..0f1378ad11 100644 --- a/stable/drupal/templates/drupal-pvc.yaml +++ b/stable/drupal/templates/drupal-pvc.yaml @@ -5,7 +5,7 @@ metadata: name: {{ template "drupal.fullname" . }}-drupal labels: app: {{ template "drupal.fullname" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + chart: {{ template "drupal.chart" . }} release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" spec: diff --git a/stable/drupal/templates/ingress.yaml b/stable/drupal/templates/ingress.yaml index 079873dcb6..95e7f3d422 100644 --- a/stable/drupal/templates/ingress.yaml +++ b/stable/drupal/templates/ingress.yaml @@ -1,28 +1,38 @@ {{- if .Values.ingress.enabled -}} +{{- range .Values.ingress.hosts }} apiVersion: extensions/v1beta1 kind: Ingress metadata: - name: {{ template "drupal.fullname" . }} + name: "{{- printf "%s-%s" .name $.Release.Name | trunc 63 | trimSuffix "-" -}}" labels: - app: {{ template "drupal.fullname" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" - release: "{{ .Release.Name }}" - heritage: "{{ .Release.Service }}" + app: {{ template "drupal.fullname" $ }} + chart: {{ template "drupal.chart" $ }} + release: "{{ $.Release.Name }}" + heritage: "{{ $.Release.Service }}" annotations: - {{- range $key, $value := .Values.ingress.annotations }} - {{ $key }}: {{ $value | quote }} + {{- if .certManager }} + kubernetes.io/tls-acme: "true" + {{- end }} + {{- range $key, $value := .annotations }} + {{ $key }}: {{ $value | quote }} {{- end }} spec: rules: - - host: {{ .Values.ingress.hostname }} + - host: {{ .name }} http: paths: - - path: / + - path: {{ default "/" .path }} backend: - serviceName: {{ template "drupal.fullname" . }} + serviceName: {{ template "drupal.fullname" $ }} servicePort: 80 -{{- if .Values.ingress.tls }} +{{- if .tls }} tls: -{{ toYaml .Values.ingress.tls | indent 4 }} -{{- end -}} -{{- end -}} + - hosts: + - {{ .name }} + secretName: {{ .tlsSecret }} +{{- end }} +--- +{{- end }} +{{- end }} + + diff --git a/stable/drupal/templates/secrets.yaml b/stable/drupal/templates/secrets.yaml index 1037810912..774530fef6 100644 --- a/stable/drupal/templates/secrets.yaml +++ b/stable/drupal/templates/secrets.yaml @@ -4,7 +4,7 @@ metadata: name: {{ template "drupal.fullname" . }} labels: app: {{ template "drupal.fullname" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + chart: {{ template "drupal.chart" . }} release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" type: Opaque diff --git a/stable/drupal/templates/svc.yaml b/stable/drupal/templates/svc.yaml index 4a2abb702d..222e9d5b8c 100644 --- a/stable/drupal/templates/svc.yaml +++ b/stable/drupal/templates/svc.yaml @@ -4,7 +4,7 @@ metadata: name: {{ template "drupal.fullname" . }} labels: app: {{ template "drupal.fullname" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + chart: {{ template "drupal.chart" . }} release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" spec: diff --git a/stable/drupal/values.yaml b/stable/drupal/values.yaml index 4f2a097979..dad9906d42 100644 --- a/stable/drupal/values.yaml +++ b/stable/drupal/values.yaml @@ -39,7 +39,7 @@ drupalUsername: user drupalEmail: user@example.com ## Set to `yes` to allow the container to be started with blank passwords -## ref: https://github.com/bitnami/bitnami-docker-wordpress#environment-variables +## ref: https://github.com/bitnami/bitnami-docker-drupal#environment-variables allowEmptyPassword: "yes" ## @@ -107,27 +107,36 @@ mariadb: ## serviceType: LoadBalancer -## Configure Ingress resource that allow you to access the Drupal installation -## Set up the URL +## Configure the ingress resource that allows you to access the +## Drupal installation. Set up the URL ## ref: http://kubernetes.io/docs/user-guide/ingress/ ## ingress: + ## Set to true to enable ingress record generation enabled: false - # Used to create Ingress record (should used with ServiceType: ClusterIP). - # hostname: drupal.local - ## Ingress annotations - ## - # annotations: - # kubernetes.io/ingress.class: nginx + ## The list of hostnames to be covered with this ingress record. + ## Most likely this will be just one host, but in the event more hosts are needed, this is an array + hosts: + - name: drupal.local - ## Ingress TLS configuration - ## Secrets must be manually created in the namespace - ## - # tls: - # - secretName: wordpress.local-tls - # hosts: - # - drupal.local + ## Set this to true in order to enable TLS on the ingress record + ## A side effect of this will be that the backend drupal service will be connected at port 443 + tls: false + + ## Set this to true in order to add the corresponding annotations for cert-manager + certManager: false + + ## If TLS is set to true, you must declare what secret will store the key/certificate for TLS + tlsSecret: drupal.local-tls + + ## Ingress annotations done as key:value pairs + ## For a full list of possible ingress annotations, please see + ## ref: https://github.com/kubernetes/ingress-nginx/blob/master/docs/annotations.md + ## + ## If certManager is set to true, annotation kubernetes.io/tls-acme: "true" will automatically be set + annotations: + # kubernetes.io/ingress.class: nginx ## Enable persistence using Persistent Volume Claims ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/