From 37c213fd5b81992e20edd9555e4601c185e77bd4 Mon Sep 17 00:00:00 2001 From: Eriks Zelenka <42933722+ezelenka@users.noreply.github.com> Date: Mon, 22 Jul 2019 15:22:52 +0100 Subject: [PATCH] [stable/newrelic-infrastructure] add ability to use custom secret for license key (#15707) * [stable/newrelic-infrastructure] add ability to use custom secret for license key Signed-off-by: Eriks Zelenka * fix: deduplicate code for license secret key mounting Signed-off-by: Eriks Zelenka * fix: improve readme and license key env variable instantiation code Signed-off-by: Eriks Zelenka --- stable/newrelic-infrastructure/Chart.yaml | 2 +- stable/newrelic-infrastructure/README.md | 10 ++++++---- .../templates/daemonset.yaml | 15 ++++++++++----- stable/newrelic-infrastructure/values.yaml | 5 +++++ 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/stable/newrelic-infrastructure/Chart.yaml b/stable/newrelic-infrastructure/Chart.yaml index 4693875580..b3b09643d3 100644 --- a/stable/newrelic-infrastructure/Chart.yaml +++ b/stable/newrelic-infrastructure/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 description: A Helm chart to deploy the New Relic Infrastructure Agent as a DaemonSet name: newrelic-infrastructure -version: 0.13.0 +version: 0.13.1 appVersion: 1.9.0 home: https://hub.docker.com/r/newrelic/infrastructure-k8s/ source: diff --git a/stable/newrelic-infrastructure/README.md b/stable/newrelic-infrastructure/README.md index 25c760e6e1..d596c69142 100644 --- a/stable/newrelic-infrastructure/README.md +++ b/stable/newrelic-infrastructure/README.md @@ -8,16 +8,18 @@ This chart will deploy the New Relic Infrastructure agent as a Daemonset. | Parameter | Description | Default | | ------------------------- | ------------------------------------------------------------ | -------------------------- | -| `cluster` | The cluster name for the Kubernetes cluster. | | -| `licenseKey` | The [license key](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/license-key) for your New Relic Account. | | -| `config` | A `newrelic.yml` file if you wish to provide. | | +| `cluster` | The cluster name for the Kubernetes cluster. | | +| `licenseKey` | The [license key](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/license-key) for your New Relic Account. This will be preferred configuration option if both `licenseKey` and `customSecret` are specified. | | +| `customSecret.name` | Name of the Secret object where the license key is stored | | +| `customSecret.key` | Key in the Secret object where the license key is stored. | | +| `config` | A `newrelic.yml` file if you wish to provide. | | | `kubeStateMetricsUrl` | If provided, the discovery process for kube-state-metrics endpoint won't be triggered. Example: http://172.17.0.3:8080 | | `kubeStateMetricsTimeout` | Timeout for accessing kube-state-metrics in milliseconds. If not set the newrelic default is 5000 | | | `rbac.create` | Enable Role-based authentication | `true` | | `rbac.pspEnabled` | Enable pod security policy support | `false` | | `image.name` | The container to pull. | `newrelic/infrastructure` | | `image.pullPolicy` | The pull policy. | `IfNotPresent` | -| `image.tag` | The version of the container to pull. | `1.9.0` | +| `image.tag` | The version of the container to pull. | `1.9.0` | | `resources` | Any resources you wish to assign to the pod. | See Resources below | | `verboseLog` | Should the agent log verbosely. (Boolean) | `false` | | `priorityClassName` | Scheduling priority of the pod | `nil` | diff --git a/stable/newrelic-infrastructure/templates/daemonset.yaml b/stable/newrelic-infrastructure/templates/daemonset.yaml index caf864bb95..e2b4fa535c 100644 --- a/stable/newrelic-infrastructure/templates/daemonset.yaml +++ b/stable/newrelic-infrastructure/templates/daemonset.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.licenseKey .Values.cluster }} +{{- if and (or .Values.licenseKey .Values.customSecret) .Values.cluster }} apiVersion: apps/v1beta2 kind: DaemonSet metadata: @@ -35,18 +35,23 @@ spec: - name: NRIA_LICENSE_KEY valueFrom: secretKeyRef: + {{- if .Values.licenseKey }} name: {{ template "newrelic.fullname" . }}-config key: license + {{- else }} + name: {{ .Values.customSecret.name }} + key: {{ .Values.customSecret.key }} + {{- end }} - name: "CLUSTER_NAME" value: "{{ .Values.cluster }}" - {{- if .Values.kubeStateMetricsUrl }} + {{- if .Values.kubeStateMetricsUrl }} - name: "KUBE_STATE_METRICS_URL" value: "{{ .Values.kubeStateMetricsUrl }}" - {{- end }} - {{- if .Values.kubeStateMetricsTimeout }} + {{- end }} + {{- if .Values.kubeStateMetricsTimeout }} - name: TIMEOUT value: {{ .Values.kubeStateMetricsTimeout | quote }} - {{- end }} + {{- end }} - name: "NRIA_DISPLAY_NAME" valueFrom: fieldRef: diff --git a/stable/newrelic-infrastructure/values.yaml b/stable/newrelic-infrastructure/values.yaml index 1ed1a412f6..9f866d4eb6 100644 --- a/stable/newrelic-infrastructure/values.yaml +++ b/stable/newrelic-infrastructure/values.yaml @@ -1,5 +1,10 @@ # IMPORTANT: Specify your New Relic API key here. # licenseKey: +# +# or Specify secret which contains New Relic API key +# customSecret: +# name: secret_name +# key: secret_key # IMPORTANT: The Kubernetes cluster name # https://docs.newrelic.com/docs/kubernetes-monitoring-integration