Skip to content

Commit c00d400

Browse files
committed
Moved kube-state-metrics related templates to directory
1 parent a1a1b04 commit c00d400

10 files changed

+111
-123
lines changed

stable/yugaware/templates/_helpers.tpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ Make list of allowed CORS origins
117117
kube-state-metrics
118118
*/}}
119119
{{- define "yugaware.kubeStateMetrics.endpoint" -}}
120-
{{- if .Values.kubeStateMetric.customEndpoint -}}
121-
{{- .Values.kubeStateMetric.customEndpoint -}}
122-
{{- else if .Values.kubeStateMetric.install -}}
120+
{{- if .Values.kubeStateMetrics.customEndpoint -}}
121+
{{- .Values.kubeStateMetrics.customEndpoint -}}
122+
{{- else if .Values.kubeStateMetrics.install -}}
123123
{{- printf "%s-ksm.%s.svc.%s:8080" .Release.Name .Release.Namespace .Values.domainName -}}
124124
{{- else -}}
125125
{{- printf "kube-state-metrics.kube-system.svc.%s:8080" .Values.domainName -}}

stable/yugaware/templates/configs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ data:
332332
333333
- job_name: 'kube-state-metrics'
334334
static_configs:
335-
- targets: ['{{ template "kubeStateMetric.endpoint" . }}']
335+
- targets: ['{{ template "yugaware.kubeStateMetrics.endpoint" . }}']
336336
metric_relabel_configs:
337337
# Save the name of the metric so we can group_by since we cannot by __name__ directly...
338338
- source_labels: ["__name__"]

stable/yugaware/templates/kube-state-metrics-deployment.yaml

Lines changed: 0 additions & 67 deletions
This file was deleted.

stable/yugaware/templates/kube-state-metrics-service-account.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

