From a9317af3d8d3e325c492b11b2dae6e033dce659c Mon Sep 17 00:00:00 2001 From: Alejandro Pedraza Date: Tue, 12 Jan 2021 10:56:43 -0500 Subject: [PATCH] Add back support for proxy resource settings (#5517) The last viz refactoring removed support for modifying the k8s resources used by the proxies injected into the control plane components (values like `tapProxyResources`, `prometheus.proxy.resources`, etc). This adds them back, using a consistent naming: `tap.proxy.resources`, `dashboard.proxy.resources`, etc. Also fixes the tap helm template that was making reference to `.Values.tapResources` instead of `.Values.tap.resources`. Co-authored-by: Kevin Leimkuhler --- .../partials/templates/_proxy-config-ann.tpl | 18 +++++++++++++++++ pkg/charts/charts.go | 1 + viz/charts/linkerd-viz/README.md | 4 ++++ viz/charts/linkerd-viz/templates/grafana.yaml | 3 +++ .../linkerd-viz/templates/prometheus.yaml | 3 +++ viz/charts/linkerd-viz/templates/tap.yaml | 7 +++++-- viz/charts/linkerd-viz/templates/web.yaml | 3 +++ viz/charts/linkerd-viz/values.yaml | 20 +++++++++++++++++++ viz/cmd/testdata/install_default.golden | 1 + .../install_prometheus_disabled.golden | 1 + 10 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 charts/partials/templates/_proxy-config-ann.tpl diff --git a/charts/partials/templates/_proxy-config-ann.tpl b/charts/partials/templates/_proxy-config-ann.tpl new file mode 100644 index 000000000..9651b3bd1 --- /dev/null +++ b/charts/partials/templates/_proxy-config-ann.tpl @@ -0,0 +1,18 @@ +{{- define "partials.proxy.config.annotations" -}} +{{- with .cpu }} +{{- with .request -}} +config.linkerd.io/proxy-cpu-request: {{. | quote}} +{{end}} +{{- with .limit -}} +config.linkerd.io/proxy-cpu-limit: {{. | quote}} +{{- end}} +{{- end}} +{{- with .memory }} +{{- with .request }} +config.linkerd.io/proxy-memory-request: {{. | quote}} +{{end}} +{{- with .limit -}} +config.linkerd.io/proxy-memory-limit: {{. | quote}} +{{- end}} +{{- end }} +{{- end }} diff --git a/pkg/charts/charts.go b/pkg/charts/charts.go index 492685b78..2dc9a4bce 100644 --- a/pkg/charts/charts.go +++ b/pkg/charts/charts.go @@ -22,6 +22,7 @@ var ( L5dPartials = []string{ "charts/partials/" + chartutil.ChartfileName, "charts/partials/templates/_proxy.tpl", + "charts/partials/templates/_proxy-config-ann.tpl", "charts/partials/templates/_proxy-init.tpl", "charts/partials/templates/_volumes.tpl", "charts/partials/templates/_resources.tpl", diff --git a/viz/charts/linkerd-viz/README.md b/viz/charts/linkerd-viz/README.md index 2bb527b40..4231f44d2 100644 --- a/viz/charts/linkerd-viz/README.md +++ b/viz/charts/linkerd-viz/README.md @@ -79,6 +79,7 @@ Kubernetes: `>=1.13.0-0` | dashboard.image.registry | string | `"ghcr.io/linkerd"` | Docker registry for the web instance | | dashboard.image.tag | string | `"linkerdVersionValue"` | Docker image tag for the web instance | | dashboard.logLevel | string | `"info"` | log level of the dashboard component | +| dashboard.proxy | string | `nil` | | | dashboard.replicas | int | `1` | Number of replicas of dashboard | | dashboard.resources.cpu.limit | string | `nil` | Maximum amount of CPU units that the web container can use | | dashboard.resources.cpu.request | string | `nil` | Amount of CPU units that the web container requests | @@ -93,6 +94,7 @@ Kubernetes: `>=1.13.0-0` | grafana.image.name | string | `"grafana"` | Docker image name for the grafana instance | | grafana.image.registry | string | `"ghcr.io/linkerd"` | Docker registry for the grafana instance | | grafana.image.tag | string | `"linkerdVersionValue"` | Docker image tag for the grafana instance | +| grafana.proxy | string | `nil` | | | grafana.resources.cpu.limit | string | `nil` | Maximum amount of CPU units that the grafana container can use | | grafana.resources.cpu.request | string | `nil` | Amount of CPU units that the grafana container requests | | grafana.resources.memory.limit | string | `nil` | Maximum amount of memory that grafana container can use | @@ -113,6 +115,7 @@ Kubernetes: `>=1.13.0-0` | prometheus.image.pullPolicy | string | `"Always"` | | | prometheus.image.registry | string | `"prom"` | Docker registry for the prometheus instance | | prometheus.image.tag | string | `"v2.19.3"` | Docker image tag for the prometheus instance | +| prometheus.proxy | string | `nil` | | | prometheus.remoteWrite | string | `nil` | Allows transparently sending samples to an endpoint. Mostly used for long term storage. | | prometheus.resources.cpu.limit | string | `nil` | Maximum amount of CPU units that the prometheus container can use | | prometheus.resources.cpu.request | string | `nil` | Amount of CPU units that the prometheus container requests | @@ -131,6 +134,7 @@ Kubernetes: `>=1.13.0-0` | tap.image.tag | string | `"linkerdVersionValue"` | Docker image tag for the tap instance | | tap.keyPEM | string | `""` | Certificate key for Tap component. If not provided then Helm will generate one. | | tap.logLevel | string | `"info"` | log level of the tap component | +| tap.proxy | string | `nil` | | | tap.replicas | int | `1` | | | tap.resources.cpu.limit | string | `nil` | Maximum amount of CPU units that the tap container can use | | tap.resources.cpu.request | string | `nil` | Amount of CPU units that the tap container requests | diff --git a/viz/charts/linkerd-viz/templates/grafana.yaml b/viz/charts/linkerd-viz/templates/grafana.yaml index 521494307..b31d6df2c 100644 --- a/viz/charts/linkerd-viz/templates/grafana.yaml +++ b/viz/charts/linkerd-viz/templates/grafana.yaml @@ -108,6 +108,9 @@ spec: metadata: annotations: {{.Values.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.linkerdVersion) .Values.cliVersion}} + {{- with .Values.grafana.proxy }} + {{- include "partials.proxy.config.annotations" .resources | nindent 8 }} + {{- end }} {{- with .Values.podAnnotations }}{{ toYaml . | trim | nindent 8 }}{{- end }} labels: {{.Values.extensionAnnotation}}: linkerd-viz diff --git a/viz/charts/linkerd-viz/templates/prometheus.yaml b/viz/charts/linkerd-viz/templates/prometheus.yaml index fc9af7058..17a60bbf6 100644 --- a/viz/charts/linkerd-viz/templates/prometheus.yaml +++ b/viz/charts/linkerd-viz/templates/prometheus.yaml @@ -221,6 +221,9 @@ spec: metadata: annotations: {{.Values.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.linkerdVersion) .Values.cliVersion}} + {{- with .Values.prometheus.proxy }} + {{- include "partials.proxy.config.annotations" .resources | nindent 8 }} + {{- end }} {{- with .Values.podAnnotations }}{{ . | trim | nindent 8 }}{{- end }} labels: {{.Values.extensionAnnotation}}: linkerd-viz diff --git a/viz/charts/linkerd-viz/templates/tap.yaml b/viz/charts/linkerd-viz/templates/tap.yaml index 6cce931e8..117b3a494 100644 --- a/viz/charts/linkerd-viz/templates/tap.yaml +++ b/viz/charts/linkerd-viz/templates/tap.yaml @@ -60,6 +60,9 @@ spec: checksum/config: {{ include (print $.Template.BasePath "/tap-rbac.yaml") . | sha256sum }} {{- end }} {{.Values.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.linkerdVersion) .Values.cliVersion}} + {{- with .Values.tap.proxy }} + {{- include "partials.proxy.config.annotations" .resources | nindent 8 }} + {{- end }} {{- with .Values.podAnnotations }}{{ toYaml . | trim | nindent 8 }}{{- end }} labels: {{.Values.extensionAnnotation}}: linkerd-viz @@ -101,8 +104,8 @@ spec: httpGet: path: /ready port: 9998 - {{- if .Values.tapResources -}} - {{- include "partials.resources" .Values.tapResources | nindent 8 }} + {{- if .Values.tap.resources -}} + {{- include "partials.resources" .Values.tap.resources | nindent 8 }} {{- end }} securityContext: runAsUser: {{.Values.tap.UID}} diff --git a/viz/charts/linkerd-viz/templates/web.yaml b/viz/charts/linkerd-viz/templates/web.yaml index 038c6013c..b16818a64 100644 --- a/viz/charts/linkerd-viz/templates/web.yaml +++ b/viz/charts/linkerd-viz/templates/web.yaml @@ -52,6 +52,9 @@ spec: metadata: annotations: {{.Values.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.linkerdVersion) .Values.cliVersion}} + {{- with .Values.dashboard.proxy }} + {{- include "partials.proxy.config.annotations" .resources | nindent 8 }} + {{- end }} {{- with .Values.podAnnotations }}{{ toYaml . | trim | nindent 8 }}{{- end }} labels: {{.Values.extensionAnnotation}}: linkerd-viz diff --git a/viz/charts/linkerd-viz/values.yaml b/viz/charts/linkerd-viz/values.yaml index 7ae09dea6..b9d57d305 100644 --- a/viz/charts/linkerd-viz/values.yaml +++ b/viz/charts/linkerd-viz/values.yaml @@ -99,6 +99,11 @@ tap: # -- Amount of memory that the tap container requests request: + proxy: + # -- If set, overrides default proxy resources for the proxy injected + # into the tap component + # resources: + UID: *uid # web dashboard configuration @@ -137,6 +142,11 @@ dashboard: # -- Amount of memory that the web container requests request: + proxy: + # -- If set, overrides default proxy resources for the proxy injected + # into the dashboard component + # resources: + grafana: # -- toggle field to enable or disable grafana enabled: true @@ -160,6 +170,11 @@ grafana: # -- Amount of memory that the grafana container requests request: + proxy: + # -- If set, overrides default proxy resources for the proxy injected + # into the grafana component + # resources: + prometheus: # -- toggle field to enable or disable prometheus enabled: true @@ -279,3 +294,8 @@ prometheus: limit: # -- Amount of memory that the prometheus container requests request: + + proxy: + # -- If set, overrides default proxy resources for the proxy injected + # into the prometheus component + # resources: diff --git a/viz/cmd/testdata/install_default.golden b/viz/cmd/testdata/install_default.golden index 05f5e11f4..819bf6aee 100644 --- a/viz/cmd/testdata/install_default.golden +++ b/viz/cmd/testdata/install_default.golden @@ -828,6 +828,7 @@ spec: httpGet: path: /ready port: 9998 + resources: securityContext: runAsUser: 2103 volumeMounts: diff --git a/viz/cmd/testdata/install_prometheus_disabled.golden b/viz/cmd/testdata/install_prometheus_disabled.golden index c057ec1f4..cd5522bd1 100644 --- a/viz/cmd/testdata/install_prometheus_disabled.golden +++ b/viz/cmd/testdata/install_prometheus_disabled.golden @@ -536,6 +536,7 @@ spec: httpGet: path: /ready port: 9998 + resources: securityContext: runAsUser: 2103 volumeMounts: