From 9db2dacbcad80dcdfa1406fe0dc299032641084d Mon Sep 17 00:00:00 2001 From: juan131 Date: Mon, 5 Aug 2019 10:33:07 +0200 Subject: [PATCH] [bitnami/nginx] Add 'nodeSelector', 'affinity' and 'tolerations' support Signed-off-by: juan131 --- bitnami/nginx/Chart.yaml | 2 +- bitnami/nginx/README.md | 5 ++++ bitnami/nginx/templates/NOTES.txt | 32 +++++++++++++++++++++++++ bitnami/nginx/templates/deployment.yaml | 32 +++++++++++++++++++++++++ bitnami/nginx/values.yaml | 22 +++++++++++++++++ 5 files changed, 92 insertions(+), 1 deletion(-) diff --git a/bitnami/nginx/Chart.yaml b/bitnami/nginx/Chart.yaml index 1682823ca..d19a77590 100644 --- a/bitnami/nginx/Chart.yaml +++ b/bitnami/nginx/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: nginx -version: 4.1.2 +version: 4.2.0 appVersion: 1.16.0 description: Chart for the nginx server keywords: diff --git a/bitnami/nginx/README.md b/bitnami/nginx/README.md index 9fc981d2f..d2d799c1f 100644 --- a/bitnami/nginx/README.md +++ b/bitnami/nginx/README.md @@ -55,6 +55,11 @@ The following tables lists the configurable parameters of the NGINX Open Source | `fullnameOverride` | String to fully override nginx.fullname template with a string | `nil` | | `serverBlock` | Custom NGINX server block | `nil` | | `podAnnotations` | Pod annotations | `{}` | +| `nodeAffinity` | Node Affinity rules for pod assignment. The value is evaluated as a template | `{}` | +| `podAffinity` | Affinity rules for pod assignment. The value is evaluated as a template | `{}` | +| `podAntiAffinity` | Anti-Affinity rules for pod assignment. Allowed values: `soft` and `hard` | `soft` | +| `nodeSelector` | Node labels for pod assignment. The value is evaluated as a template | `{}` | +| `tolerations` | Tolerations for pod assignment. The value is evaluated as a template | `{}` | | `metrics.enabled` | Start a side-car prometheus exporter | `false` | | `metrics.image.registry` | Promethus exporter image registry | `docker.io` | | `metrics.image.repository` | Promethus exporter image name | `bitnami/nginx-exporter` | diff --git a/bitnami/nginx/templates/NOTES.txt b/bitnami/nginx/templates/NOTES.txt index d24052057..652d73996 100644 --- a/bitnami/nginx/templates/NOTES.txt +++ b/bitnami/nginx/templates/NOTES.txt @@ -1,3 +1,35 @@ +Get the NGINX URL: + +{{- if .Values.ingress.enabled }} + + You should be able to access your new NGINX installation through + + {{- range .Values.ingress.hosts }} + {{ if .tls }}https{{ else }}http{{ end }}://{{ .name }} + {{- end }} + +{{- else if contains "LoadBalancer" .Values.service.type }} +{{- $port:=.Values.service.port | toString }} + + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "nginx.fullname" . }}' + + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "nginx.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo "NGINX URL: http://$SERVICE_IP{{- if ne $port "80" }}:{{ .Values.service.port }}{{ end }}/" + +{{- else if contains "ClusterIP" .Values.service.type }} + + echo "NGINX URL: http://127.0.0.1:8080/" + kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "nginx.fullname" . }} 8080:{{ .Values.service.port }} + +{{- else if contains "NodePort" .Values.service.type }} + + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "nginx.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo "NGINX URL: http://$NODE_IP:$NODE_PORT/" + +{{- end }} + {{- if and (contains "bitnami/" .Values.image.repository) (not (.Values.image.tag | toString | regexFind "-r\\d+$|sha256:")) }} WARNING: Rolling tag detected ({{ .Values.image.repository }}:{{ .Values.image.tag }}), please note that it is strongly recommended to avoid using rolling tags in a production environment. diff --git a/bitnami/nginx/templates/deployment.yaml b/bitnami/nginx/templates/deployment.yaml index a3b3bce71..5ccfc107f 100644 --- a/bitnami/nginx/templates/deployment.yaml +++ b/bitnami/nginx/templates/deployment.yaml @@ -30,6 +30,38 @@ spec: {{- end }} {{- end }} spec: + affinity: + {{- with .Values.nodeAffinity }} + nodeAffinity: {{ tpl (toYaml .) $ | nindent 10 }} + {{- end }} + {{- with .Values.podAffinity }} + podAffinity: {{ tpl (toYaml .) $ | nindent 10 }} + {{- end }} + {{- if eq .Values.podAntiAffinity "hard" }} + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - topologyKey: "kubernetes.io/hostname" + labelSelector: + matchLabels: + app: {{ template "nginx.fullname" . }} + release: "{{ .Release.Name }}" + {{- else if eq .Values.podAntiAffinity "soft" }} + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 1 + podAffinityTerm: + topologyKey: "kubernetes.io/hostname" + labelSelector: + matchLabels: + app: {{ template "nginx.fullname" . }} + release: "{{ .Release.Name }}" + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: {{ tpl (toYaml .) $ | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: {{ tpl (toYaml .) $ | nindent 8 }} + {{- end }} {{- include "nginx.imagePullSecrets" . | indent 6 }} containers: - name: nginx diff --git a/bitnami/nginx/values.yaml b/bitnami/nginx/values.yaml index d0e2977c3..061af8a75 100644 --- a/bitnami/nginx/values.yaml +++ b/bitnami/nginx/values.yaml @@ -144,6 +144,28 @@ readinessProbe: ## podAnnotations: {} +## Node Affinity. The value is evaluated as a template. +## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity-beta-feature +## +nodeAffinity: {} +## Pod Affinity. The value is evaluated as a template. +## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity +## +podAffinity: {} +## Pod AntiAffinity +## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity +## +podAntiAffinity: soft + +## Node labels for pod assignment. The value is evaluated as a template. +## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector +## +nodeSelector: {} +## Tolerations for pod assignment. The value is evaluated as a template. +## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#taints-and-tolerations-beta-feature +## +tolerations: {} + ## Resource requests and limits ## ref: http://kubernetes.io/docs/user-guide/compute-resources/ ##