stable/yugaware/templates/kube-state-metrics-clusterrole.yaml renamed to stable/yugaware/templates/kube-state-metrics/kube-state-metrics-clusterrole.yaml

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# Adapted from https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-state-metrics (Apache-2.0 license)
2-
{{- if and .Values.kubeStateMetric.install (not .Values.kubeStateMetric.customEndpoint) -}}
1+
{{- /*
2+
Adapted from https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-state-metrics (Apache-2.0 license).
3+
*/}}
4+
{{- if and .Values.kubeStateMetrics.install (not .Values.kubeStateMetrics.customEndpoint) -}}
35
apiVersion: rbac.authorization.k8s.io/v1
46
kind: ClusterRole
57
metadata:
@@ -9,169 +11,169 @@ metadata:
911
release: {{ .Release.Name }}
1012
name: {{ .Release.Name }}-ksm
1113
rules:
12-
{{ if has "certificatesigningrequests" $.Values.kubeStateMetric.collectors }}
14+
{{ if has "certificatesigningrequests" $.Values.kubeStateMetrics.collectors }}
1315
- apiGroups: ["certificates.k8s.io"]
1416
resources:
1517
- certificatesigningrequests
1618
verbs: ["list", "watch"]
1719
{{ end -}}
18-
{{ if has "configmaps" $.Values.kubeStateMetric.collectors }}
20+
{{ if has "configmaps" $.Values.kubeStateMetrics.collectors }}
1921
- apiGroups: [""]
2022
resources:
2123
- configmaps
2224
verbs: ["list", "watch"]
2325
{{ end -}}
24-
{{ if has "cronjobs" $.Values.kubeStateMetric.collectors }}
26+
{{ if has "cronjobs" $.Values.kubeStateMetrics.collectors }}
2527
- apiGroups: ["batch"]
2628
resources:
2729
- cronjobs
2830
verbs: ["list", "watch"]
2931
{{ end -}}
30-
{{ if has "daemonsets" $.Values.kubeStateMetric.collectors }}
32+
{{ if has "daemonsets" $.Values.kubeStateMetrics.collectors }}
3133
- apiGroups: ["extensions", "apps"]
3234
resources:
3335
- daemonsets
3436
verbs: ["list", "watch"]
3537
{{ end -}}
36-
{{ if has "deployments" $.Values.kubeStateMetric.collectors }}
38+
{{ if has "deployments" $.Values.kubeStateMetrics.collectors }}
3739
- apiGroups: ["extensions", "apps"]
3840
resources:
3941
- deployments
4042
verbs: ["list", "watch"]
4143
{{ end -}}
42-
{{ if has "endpoints" $.Values.kubeStateMetric.collectors }}
44+
{{ if has "endpoints" $.Values.kubeStateMetrics.collectors }}
4345
- apiGroups: [""]
4446
resources:
4547
- endpoints
4648
verbs: ["list", "watch"]
4749
{{ end -}}
48-
{{ if has "horizontalpodautoscalers" $.Values.kubeStateMetric.collectors }}
50+
{{ if has "horizontalpodautoscalers" $.Values.kubeStateMetrics.collectors }}
4951
- apiGroups: ["autoscaling"]
5052
resources:
5153
- horizontalpodautoscalers
5254
verbs: ["list", "watch"]
5355
{{ end -}}
54-
{{ if has "ingresses" $.Values.kubeStateMetric.collectors }}
56+
{{ if has "ingresses" $.Values.kubeStateMetrics.collectors }}
5557
- apiGroups: ["extensions", "networking.k8s.io"]
5658
resources:
5759
- ingresses
5860
verbs: ["list", "watch"]
5961
{{ end -}}
60-
{{ if has "jobs" $.Values.kubeStateMetric.collectors }}
62+
{{ if has "jobs" $.Values.kubeStateMetrics.collectors }}
6163
- apiGroups: ["batch"]
6264
resources:
6365
- jobs
6466
verbs: ["list", "watch"]
6567
{{ end -}}
66-
{{ if has "limitranges" $.Values.kubeStateMetric.collectors }}
68+
{{ if has "limitranges" $.Values.kubeStateMetrics.collectors }}
6769
- apiGroups: [""]
6870
resources:
6971
- limitranges
7072
verbs: ["list", "watch"]
7173
{{ end -}}
72-
{{ if has "mutatingwebhookconfigurations" $.Values.kubeStateMetric.collectors }}
74+
{{ if has "mutatingwebhookconfigurations" $.Values.kubeStateMetrics.collectors }}
7375
- apiGroups: ["admissionregistration.k8s.io"]
7476
resources:
7577
- mutatingwebhookconfigurations
7678
verbs: ["list", "watch"]
7779
{{ end -}}
78-
{{ if has "namespaces" $.Values.kubeStateMetric.collectors }}
80+
{{ if has "namespaces" $.Values.kubeStateMetrics.collectors }}
7981
- apiGroups: [""]
8082
resources:
8183
- namespaces
8284
verbs: ["list", "watch"]
8385
{{ end -}}
84-
{{ if has "networkpolicies" $.Values.kubeStateMetric.collectors }}
86+
{{ if has "networkpolicies" $.Values.kubeStateMetrics.collectors }}
8587
- apiGroups: ["networking.k8s.io"]
8688
resources:
8789
- networkpolicies
8890
verbs: ["list", "watch"]
8991
{{ end -}}
90-
{{ if has "nodes" $.Values.kubeStateMetric.collectors }}
92+
{{ if has "nodes" $.Values.kubeStateMetrics.collectors }}
9193
- apiGroups: [""]
9294
resources:
9395
- nodes
9496
verbs: ["list", "watch"]
9597
{{ end -}}
96-
{{ if has "persistentvolumeclaims" $.Values.kubeStateMetric.collectors }}
98+
{{ if has "persistentvolumeclaims" $.Values.kubeStateMetrics.collectors }}
9799
- apiGroups: [""]
98100
resources:
99101
- persistentvolumeclaims
100102
verbs: ["list", "watch"]
101103
{{ end -}}
102-
{{ if has "persistentvolumes" $.Values.kubeStateMetric.collectors }}
104+
{{ if has "persistentvolumes" $.Values.kubeStateMetrics.collectors }}
103105
- apiGroups: [""]
104106
resources:
105107
- persistentvolumes
106108
verbs: ["list", "watch"]
107109
{{ end -}}
108-
{{ if has "poddisruptionbudgets" $.Values.kubeStateMetric.collectors }}
110+
{{ if has "poddisruptionbudgets" $.Values.kubeStateMetrics.collectors }}
109111
- apiGroups: ["policy"]
110112
resources:
111113
- poddisruptionbudgets
112114
verbs: ["list", "watch"]
113115
{{ end -}}
114-
{{ if has "pods" $.Values.kubeStateMetric.collectors }}
116+
{{ if has "pods" $.Values.kubeStateMetrics.collectors }}
115117
- apiGroups: [""]
116118
resources:
117119
- pods
118120
verbs: ["list", "watch"]
119121
{{ end -}}
120-
{{ if has "replicasets" $.Values.kubeStateMetric.collectors }}
122+
{{ if has "replicasets" $.Values.kubeStateMetrics.collectors }}
121123
- apiGroups: ["extensions", "apps"]
122124
resources:
123125
- replicasets
124126
verbs: ["list", "watch"]
125127
{{ end -}}
126-
{{ if has "replicationcontrollers" $.Values.kubeStateMetric.collectors }}
128+
{{ if has "replicationcontrollers" $.Values.kubeStateMetrics.collectors }}
127129
- apiGroups: [""]
128130
resources:
129131
- replicationcontrollers
130132
verbs: ["list", "watch"]
131133
{{ end -}}
132-
{{ if has "resourcequotas" $.Values.kubeStateMetric.collectors }}
134+
{{ if has "resourcequotas" $.Values.kubeStateMetrics.collectors }}
133135
- apiGroups: [""]
134136
resources:
135137
- resourcequotas
136138
verbs: ["list", "watch"]
137139
{{ end -}}
138-
{{ if has "secrets" $.Values.kubeStateMetric.collectors }}
140+
{{ if has "secrets" $.Values.kubeStateMetrics.collectors }}
139141
- apiGroups: [""]
140142
resources:
141143
- secrets
142144
verbs: ["list", "watch"]
143145
{{ end -}}
144-
{{ if has "services" $.Values.kubeStateMetric.collectors }}
146+
{{ if has "services" $.Values.kubeStateMetrics.collectors }}
145147
- apiGroups: [""]
146148
resources:
147149
- services
148150
verbs: ["list", "watch"]
149151
{{ end -}}
150-
{{ if has "statefulsets" $.Values.kubeStateMetric.collectors }}
152+
{{ if has "statefulsets" $.Values.kubeStateMetrics.collectors }}
151153
- apiGroups: ["apps"]
152154
resources:
153155
- statefulsets
154156
verbs: ["list", "watch"]
155157
{{ end -}}
156-
{{ if has "storageclasses" $.Values.kubeStateMetric.collectors }}
158+
{{ if has "storageclasses" $.Values.kubeStateMetrics.collectors }}
157159
- apiGroups: ["storage.k8s.io"]
158160
resources:
159161
- storageclasses
160162
verbs: ["list", "watch"]
161163
{{ end -}}
162-
{{ if has "validatingwebhookconfigurations" $.Values.kubeStateMetric.collectors }}
164+
{{ if has "validatingwebhookconfigurations" $.Values.kubeStateMetrics.collectors }}
163165
- apiGroups: ["admissionregistration.k8s.io"]
164166
resources:
165167
- validatingwebhookconfigurations
166168
verbs: ["list", "watch"]
167169
{{ end -}}
168-
{{ if has "volumeattachments" $.Values.kubeStateMetric.collectors }}
170+
{{ if has "volumeattachments" $.Values.kubeStateMetrics.collectors }}
169171
- apiGroups: ["storage.k8s.io"]
170172
resources:
171173
- volumeattachments
172174
verbs: ["list", "watch"]
173175
{{ end -}}
174-
{{ if has "verticalpodautoscalers" $.Values.kubeStateMetric.collectors }}
176+
{{ if has "verticalpodautoscalers" $.Values.kubeStateMetrics.collectors }}
175177
- apiGroups: ["autoscaling.k8s.io"]
176178
resources:
177179
- verticalpodautoscalers

