From eb29b74feaafda13db51eaaa459a8d1d4a56dcbc Mon Sep 17 00:00:00 2001 From: Adnan Abdulhussein Date: Mon, 12 Jun 2017 16:24:04 +0200 Subject: [PATCH] [incubator/nginx] add option to configure vitual host --- incubator/nginx/Chart.yaml | 3 ++- incubator/nginx/README.md | 25 ++++++++++++++++++++++- incubator/nginx/templates/deployment.yaml | 9 ++++++++ incubator/nginx/templates/vhost.yaml | 14 +++++++++++++ incubator/nginx/values.yaml | 15 ++++++++++++++ 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 incubator/nginx/templates/vhost.yaml diff --git a/incubator/nginx/Chart.yaml b/incubator/nginx/Chart.yaml index a28bf5192..e2c6c2ff0 100644 --- a/incubator/nginx/Chart.yaml +++ b/incubator/nginx/Chart.yaml @@ -1,5 +1,6 @@ name: nginx -version: 0.3.5 +version: 0.4.0 +appVersion: 1.10.2 description: Chart for the nginx server keywords: - nginx diff --git a/incubator/nginx/README.md b/incubator/nginx/README.md index cdde1c19f..9be4dc170 100644 --- a/incubator/nginx/README.md +++ b/incubator/nginx/README.md @@ -53,9 +53,10 @@ The command removes all the Kubernetes components associated with the chart and The following tables lists the configurable parameters of the NGINX chart and their default values. | Parameter | Description | Default | -|-------------------|---------------------------|---------------------| +| ----------------- | ------------------------- | ------------------- | | `imageTag` | `bitnami/nginx` image tag | NGINX image version | | `imagePullPolicy` | Image pull policy | `IfNotPresent` | +| `vhost` | Custom nginx virtual host | `nil` | Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, @@ -74,3 +75,25 @@ $ helm install --name my-release -f values.yaml nginx-x.x.x.tgz ``` > **Tip**: You can use the default [values.yaml](values.yaml) + +### Providing a custom virtual host + +You can use the `vhost` value to provide a custom virtual host for NGINX to use. +To do this, create a values files with your virtual host: + +_custom-vhost.yaml_ +```yaml +vhost: |- + server { + listen 0.0.0.0:80; + location / { + return 200 "hello!"; + } + } +``` + +Install the chart with this value: + +```console +$ helm install --name my-release -f custom-vhost.yaml nginx-x.x.x.tgz +``` diff --git a/incubator/nginx/templates/deployment.yaml b/incubator/nginx/templates/deployment.yaml index 87ef757df..dd963613d 100644 --- a/incubator/nginx/templates/deployment.yaml +++ b/incubator/nginx/templates/deployment.yaml @@ -43,6 +43,15 @@ spec: volumeMounts: - name: nginx-data mountPath: /bitnami/nginx + {{- if .Values.vhost }} + - name: nginx-vhost + mountPath: /bitnami/nginx/conf/vhosts + {{- end }} volumes: - name: nginx-data emptyDir: {} + {{- if .Values.vhost }} + - name: nginx-vhost + configMap: + name: {{ template "fullname" . }} + {{- end }} diff --git a/incubator/nginx/templates/vhost.yaml b/incubator/nginx/templates/vhost.yaml new file mode 100644 index 000000000..7ef7c8e4f --- /dev/null +++ b/incubator/nginx/templates/vhost.yaml @@ -0,0 +1,14 @@ +{{- if .Values.vhost -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +data: + vhost.conf: |- +{{ .Values.vhost | indent 4 }} +{{- end -}} diff --git a/incubator/nginx/values.yaml b/incubator/nginx/values.yaml index 1ca45c62b..81e06c058 100644 --- a/incubator/nginx/values.yaml +++ b/incubator/nginx/values.yaml @@ -7,3 +7,18 @@ imageTag: 1.10.2-r3 ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images ## imagePullPolicy: IfNotPresent + +# vhost: |- +# # example PHP-FPM vhost +# server { +# listen 0.0.0.0:80; +# root /app; +# location / { +# index index.html index.php; +# } +# location ~ \.php$ { +# fastcgi_pass phpfpm-server:9000; +# fastcgi_index index.php; +# include fastcgi.conf; +# } +# }