From 347f9339f5517c70b92ade32a136beb42ed6e8c5 Mon Sep 17 00:00:00 2001 From: Chi-En Wu Date: Thu, 23 Apr 2020 15:13:37 +0800 Subject: [PATCH] docs: add description about `common.serviceMonitor.secret` --- README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/README.md b/README.md index b4dbf33..650eb18 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ It provides utilities that reflect best practices of Kubernetes chart developmen * [`common.service`](#commonservice) * [`common.serviceAccount`](#commonserviceaccount) * [`common.serviceMonitor`](#commonservicemonitor) + * [`common.serviceMonitor.secret`](#commonservicemonitorsecret) - [Partial Objects](#partial-objects) * [`common.container`](#commoncontainer) * [`common.pod.template`](#commonpodtemplate) @@ -686,6 +687,59 @@ spec: +### `common.serviceMonitor.secret` + +The `common.serviceMonitor.secret` template accepts a list of three values: + +- `$top`, the top context +- `$serviceMonitor`, a dictionary of values used in the service account template +- [optional] the template name of the overrides + +It creates a `Secret` resource contains the BasicAuth information for the `SecretMonitor`. + +An example `values.yaml` for your `ServiceMonitor` could look like: + +```yaml +serviceMonitor: + basicAuth: + enabled: true + username: administrator + password: password +``` + +Example use: + +```yaml +{{- include "common.serviceMonitor.secret" (list . .Values.serviceMonitor) -}} + +## The following is the same as above: +# {{- include "common.serviceMonitor.secret" (list . .Values.serviceMonitor "mychart.serviceMonitor.secret") -}} +# {{- define "mychart.serviceMonitor.secret" -}} +# {{- end -}} +``` + +Output: + +```yaml +apiVersion: v1 +data: + password: cGFzc3dvcmQ= + username: YWRtaW5pc3RyYXRvcg== +kind: Secret +metadata: + labels: + app.kubernetes.io/instance: release-name + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: mychart + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: mychart-0.1.0 + name: release-name-mychart + namespace: monitoring +type: Opaque +``` + + + ## Partial Objects When writing Kubernetes resources, you may find the following helpers useful to construct parts of the spec.