Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ability to read prometheus basic auth creds from secret #13035

Merged
merged 7 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ require (
github.com/huandu/xstrings v1.4.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
Expand All @@ -116,6 +117,7 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc6 // indirect
Expand Down
1 change: 1 addition & 0 deletions viz/charts/linkerd-viz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ Kubernetes: `>=1.22.0-0`
| prometheus.scrapeConfigs | string | `nil` | A scrapeConfigs section specifies a set of targets and parameters describing how to scrape them. |
| prometheus.sidecarContainers | string | `nil` | A sidecarContainers section specifies a list of secondary containers to run in the prometheus pod e.g. to export data to non-prometheus systems |
| prometheus.tolerations | string | `nil` | Tolerations section, See the [K8S documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) for more information |
| prometheusCredsSecret | string | `""` | name of the prometheus credentials secret If this is set, the metrics-api will use basic auth to connect to prometheus and load the user and password from the "user" and "password" keys respectively in the given secret. The secret must be in the same namespace and must exist before the metrics-api is deployed. |
alpeb marked this conversation as resolved.
Show resolved Hide resolved
| prometheusUrl | string | `""` | url of external prometheus instance |
| revisionHistoryLimit | int | `10` | Specifies the number of old ReplicaSets to retain to allow rollback. |
| tap.GID | string | `nil` | GID for the tap component |
Expand Down
37 changes: 37 additions & 0 deletions viz/charts/linkerd-viz/templates/metrics-api-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,43 @@ subjects:
name: metrics-api
namespace: {{.Release.Namespace}}
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: prometheus-credentials
namespace: {{.Release.Namespace}}
labels:
linkerd.io/extension: viz
component: metrics-api
{{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
rules:
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
- list
- watch
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: metrics-api-prometheus-credentials
namespace: {{.Release.Namespace}}
labels:
linkerd.io/extension: viz
component: metrics-api
{{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: prometheus-credentials
subjects:
- kind: ServiceAccount
name: metrics-api
namespace: {{.Release.Namespace}}
---
kind: ServiceAccount
apiVersion: v1
metadata:
Expand Down
4 changes: 4 additions & 0 deletions viz/charts/linkerd-viz/templates/metrics-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ spec:
{{- else }}
{{ fail "Please enable `linkerd-prometheus` or provide `prometheusUrl` for the viz extension to function properly"}}
{{- end }}
{{- if .Values.prometheusCredsSecret }}
- -prometheus-creds-secret={{.Values.prometheusCredsSecret}}
{{- end}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIOLI: use {{- with .Values.prometheusCredsSecret}} to avoid repeating .Values.prometheusCredsSecret and just using {{ . }}

- -enable-pprof={{.Values.enablePprof | default false}}
- -viz-namespace={{.Release.Namespace}}
image: {{.Values.metricsAPI.image.registry | default .Values.defaultRegistry}}/{{.Values.metricsAPI.image.name}}:{{.Values.metricsAPI.image.tag | default .Values.linkerdVersion}}
imagePullPolicy: {{.Values.metricsAPI.image.pullPolicy | default .Values.defaultImagePullPolicy}}
livenessProbe:
Expand Down
7 changes: 7 additions & 0 deletions viz/charts/linkerd-viz/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ enablePSP: false
# -- url of external prometheus instance
prometheusUrl: ""

# -- name of the prometheus credentials secret
# If this is set, the metrics-api will use basic auth to connect to prometheus
# and load the user and password from the "user" and "password" keys
# respectively in the given secret. The secret must be in the same namespace
# and must exist before the metrics-api is deployed.
prometheusCredsSecret: ""

# -- url of external jaeger instance
# Set this to `jaeger.linkerd-jaeger.svc.<clusterDomain>:16686` if you plan to use jaeger extension
jaegerUrl: ""
Expand Down
38 changes: 37 additions & 1 deletion viz/cmd/testdata/install_default.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 37 additions & 1 deletion viz/cmd/testdata/install_default_overrides.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 37 additions & 1 deletion viz/cmd/testdata/install_prometheus_disabled.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 37 additions & 1 deletion viz/cmd/testdata/install_prometheus_loglevel_from_args.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 37 additions & 1 deletion viz/cmd/testdata/install_proxy_resources.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading