From 9e21bd5fe9ec15ab7f250e46e6e173a3d58bce02 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 27 Nov 2018 14:45:34 +0000 Subject: [PATCH 1/5] Add nodeSelector, affinity, tolerations support * Add nodeSelector support to deployment template * Add affinity support to daemonset and deployment templates * Tolerations changed to be more flexible. Can now be used in deployments and daemonsets that are not deployed on IBM icp --- .../helm-chart/templates/controller-daemonset.yaml | 14 +++++++------- .../templates/controller-deployment.yaml | 12 ++++++++++++ deployments/helm-chart/values-icp.yaml | 7 ++++++- deployments/helm-chart/values.yaml | 3 ++- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/deployments/helm-chart/templates/controller-daemonset.yaml b/deployments/helm-chart/templates/controller-daemonset.yaml index ceba609cf3..a55fed003b 100644 --- a/deployments/helm-chart/templates/controller-daemonset.yaml +++ b/deployments/helm-chart/templates/controller-daemonset.yaml @@ -26,15 +26,15 @@ spec: terminationGracePeriodSeconds: {{ .Values.controller.terminationGracePeriodSeconds }} {{- if .Values.controller.nodeSelector }} nodeSelector: -{{ toYaml .Values.controller.nodeSelector | indent 8 }} +{{ toYaml .Values.controller.nodeSelector | trimSuffix "\n" | indent 8 }} {{- end }} -{{- if eq .Values.controller.tolerations "icp" }} +{{- if .Values.controller.tolerations }} tolerations: - - key: "dedicated" - operator: "Exists" - effect: "NoSchedule" - - key: "CriticalAddonsOnly" - operator: "Exists" +{{ toYaml .Values.controller.tolerations | trimSuffix "\n" | indent 6 }} +{{- end }} +{{- if .Values.controller.affinity }} + affinity: +{{ toYaml .Values.controller.affinity | trimSuffix "\n" | indent 8 }} {{- end }} hostNetwork: {{ .Values.controller.hostNetwork }} containers: diff --git a/deployments/helm-chart/templates/controller-deployment.yaml b/deployments/helm-chart/templates/controller-deployment.yaml index 5de7de071b..4eb5e4ce20 100644 --- a/deployments/helm-chart/templates/controller-deployment.yaml +++ b/deployments/helm-chart/templates/controller-deployment.yaml @@ -23,6 +23,18 @@ spec: prometheus.io/port: "{{ .Values.prometheus.port }}" {{- end }} spec: +{{- if .Values.controller.nodeSelector }} + nodeSelector: +{{ toYaml .Values.controller.nodeSelector | trimSuffix "\n" | indent 8 }} +{{- end }} +{{- if .Values.controller.tolerations }} + tolerations: +{{ toYaml .Values.controller.tolerations | trimSuffix "\n" | indent 6 }} +{{- end }} +{{- if .Values.controller.affinity }} + affinity: +{{ toYaml .Values.controller.affinity | trimSuffix "\n" | indent 8 }} +{{- end }} serviceAccountName: {{ .Values.controller.serviceAccount.name }} hostNetwork: {{ .Values.controller.hostNetwork }} containers: diff --git a/deployments/helm-chart/values-icp.yaml b/deployments/helm-chart/values-icp.yaml index 2b30fdd24d..da70f1a1fa 100644 --- a/deployments/helm-chart/values-icp.yaml +++ b/deployments/helm-chart/values-icp.yaml @@ -7,4 +7,9 @@ controller: nodeSelector: { beta.kubernetes.io/arch: "amd64", proxy: "true" } terminationGracePeriodSeconds: 60 - tolerations: "icp" + tolerations: + - key: "dedicated" + operator: "Exists" + effect: "NoSchedule" + - key: "CriticalAddonsOnly" + operator: "Exists" diff --git a/deployments/helm-chart/values.yaml b/deployments/helm-chart/values.yaml index 0df41e79bb..b58eec0a75 100644 --- a/deployments/helm-chart/values.yaml +++ b/deployments/helm-chart/values.yaml @@ -17,7 +17,8 @@ controller: # secret: / nodeSelector: {} terminationGracePeriodSeconds: 30 - tolerations: "" + tolerations: [] + affinity: {} replicaCount: 1 ingressClass: nginx useIngressClassOnly: false From 7d420c87f2bebcc8c5e42c2702a74161cbdad05c Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 27 Nov 2018 14:48:43 +0000 Subject: [PATCH 2/5] Increment helm chart version --- deployments/helm-chart/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/helm-chart/Chart.yaml b/deployments/helm-chart/Chart.yaml index 1422cd51be..247ad1250c 100644 --- a/deployments/helm-chart/Chart.yaml +++ b/deployments/helm-chart/Chart.yaml @@ -1,5 +1,5 @@ name: nginx-ingress -version: 0.2.0 +version: 0.3.0 appVersion: edge description: NGINX Ingress Controller sources: From b485cba9c43b9988cddf43f722c27f3214b37f33 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Fri, 30 Nov 2018 01:43:02 +0000 Subject: [PATCH 3/5] Helm: Update readme with affinities, tolerations Signed-off-by: Dean Coakley --- deployments/helm-chart/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deployments/helm-chart/README.md b/deployments/helm-chart/README.md index 476f515f83..cf094f0fd0 100644 --- a/deployments/helm-chart/README.md +++ b/deployments/helm-chart/README.md @@ -71,7 +71,8 @@ Parameter | Description | Default `controller.defaultTLS.secret` | The secret with a TLS certificate and key for the default HTTPS server. The value must follow the following format: `/`. Used as an alternative to specifiying a certifcate and key using `controller.defaultTLS.cert` and `controller.defaultTLS.key` parameters. | None `controller.nodeSelector` | The node selector for pod assignment for the Ingress controller pods. | { } `controller.terminationGracePeriodSeconds` | The termination grace period of the Ingress controller pod. | 30 -`controller.tolerations` | The tolerations required for the IBM Cloud Private installation. | None +`controller.tolerations` | The taints to tolerate for the Ingress controller pods. | [] +`controller.affinity` | The affinities of the ingress controller pods. | { } `controller.replicaCount` | The number of replicas of the Ingress controller deployment. | 1 `controller.service.create` | Creates a service to expose the Ingress controller pods. | true `controller.service.type` | The type of service to create for the Ingress controller. | LoadBalancer From 9326ba09215ea443ca81709d9c9ba228063e1b6b Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Sat, 1 Dec 2018 03:20:16 +0000 Subject: [PATCH 4/5] Fix icp-values.yaml formatting --- deployments/helm-chart/values-icp.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/deployments/helm-chart/values-icp.yaml b/deployments/helm-chart/values-icp.yaml index da70f1a1fa..71b0b7ab37 100644 --- a/deployments/helm-chart/values-icp.yaml +++ b/deployments/helm-chart/values-icp.yaml @@ -4,8 +4,9 @@ controller: image: repository: mycluster.icp:8500/kube-system/nginx-plus-ingress tag: "edge" - nodeSelector: { beta.kubernetes.io/arch: "amd64", - proxy: "true" } + nodeSelector: + beta.kubernetes.io/arch: "amd64" + proxy: true terminationGracePeriodSeconds: 60 tolerations: - key: "dedicated" From 8e4062ead3ef59ceb2643f7d67b2428db83de60a Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Mon, 3 Dec 2018 18:54:23 +0000 Subject: [PATCH 5/5] Fix helm documentation. Remove trimSuffix * Simplify documentation of affinity and tolerations in the helm chart. * trimSuffix removes a trailing newline produced by toYaml. This newline is harmless, and trimSuffix was inconsistent with the rest of the templates. So it was removed. --- deployments/helm-chart/README.md | 4 ++-- deployments/helm-chart/templates/controller-daemonset.yaml | 6 +++--- deployments/helm-chart/templates/controller-deployment.yaml | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/deployments/helm-chart/README.md b/deployments/helm-chart/README.md index cf094f0fd0..b69e785374 100644 --- a/deployments/helm-chart/README.md +++ b/deployments/helm-chart/README.md @@ -71,8 +71,8 @@ Parameter | Description | Default `controller.defaultTLS.secret` | The secret with a TLS certificate and key for the default HTTPS server. The value must follow the following format: `/`. Used as an alternative to specifiying a certifcate and key using `controller.defaultTLS.cert` and `controller.defaultTLS.key` parameters. | None `controller.nodeSelector` | The node selector for pod assignment for the Ingress controller pods. | { } `controller.terminationGracePeriodSeconds` | The termination grace period of the Ingress controller pod. | 30 -`controller.tolerations` | The taints to tolerate for the Ingress controller pods. | [] -`controller.affinity` | The affinities of the ingress controller pods. | { } +`controller.tolerations` | The tolerations of the Ingress controller pods. | [] +`controller.affinity` | The affinity of the Ingress controller pods. | { } `controller.replicaCount` | The number of replicas of the Ingress controller deployment. | 1 `controller.service.create` | Creates a service to expose the Ingress controller pods. | true `controller.service.type` | The type of service to create for the Ingress controller. | LoadBalancer diff --git a/deployments/helm-chart/templates/controller-daemonset.yaml b/deployments/helm-chart/templates/controller-daemonset.yaml index a55fed003b..7fe9f2c5c9 100644 --- a/deployments/helm-chart/templates/controller-daemonset.yaml +++ b/deployments/helm-chart/templates/controller-daemonset.yaml @@ -26,15 +26,15 @@ spec: terminationGracePeriodSeconds: {{ .Values.controller.terminationGracePeriodSeconds }} {{- if .Values.controller.nodeSelector }} nodeSelector: -{{ toYaml .Values.controller.nodeSelector | trimSuffix "\n" | indent 8 }} +{{ toYaml .Values.controller.nodeSelector | indent 8 }} {{- end }} {{- if .Values.controller.tolerations }} tolerations: -{{ toYaml .Values.controller.tolerations | trimSuffix "\n" | indent 6 }} +{{ toYaml .Values.controller.tolerations | indent 6 }} {{- end }} {{- if .Values.controller.affinity }} affinity: -{{ toYaml .Values.controller.affinity | trimSuffix "\n" | indent 8 }} +{{ toYaml .Values.controller.affinity | indent 8 }} {{- end }} hostNetwork: {{ .Values.controller.hostNetwork }} containers: diff --git a/deployments/helm-chart/templates/controller-deployment.yaml b/deployments/helm-chart/templates/controller-deployment.yaml index 4eb5e4ce20..00932d441f 100644 --- a/deployments/helm-chart/templates/controller-deployment.yaml +++ b/deployments/helm-chart/templates/controller-deployment.yaml @@ -25,15 +25,15 @@ spec: spec: {{- if .Values.controller.nodeSelector }} nodeSelector: -{{ toYaml .Values.controller.nodeSelector | trimSuffix "\n" | indent 8 }} +{{ toYaml .Values.controller.nodeSelector | indent 8 }} {{- end }} {{- if .Values.controller.tolerations }} tolerations: -{{ toYaml .Values.controller.tolerations | trimSuffix "\n" | indent 6 }} +{{ toYaml .Values.controller.tolerations | indent 6 }} {{- end }} {{- if .Values.controller.affinity }} affinity: -{{ toYaml .Values.controller.affinity | trimSuffix "\n" | indent 8 }} +{{ toYaml .Values.controller.affinity | indent 8 }} {{- end }} serviceAccountName: {{ .Values.controller.serviceAccount.name }} hostNetwork: {{ .Values.controller.hostNetwork }}