-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
willyi
committed
Sep 2, 2024
1 parent
3e517f6
commit 2c8574f
Showing
25 changed files
with
1,921 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: v2 | ||
name: kube-state-metrics | ||
description: Install kube-state-metrics to generate and expose cluster-level metrics | ||
keywords: | ||
- metric | ||
- monitor | ||
- prometheus | ||
- kubernetes | ||
type: application | ||
version: 5.25.1 | ||
appVersion: 2.13.0 | ||
home: https://github.com/kubernetes/kube-state-metrics/ | ||
sources: | ||
- https://github.com/kubernetes/kube-state-metrics/ | ||
maintainers: | ||
- name: willyi | ||
email: [email protected] | ||
annotations: | ||
"artifacthub.io/license": Apache-2.0 | ||
"artifacthub.io/links": | | ||
- name: Chart Source | ||
url: https://github.com/prometheus-community/helm-charts | ||
kubeVerion: '>= 1.12.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# kube-state-metrics Helm Chart | ||
|
||
Installs the [kube-state-metrics agent](https://github.com/kubernetes/kube-state-metrics). | ||
|
||
## Get Repository Info | ||
<!-- textlint-disable --> | ||
```console | ||
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts | ||
helm repo update | ||
``` | ||
|
||
_See [helm repo](https://helm.sh/docs/helm/helm_repo/) for command documentation._ | ||
<!-- textlint-enable --> | ||
|
||
## Install Chart | ||
|
||
```console | ||
helm install [RELEASE_NAME] prometheus-community/kube-state-metrics [flags] | ||
``` | ||
|
||
_See [configuration](#configuration) below._ | ||
|
||
_See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._ | ||
|
||
## Uninstall Chart | ||
|
||
```console | ||
helm uninstall [RELEASE_NAME] | ||
``` | ||
|
||
This removes all the Kubernetes components associated with the chart and deletes the release. | ||
|
||
_See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._ | ||
|
||
## Upgrading Chart | ||
|
||
```console | ||
helm upgrade [RELEASE_NAME] prometheus-community/kube-state-metrics [flags] | ||
``` | ||
|
||
_See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._ | ||
|
||
### Migrating from stable/kube-state-metrics and kubernetes/kube-state-metrics | ||
|
||
You can upgrade in-place: | ||
|
||
1. [get repository info](#get-repository-info) | ||
1. [upgrade](#upgrading-chart) your existing release name using the new chart repository | ||
|
||
## Upgrading to v3.0.0 | ||
|
||
v3.0.0 includes kube-state-metrics v2.0, see the [changelog](https://github.com/kubernetes/kube-state-metrics/blob/release-2.0/CHANGELOG.md) for major changes on the application-side. | ||
|
||
The upgraded chart now the following changes: | ||
|
||
* Dropped support for helm v2 (helm v3 or later is required) | ||
* collectors key was renamed to resources | ||
* namespace key was renamed to namespaces | ||
|
||
## Configuration | ||
|
||
See [Customizing the Chart Before Installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). To see all configurable options with detailed comments: | ||
|
||
```console | ||
helm show values prometheus-community/kube-state-metrics | ||
``` | ||
|
||
### kube-rbac-proxy | ||
|
||
You can enable `kube-state-metrics` endpoint protection using `kube-rbac-proxy`. By setting `kubeRBACProxy.enabled: true`, this chart will deploy one RBAC proxy container per endpoint (metrics & telemetry). | ||
To authorize access, authenticate your requests (via a `ServiceAccount` for example) with a `ClusterRole` attached such as: | ||
|
||
```yaml | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: kube-state-metrics-read | ||
rules: | ||
- apiGroups: [ "" ] | ||
resources: ["services/kube-state-metrics"] | ||
verbs: | ||
- get | ||
``` | ||
See [kube-rbac-proxy examples](https://github.com/brancz/kube-rbac-proxy/tree/master/examples/resource-attributes) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
kube-state-metrics is a simple service that listens to the Kubernetes API server and generates metrics about the state of the objects. | ||
The exposed metrics can be found here: | ||
https://github.com/kubernetes/kube-state-metrics/blob/master/docs/README.md#exposed-metrics | ||
|
||
The metrics are exported on the HTTP endpoint /metrics on the listening port. | ||
In your case, {{ template "kube-state-metrics.fullname" . }}.{{ template "kube-state-metrics.namespace" . }}.svc.cluster.local:{{ .Values.service.port }}/metrics | ||
|
||
They are served either as plaintext or protobuf depending on the Accept header. | ||
They are designed to be consumed either by Prometheus itself or by a scraper that is compatible with scraping a Prometheus client endpoint. | ||
|
||
{{- if .Values.kubeRBACProxy.enabled}} | ||
|
||
kube-rbac-proxy endpoint protections is enabled: | ||
- Metrics endpoints are now HTTPS | ||
- Ensure that the client authenticates the requests (e.g. via service account) with the following role permissions: | ||
``` | ||
rules: | ||
- apiGroups: [ "" ] | ||
resources: ["services/{{ template "kube-state-metrics.fullname" . }}"] | ||
verbs: | ||
- get | ||
``` | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "kube-state-metrics.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "kube-state-metrics.fullname" -}} | ||
{{- if .Values.fullnameOverride -}} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- else -}} | ||
{{- $name := default .Chart.Name .Values.nameOverride -}} | ||
{{- if contains $name .Release.Name -}} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}} | ||
{{- else -}} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "kube-state-metrics.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create -}} | ||
{{ default (include "kube-state-metrics.fullname" .) .Values.serviceAccount.name }} | ||
{{- else -}} | ||
{{ default "default" .Values.serviceAccount.name }} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Allow the release namespace to be overridden for multi-namespace deployments in combined charts | ||
*/}} | ||
{{- define "kube-state-metrics.namespace" -}} | ||
{{- if .Values.namespaceOverride -}} | ||
{{- .Values.namespaceOverride -}} | ||
{{- else -}} | ||
{{- .Release.Namespace -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "kube-state-metrics.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Generate basic labels | ||
*/}} | ||
{{- define "kube-state-metrics.labels" }} | ||
helm.sh/chart: {{ template "kube-state-metrics.chart" . }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
app.kubernetes.io/component: metrics | ||
app.kubernetes.io/part-of: {{ template "kube-state-metrics.name" . }} | ||
{{- include "kube-state-metrics.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
{{- if .Values.customLabels }} | ||
{{ tpl (toYaml .Values.customLabels) . }} | ||
{{- end }} | ||
{{- if .Values.releaseLabel }} | ||
release: {{ .Release.Name }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "kube-state-metrics.selectorLabels" }} | ||
{{- if .Values.selectorOverride }} | ||
{{ toYaml .Values.selectorOverride }} | ||
{{- else }} | ||
app.kubernetes.io/name: {{ include "kube-state-metrics.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* Sets default scrape limits for servicemonitor */}} | ||
{{- define "servicemonitor.scrapeLimits" -}} | ||
{{- with .sampleLimit }} | ||
sampleLimit: {{ . }} | ||
{{- end }} | ||
{{- with .targetLimit }} | ||
targetLimit: {{ . }} | ||
{{- end }} | ||
{{- with .labelLimit }} | ||
labelLimit: {{ . }} | ||
{{- end }} | ||
{{- with .labelNameLengthLimit }} | ||
labelNameLengthLimit: {{ . }} | ||
{{- end }} | ||
{{- with .labelValueLengthLimit }} | ||
labelValueLengthLimit: {{ . }} | ||
{{- end }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Formats imagePullSecrets. Input is (dict "Values" .Values "imagePullSecrets" .{specific imagePullSecrets}) | ||
*/}} | ||
{{- define "kube-state-metrics.imagePullSecrets" -}} | ||
{{- range (concat .Values.global.imagePullSecrets .imagePullSecrets) }} | ||
{{- if eq (typeOf .) "map[string]interface {}" }} | ||
- {{ toYaml . | trim }} | ||
{{- else }} | ||
- name: {{ . }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end -}} | ||
|
||
{{/* | ||
The image to use for kube-state-metrics | ||
*/}} | ||
{{- define "kube-state-metrics.image" -}} | ||
{{- if .Values.image.sha }} | ||
{{- if .Values.global.imageRegistry }} | ||
{{- printf "%s/%s:%s@%s" .Values.global.imageRegistry .Values.image.repository (default (printf "v%s" .Chart.AppVersion) .Values.image.tag) .Values.image.sha }} | ||
{{- else }} | ||
{{- printf "%s/%s:%s@%s" .Values.image.registry .Values.image.repository (default (printf "v%s" .Chart.AppVersion) .Values.image.tag) .Values.image.sha }} | ||
{{- end }} | ||
{{- else }} | ||
{{- if .Values.global.imageRegistry }} | ||
{{- printf "%s/%s:%s" .Values.global.imageRegistry .Values.image.repository (default (printf "v%s" .Chart.AppVersion) .Values.image.tag) }} | ||
{{- else }} | ||
{{- printf "%s/%s:%s" .Values.image.registry .Values.image.repository (default (printf "v%s" .Chart.AppVersion) .Values.image.tag) }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
The image to use for kubeRBACProxy | ||
*/}} | ||
{{- define "kubeRBACProxy.image" -}} | ||
{{- if .Values.kubeRBACProxy.image.sha }} | ||
{{- if .Values.global.imageRegistry }} | ||
{{- printf "%s/%s:%s@%s" .Values.global.imageRegistry .Values.kubeRBACProxy.image.repository (default (printf "v%s" .Chart.AppVersion) .Values.kubeRBACProxy.image.tag) .Values.kubeRBACProxy.image.sha }} | ||
{{- else }} | ||
{{- printf "%s/%s:%s@%s" .Values.kubeRBACProxy.image.registry .Values.kubeRBACProxy.image.repository (default (printf "v%s" .Chart.AppVersion) .Values.kubeRBACProxy.image.tag) .Values.kubeRBACProxy.image.sha }} | ||
{{- end }} | ||
{{- else }} | ||
{{- if .Values.global.imageRegistry }} | ||
{{- printf "%s/%s:%s" .Values.global.imageRegistry .Values.kubeRBACProxy.image.repository (default (printf "v%s" .Chart.AppVersion) .Values.kubeRBACProxy.image.tag) }} | ||
{{- else }} | ||
{{- printf "%s/%s:%s" .Values.kubeRBACProxy.image.registry .Values.kubeRBACProxy.image.repository (default (printf "v%s" .Chart.AppVersion) .Values.kubeRBACProxy.image.tag) }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
33 changes: 33 additions & 0 deletions
33
incubator/kube-state-metrics/templates/ciliumnetworkpolicy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{{- if and .Values.networkPolicy.enabled (eq .Values.networkPolicy.flavor "cilium") }} | ||
apiVersion: cilium.io/v2 | ||
kind: CiliumNetworkPolicy | ||
metadata: | ||
{{- if .Values.annotations }} | ||
annotations: | ||
{{ toYaml .Values.annotations | nindent 4 }} | ||
{{- end }} | ||
labels: | ||
{{- include "kube-state-metrics.labels" . | indent 4 }} | ||
name: {{ template "kube-state-metrics.fullname" . }} | ||
namespace: {{ template "kube-state-metrics.namespace" . }} | ||
spec: | ||
endpointSelector: | ||
matchLabels: | ||
{{- include "kube-state-metrics.selectorLabels" . | indent 6 }} | ||
egress: | ||
{{- if and .Values.networkPolicy.cilium .Values.networkPolicy.cilium.kubeApiServerSelector }} | ||
{{ toYaml .Values.networkPolicy.cilium.kubeApiServerSelector | nindent 6 }} | ||
{{- else }} | ||
- toEntities: | ||
- kube-apiserver | ||
{{- end }} | ||
ingress: | ||
- toPorts: | ||
- ports: | ||
- port: {{ .Values.service.port | quote }} | ||
protocol: TCP | ||
{{- if .Values.selfMonitor.enabled }} | ||
- port: {{ .Values.selfMonitor.telemetryPort | default 8081 | quote }} | ||
protocol: TCP | ||
{{ end }} | ||
{{ end }} |
20 changes: 20 additions & 0 deletions
20
incubator/kube-state-metrics/templates/clusterrolebinding.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{- if and .Values.rbac.create .Values.rbac.useClusterRole -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
labels: | ||
{{- include "kube-state-metrics.labels" . | indent 4 }} | ||
name: {{ template "kube-state-metrics.fullname" . }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
{{- if .Values.rbac.useExistingRole }} | ||
name: {{ .Values.rbac.useExistingRole }} | ||
{{- else }} | ||
name: {{ template "kube-state-metrics.fullname" . }} | ||
{{- end }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ template "kube-state-metrics.serviceAccountName" . }} | ||
namespace: {{ template "kube-state-metrics.namespace" . }} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{- if .Values.customResourceState.enabled}} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ template "kube-state-metrics.fullname" . }}-customresourcestate-config | ||
namespace: {{ template "kube-state-metrics.namespace" . }} | ||
labels: | ||
{{- include "kube-state-metrics.labels" . | indent 4 }} | ||
{{- if .Values.annotations }} | ||
annotations: | ||
{{ toYaml .Values.annotations | nindent 4 }} | ||
{{- end }} | ||
data: | ||
config.yaml: | | ||
{{- toYaml .Values.customResourceState.config | nindent 4 }} | ||
{{- end }} |
Oops, something went wrong.