Skip to content

Commit

Permalink
Moved kube-state-metrics related templates to directory
Browse files Browse the repository at this point in the history
  • Loading branch information
baba230896 committed May 9, 2022
1 parent 919c53a commit 96676c2
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 123 deletions.
6 changes: 3 additions & 3 deletions stable/yugaware/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ Make list of allowed CORS origins
kube-state-metrics
*/}}
{{- define "yugaware.kubeStateMetrics.endpoint" -}}
{{- if .Values.kubeStateMetric.customEndpoint -}}
{{- .Values.kubeStateMetric.customEndpoint -}}
{{- else if .Values.kubeStateMetric.install -}}
{{- if .Values.kubeStateMetrics.customEndpoint -}}
{{- .Values.kubeStateMetrics.customEndpoint -}}
{{- else if .Values.kubeStateMetrics.install -}}
{{- printf "%s-ksm.%s.svc.%s:8080" .Release.Name .Release.Namespace .Values.domainName -}}
{{- else -}}
{{- printf "kube-state-metrics.kube-system.svc.%s:8080" .Values.domainName -}}
Expand Down
2 changes: 1 addition & 1 deletion stable/yugaware/templates/configs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ data:
- job_name: 'kube-state-metrics'
static_configs:
- targets: ['{{ template "kubeStateMetric.endpoint" . }}']
- targets: ['{{ template "yugaware.kubeStateMetrics.endpoint" . }}']
metric_relabel_configs:
# Save the name of the metric so we can group_by since we cannot by __name__ directly...
- source_labels: ["__name__"]
Expand Down
67 changes: 0 additions & 67 deletions stable/yugaware/templates/kube-state-metrics-deployment.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions stable/yugaware/templates/kube-state-metrics-service-account.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Adapted from https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-state-metrics (Apache-2.0 license)
{{- if and .Values.kubeStateMetric.install (not .Values.kubeStateMetric.customEndpoint) -}}
{{- /*
Adapted from https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-state-metrics (Apache-2.0 license).
*/}}
{{- if and .Values.kubeStateMetrics.install (not .Values.kubeStateMetrics.customEndpoint) -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand All @@ -9,169 +11,169 @@ metadata:
release: {{ .Release.Name }}
name: {{ .Release.Name }}-ksm
rules:
{{ if has "certificatesigningrequests" $.Values.kubeStateMetric.collectors }}
{{ if has "certificatesigningrequests" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["certificates.k8s.io"]
resources:
- certificatesigningrequests
verbs: ["list", "watch"]
{{ end -}}
{{ if has "configmaps" $.Values.kubeStateMetric.collectors }}
{{ if has "configmaps" $.Values.kubeStateMetrics.collectors }}
- apiGroups: [""]
resources:
- configmaps
verbs: ["list", "watch"]
{{ end -}}
{{ if has "cronjobs" $.Values.kubeStateMetric.collectors }}
{{ if has "cronjobs" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["batch"]
resources:
- cronjobs
verbs: ["list", "watch"]
{{ end -}}
{{ if has "daemonsets" $.Values.kubeStateMetric.collectors }}
{{ if has "daemonsets" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["extensions", "apps"]
resources:
- daemonsets
verbs: ["list", "watch"]
{{ end -}}
{{ if has "deployments" $.Values.kubeStateMetric.collectors }}
{{ if has "deployments" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["extensions", "apps"]
resources:
- deployments
verbs: ["list", "watch"]
{{ end -}}
{{ if has "endpoints" $.Values.kubeStateMetric.collectors }}
{{ if has "endpoints" $.Values.kubeStateMetrics.collectors }}
- apiGroups: [""]
resources:
- endpoints
verbs: ["list", "watch"]
{{ end -}}
{{ if has "horizontalpodautoscalers" $.Values.kubeStateMetric.collectors }}
{{ if has "horizontalpodautoscalers" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["autoscaling"]
resources:
- horizontalpodautoscalers
verbs: ["list", "watch"]
{{ end -}}
{{ if has "ingresses" $.Values.kubeStateMetric.collectors }}
{{ if has "ingresses" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["extensions", "networking.k8s.io"]
resources:
- ingresses
verbs: ["list", "watch"]
{{ end -}}
{{ if has "jobs" $.Values.kubeStateMetric.collectors }}
{{ if has "jobs" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["batch"]
resources:
- jobs
verbs: ["list", "watch"]
{{ end -}}
{{ if has "limitranges" $.Values.kubeStateMetric.collectors }}
{{ if has "limitranges" $.Values.kubeStateMetrics.collectors }}
- apiGroups: [""]
resources:
- limitranges
verbs: ["list", "watch"]
{{ end -}}
{{ if has "mutatingwebhookconfigurations" $.Values.kubeStateMetric.collectors }}
{{ if has "mutatingwebhookconfigurations" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["admissionregistration.k8s.io"]
resources:
- mutatingwebhookconfigurations
verbs: ["list", "watch"]
{{ end -}}
{{ if has "namespaces" $.Values.kubeStateMetric.collectors }}
{{ if has "namespaces" $.Values.kubeStateMetrics.collectors }}
- apiGroups: [""]
resources:
- namespaces
verbs: ["list", "watch"]
{{ end -}}
{{ if has "networkpolicies" $.Values.kubeStateMetric.collectors }}
{{ if has "networkpolicies" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["networking.k8s.io"]
resources:
- networkpolicies
verbs: ["list", "watch"]
{{ end -}}
{{ if has "nodes" $.Values.kubeStateMetric.collectors }}
{{ if has "nodes" $.Values.kubeStateMetrics.collectors }}
- apiGroups: [""]
resources:
- nodes
verbs: ["list", "watch"]
{{ end -}}
{{ if has "persistentvolumeclaims" $.Values.kubeStateMetric.collectors }}
{{ if has "persistentvolumeclaims" $.Values.kubeStateMetrics.collectors }}
- apiGroups: [""]
resources:
- persistentvolumeclaims
verbs: ["list", "watch"]
{{ end -}}
{{ if has "persistentvolumes" $.Values.kubeStateMetric.collectors }}
{{ if has "persistentvolumes" $.Values.kubeStateMetrics.collectors }}
- apiGroups: [""]
resources:
- persistentvolumes
verbs: ["list", "watch"]
{{ end -}}
{{ if has "poddisruptionbudgets" $.Values.kubeStateMetric.collectors }}
{{ if has "poddisruptionbudgets" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["policy"]
resources:
- poddisruptionbudgets
verbs: ["list", "watch"]
{{ end -}}
{{ if has "pods" $.Values.kubeStateMetric.collectors }}
{{ if has "pods" $.Values.kubeStateMetrics.collectors }}
- apiGroups: [""]
resources:
- pods
verbs: ["list", "watch"]
{{ end -}}
{{ if has "replicasets" $.Values.kubeStateMetric.collectors }}
{{ if has "replicasets" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["extensions", "apps"]
resources:
- replicasets
verbs: ["list", "watch"]
{{ end -}}
{{ if has "replicationcontrollers" $.Values.kubeStateMetric.collectors }}
{{ if has "replicationcontrollers" $.Values.kubeStateMetrics.collectors }}
- apiGroups: [""]
resources:
- replicationcontrollers
verbs: ["list", "watch"]
{{ end -}}
{{ if has "resourcequotas" $.Values.kubeStateMetric.collectors }}
{{ if has "resourcequotas" $.Values.kubeStateMetrics.collectors }}
- apiGroups: [""]
resources:
- resourcequotas
verbs: ["list", "watch"]
{{ end -}}
{{ if has "secrets" $.Values.kubeStateMetric.collectors }}
{{ if has "secrets" $.Values.kubeStateMetrics.collectors }}
- apiGroups: [""]
resources:
- secrets
verbs: ["list", "watch"]
{{ end -}}
{{ if has "services" $.Values.kubeStateMetric.collectors }}
{{ if has "services" $.Values.kubeStateMetrics.collectors }}
- apiGroups: [""]
resources:
- services
verbs: ["list", "watch"]
{{ end -}}
{{ if has "statefulsets" $.Values.kubeStateMetric.collectors }}
{{ if has "statefulsets" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["apps"]
resources:
- statefulsets
verbs: ["list", "watch"]
{{ end -}}
{{ if has "storageclasses" $.Values.kubeStateMetric.collectors }}
{{ if has "storageclasses" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["storage.k8s.io"]
resources:
- storageclasses
verbs: ["list", "watch"]
{{ end -}}
{{ if has "validatingwebhookconfigurations" $.Values.kubeStateMetric.collectors }}
{{ if has "validatingwebhookconfigurations" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["admissionregistration.k8s.io"]
resources:
- validatingwebhookconfigurations
verbs: ["list", "watch"]
{{ end -}}
{{ if has "volumeattachments" $.Values.kubeStateMetric.collectors }}
{{ if has "volumeattachments" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["storage.k8s.io"]
resources:
- volumeattachments
verbs: ["list", "watch"]
{{ end -}}
{{ if has "verticalpodautoscalers" $.Values.kubeStateMetric.collectors }}
{{ if has "verticalpodautoscalers" $.Values.kubeStateMetrics.collectors }}
- apiGroups: ["autoscaling.k8s.io"]
resources:
- verticalpodautoscalers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.kubeStateMetric.install (not .Values.kubeStateMetric.customEndpoint) -}}
{{- if and .Values.kubeStateMetrics.install (not .Values.kubeStateMetrics.customEndpoint) -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- /*
Adapted from https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-state-metrics (Apache-2.0 license)
*/}}
{{- if and .Values.kubeStateMetrics.install (not .Values.kubeStateMetrics.customEndpoint) -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-ksm
labels:
app: {{ .Release.Name }}-yugaware-ksm
chart: {{ template "yugaware.chart" . }}
release: {{ .Release.Name }}
spec:
selector:
matchLabels:
app: {{ .Release.Name }}-yugaware-ksm
replicas: {{ .Values.kubeStateMetrics.replicas }}
template:
metadata:
labels:
app: {{ .Release.Name }}-yugaware-ksm
spec:
serviceAccountName: {{ .Release.Name }}
{{- if .Values.kubeStateMetrics.securityContext.enabled }}
securityContext:
fsGroup: {{ .Values.kubeStateMetrics.securityContext.fsGroup }}
runAsGroup: {{ .Values.kubeStateMetrics.securityContext.runAsGroup }}
runAsUser: {{ .Values.kubeStateMetrics.securityContext.runAsUser }}
{{- end }}
containers:
- name: kube-state-metrics-yugaware
args:
{{- if .Values.kubeStateMetrics.extraArgs }}
{{- range .Values.kubeStateMetrics.extraArgs }}
- {{ . }}
{{- end }}
{{- end }}
- --port=8080
- --resources={{ .Values.kubeStateMetrics.collectors | join "," }}
imagePullPolicy: {{ .Values.kubeStateMetrics.image.pullPolicy }}
image: "{{ .Values.kubeStateMetrics.image.repository }}:{{ .Values.kubeStateMetrics.image.tag }}"
ports:
- containerPort: 8080
name: "http"
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 5
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 5
timeoutSeconds: 5
{{- if .Values.kubeStateMetrics.resources }}
resources:
{{ toYaml .Values.kubeStateMetrics.resources | indent 10 }}
{{- end }}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if and .Values.kubeStateMetrics.install (not .Values.kubeStateMetrics.customEndpoint) -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: {{ .Release.Name }}-yugaware-ksm
chart: {{ template "yugaware.chart" . }}
release: {{ .Release.Name }}
name: {{ .Release.Name }}-ksm
{{- end -}}
Loading

0 comments on commit 96676c2

Please sign in to comment.