docs: add description about common.serviceMonitor.secret

This commit is contained in:
Chi-En Wu
2020-04-23 15:13:37 +08:00
parent 8a8bb283d1
commit 347f9339f5

View File

@ -19,6 +19,7 @@ It provides utilities that reflect best practices of Kubernetes chart developmen
* [`common.service`](#commonservice) * [`common.service`](#commonservice)
* [`common.serviceAccount`](#commonserviceaccount) * [`common.serviceAccount`](#commonserviceaccount)
* [`common.serviceMonitor`](#commonservicemonitor) * [`common.serviceMonitor`](#commonservicemonitor)
* [`common.serviceMonitor.secret`](#commonservicemonitorsecret)
- [Partial Objects](#partial-objects) - [Partial Objects](#partial-objects)
* [`common.container`](#commoncontainer) * [`common.container`](#commoncontainer)
* [`common.pod.template`](#commonpodtemplate) * [`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 ## Partial Objects
When writing Kubernetes resources, you may find the following helpers useful to construct parts of the spec. When writing Kubernetes resources, you may find the following helpers useful to construct parts of the spec.