Skip to content

Commit

Permalink
Merge pull request helm#2605 from timothyclarke/master
Browse files Browse the repository at this point in the history
[stable/wordpress] Optional MariaDB for WordPress
  • Loading branch information
k8s-ci-robot authored Dec 13, 2017
2 parents 287e6f5 + 467e35e commit dd7234f
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 16 deletions.
2 changes: 1 addition & 1 deletion stable/wordpress/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: wordpress
version: 0.7.5
version: 0.7.6
appVersion: 4.9.1
description: Web publishing platform for building blogs and websites.
icon: https://bitnami.com/assets/stacks/wordpress/img/wordpress-stack-220x234.png
Expand Down
31 changes: 25 additions & 6 deletions stable/wordpress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,29 @@ The following tables lists the configurable parameters of the WordPress chart an
| `wordpressFirstName` | First name | `FirstName` |
| `wordpressLastName` | Last name | `LastName` |
| `wordpressBlogName` | Blog name | `User's Blog!` |
| `allowEmptyPassword` | Allow DB blank passwords | `yes` |
| `allowEmptyPassword` | Allow DB blank passwords | `yes` |
| `smtpHost` | SMTP host | `nil` |
| `smtpPort` | SMTP port | `nil` |
| `smtpUser` | SMTP user | `nil` |
| `smtpPassword` | SMTP password | `nil` |
| `smtpUsername` | User name for SMTP emails | `nil` |
| `smtpProtocol` | SMTP protocol [`tls`, `ssl`] | `nil` |
| `mariadb.enabled` | Deploy MariaDB container(s) | `true` |
| `mariadb.mariadbRootPassword` | MariaDB admin password | `nil` |
| `mariadb.mariadbDatabase` | Database name to create | `bitnami_wordpress` |
| `mariadb.mariadbUser` | Database user to create | `bn_wordpress` |
| `mariadb.mariadbPassword` | Password for the database | _random 10 character long alphanumeric string_ |
| `mariadb.mariadbDatabase` | Database name to create | `bitnami_wordpress` |
| `mariadb.mariadbUser` | Database user to create | `bn_wordpress` |
| `mariadb.mariadbPassword` | Password for the database | _random 10 character long alphanumeric string_ |
| `externalDatabase.host` | Host of the external database | `localhost` |
| `externalDatabase.rootPassword` | DB Root users password (schema creation) | `nil` |
| `externalDatabase.user` | Existing username in the external db | `bn_wordpress` |
| `externalDatabase.password` | Password for the above username | `nil` |
| `externalDatabase.database` | Name of the existing database | `bitnami_wordpress` |
| `externalDatabase.port` | Database port number | `3306` |
| `serviceType` | Kubernetes Service type | `LoadBalancer` |
| `healthcheckHttps` | Use https for liveliness and readiness | `false` |
| `healthcheckHttps` | Use https for liveliness and readiness | `false` |
| `ingress.enabled` | Enable ingress controller resource | `false` |
| `ingress.hosts[0].name` | Hostname to your WordPress installation | `wordpress.local` |
| `ingress.hosts[0].path` | Path within the url structure | `/` |
| `ingress.hosts[0].tls` | Utilize TLS backend in ingress | `false` |
| `ingress.hosts[0].tlsSecret` | TLS Secret (certificates) | `wordpress.local-tls-secret` |
| `ingress.hosts[0].annotations` | Annotations for this host's ingress record | `[]` |
Expand Down Expand Up @@ -109,6 +117,17 @@ The [Bitnami WordPress](https://github.com/bitnami/bitnami-docker-wordpress) ima
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.

## Using an external database

Sometimes you may want to have Wordpress connect to an external database rather than installing one inside your cluster, e.g. to use a managed database service, or use run a single database server for all your applications. To do this, the chart allows you to specify credentials for an external database under the [`externalDatabase` parameter](#configuration). You should also disable the MariaDB installation with the `mariadb.enabled` option. For example:

```console
$ helm install stable/wordpress \
--set mariadb.enabled=false,externalDatabase.host=myexternalhost,externalDatabase.rootPassword=rootpassword,externalDatabase.user=myuser,externalDatabase.password=mypassword,externalDatabase.database=mydatabase,externalDatabase.port=3306
```
Note also if you disable MariaDB per above you MUST supply values for externalDatabase.rootPassword & externalDatabase.password.


## Ingress

This chart provides support for ingress resources. If you have an
Expand Down Expand Up @@ -181,4 +200,4 @@ kubectl create secret tls wordpress.local-tls --key /path/to/key.key --cert /pat
```
Please see [this example](https://github.com/kubernetes/contrib/tree/master/ingress/controllers/nginx/examples/tls)
for more information.
for more information.
6 changes: 3 additions & 3 deletions stable/wordpress/requirements.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: mariadb
repository: https://kubernetes-charts.storage.googleapis.com/
version: 0.7.0
digest: sha256:e1af13ac4ac21f67582006f12d2b4eb78a1a2a59b34338fac850f2bec0b08b41
generated: 2017-08-09T22:53:02.519960734-04:00
version: 2.1.1
digest: sha256:abb98724b82fbb89b183dbd016f18c207c3bfb4970d5c8770a884af1c5304dbc
generated: 2017-12-13T12:24:01.108769296Z
5 changes: 4 additions & 1 deletion stable/wordpress/requirements.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
dependencies:
- name: mariadb
version: 0.7.0
version: 2.1.1
repository: https://kubernetes-charts.storage.googleapis.com/
condition: mariadb.enabled
tags:
- wordpress-database
30 changes: 28 additions & 2 deletions stable/wordpress/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,47 @@ spec:
- name: MARIADB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.mariadb.enabled }}
name: {{ template "mariadb.fullname" . }}
key: mariadb-root-password
{{- else }}
name: {{ printf "%s-%s" .Release.Name "externaldb" }}
key: db-root-password
{{- end }}
- name: MARIADB_HOST
{{- if .Values.mariadb.enabled }}
value: {{ template "mariadb.fullname" . }}
{{- else }}
value: {{ .Values.externalDatabase.host | quote }}
{{- end }}
- name: MARIADB_PORT_NUMBER
{{- if .Values.mariadb.enabled }}
value: "3306"
{{- else }}
value: {{ .Values.externalDatabase.port | quote }}
{{- end }}
- name: WORDPRESS_DATABASE_NAME
value: {{ default "" .Values.mariadb.mariadbDatabase | quote }}
{{- if .Values.mariadb.enabled }}
value: {{ .Values.mariadb.mariadbDatabase | quote }}
{{- else }}
value: {{ .Values.externalDatabase.database | quote }}
{{- end }}
- name: WORDPRESS_DATABASE_USER
value: {{ default "" .Values.mariadb.mariadbUser | quote }}
{{- if .Values.mariadb.enabled }}
value: {{ .Values.mariadb.mariadbUser | quote }}
{{- else }}
value: {{ .Values.externalDatabase.user | quote }}
{{- end }}
- name: WORDPRESS_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.mariadb.enabled }}
name: {{ template "mariadb.fullname" . }}
key: mariadb-password
{{- else }}
name: {{ printf "%s-%s" .Release.Name "externaldb" }}
key: db-password
{{- end }}
- name: WORDPRESS_USERNAME
value: {{ default "" .Values.wordpressUsername | quote }}
- name: WORDPRESS_PASSWORD
Expand Down
15 changes: 15 additions & 0 deletions stable/wordpress/templates/externaldb-secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if not .Values.mariadb.enabled }}
apiVersion: v1
kind: Secret
metadata:
name: {{ printf "%s-%s" .Release.Name "externaldb" }}
labels:
app: {{ printf "%s-%s" .Release.Name "externaldb" }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
type: Opaque
data:
db-root-password: {{ .Values.externalDatabase.rootPassword | b64enc | quote }}
db-password: {{ .Values.externalDatabase.password | b64enc | quote }}
{{- end }}
4 changes: 2 additions & 2 deletions stable/wordpress/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
- host: {{ .name }}
http:
paths:
- path: /
- path: {{ default "/" .path }}
backend:
serviceName: {{ template "fullname" $ }}
servicePort: {{ if .tls }}443{{ else }}80{{end}}
Expand All @@ -33,4 +33,4 @@ spec:
{{- end }}
---
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.mariadb.enabled }}
apiVersion: v1
kind: Pod
metadata:
Expand All @@ -24,4 +25,4 @@ spec:
key: mariadb-password
command: ["sh", "-c", "mysql --host=$MARIADB_HOST --port=$MARIADB_PORT --user=$WORDPRESS_DATABASE_USER --password=$WORDPRESS_DATABASE_PASSWORD"]
restartPolicy: Never

{{- end }}
24 changes: 24 additions & 0 deletions stable/wordpress/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,34 @@ allowEmptyPassword: yes
# smtpUsername:
# smtpProtocol:

externalDatabase:
## All of these values are only used when mariadb.enabled is set to false
## Database host
host: localhost

## Database Root User (so wordpress can create the db schema etc)
# rootPassword:

## non-root Username for Wordpress Database
user: bn_wordpress

## Database password
# password:

## Database name
database: bitnami_wordpress

## Database port number
port: 3306

##
## MariaDB chart configuration
##
mariadb:
## Whether to use the database specified as a requirement or not.
## If you want to use an external database set this to false and supply details to externalDatabase above
enabled: true

## MariaDB admin password
## ref: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#setting-the-root-password-on-first-run
##
Expand Down

0 comments on commit dd7234f

Please sign in to comment.