stable/yugaware/templates/kube-state-metrics-clusterrolebinding.yaml renamed to stable/yugaware/templates/kube-state-metrics/kube-state-metrics-clusterrolebinding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.kubeStateMetric.install (not .Values.kubeStateMetric.customEndpoint) -}}
1+
{{- if and .Values.kubeStateMetrics.install (not .Values.kubeStateMetrics.customEndpoint) -}}
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRoleBinding
44
metadata:
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{{- /*
2+
Adapted from https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-state-metrics (Apache-2.0 license)
3+
*/}}
4+
{{- if and .Values.kubeStateMetrics.install (not .Values.kubeStateMetrics.customEndpoint) -}}
5+
apiVersion: apps/v1
6+
kind: Deployment
7+
metadata:
8+
name: {{ .Release.Name }}-ksm
9+
labels:
10+
app: {{ .Release.Name }}-yugaware-ksm
11+
chart: {{ template "yugaware.chart" . }}
12+
release: {{ .Release.Name }}
13+
spec:
14+
selector:
15+
matchLabels:
16+
app: {{ .Release.Name }}-yugaware-ksm
17+
replicas: {{ .Values.kubeStateMetrics.replicas }}
18+
template:
19+
metadata:
20+
labels:
21+
app: {{ .Release.Name }}-yugaware-ksm
22+
spec:
23+
serviceAccountName: {{ .Release.Name }}
24+
{{- if .Values.kubeStateMetrics.securityContext.enabled }}
25+
securityContext:
26+
fsGroup: {{ .Values.kubeStateMetrics.securityContext.fsGroup }}
27+
runAsGroup: {{ .Values.kubeStateMetrics.securityContext.runAsGroup }}
28+
runAsUser: {{ .Values.kubeStateMetrics.securityContext.runAsUser }}
29+
{{- end }}
30+
containers:
31+
- name: kube-state-metrics-yugaware
32+
args:
33+
{{- if .Values.kubeStateMetrics.extraArgs }}
34+
{{- range .Values.kubeStateMetrics.extraArgs }}
35+
- {{ . }}
36+
{{- end }}
37+
{{- end }}
38+
- --port=8080
39+
- --resources={{ .Values.kubeStateMetrics.collectors | join "," }}
40+
imagePullPolicy: {{ .Values.kubeStateMetrics.image.pullPolicy }}
41+
image: "{{ .Values.kubeStateMetrics.image.repository }}:{{ .Values.kubeStateMetrics.image.tag }}"
42+
ports:
43+
- containerPort: 8080
44+
name: "http"
45+
livenessProbe:
46+
httpGet:
47+
path: /healthz
48+
port: 8080
49+
initialDelaySeconds: 5
50+
timeoutSeconds: 5
51+
readinessProbe:
52+
httpGet:
53+
path: /
54+
port: 8080
55+
initialDelaySeconds: 5
56+
timeoutSeconds: 5
57+
{{- if .Values.kubeStateMetrics.resources }}
58+
resources:
59+
{{ toYaml .Values.kubeStateMetrics.resources | indent 10 }}
60+
{{- end }}
61+
{{- end -}}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{- if and .Values.kubeStateMetrics.install (not .Values.kubeStateMetrics.customEndpoint) -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
labels:
6+
app: {{ .Release.Name }}-yugaware-ksm
7+
chart: {{ template "yugaware.chart" . }}
8+
release: {{ .Release.Name }}
9+
name: {{ .Release.Name }}-ksm
10+
{{- end -}}

0 commit comments

Comments
 (0)