Skip to content

Commit 51b4320

Browse files
committed
Add helm chart for deployment
1 parent 1a95647 commit 51b4320

File tree

12 files changed

+608
-0
lines changed

12 files changed

+608
-0
lines changed

helm/Makefile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Makefile for kube-summary-exporter Helm chart
2+
3+
CHART_NAME = kube-summary-exporter
4+
RELEASE_NAME = kube-summary-exporter
5+
NAMESPACE = monitoring
6+
7+
.PHONY: lint template install upgrade uninstall package dry-run
8+
9+
# Lint the Helm chart
10+
lint:
11+
helm lint $(CHART_NAME)
12+
13+
# Render templates for debugging
14+
template:
15+
helm template $(RELEASE_NAME) $(CHART_NAME) --debug
16+
17+
# Install the chart
18+
install:
19+
helm install $(RELEASE_NAME) $(CHART_NAME) --namespace $(NAMESPACE) --create-namespace
20+
21+
# Upgrade the chart
22+
upgrade:
23+
helm upgrade $(RELEASE_NAME) $(CHART_NAME) --namespace $(NAMESPACE)
24+
25+
# Uninstall the chart
26+
uninstall:
27+
helm uninstall $(RELEASE_NAME) --namespace $(NAMESPACE)
28+
29+
# Package the chart
30+
package:
31+
helm package $(CHART_NAME)
32+
33+
# Dry run installation
34+
dry-run:
35+
helm install $(RELEASE_NAME) $(CHART_NAME) --namespace $(NAMESPACE) --dry-run --debug
36+
37+
# Show chart values
38+
show-values:
39+
helm show values $(CHART_NAME)
40+
41+
# Show chart info
42+
show-chart:
43+
helm show chart $(CHART_NAME)
44+
45+
# Test the release
46+
test:
47+
helm test $(RELEASE_NAME) --namespace $(NAMESPACE)
48+
49+
# Get status
50+
status:
51+
helm status $(RELEASE_NAME) --namespace $(NAMESPACE)
52+
53+
# List releases
54+
list:
55+
helm list --namespace $(NAMESPACE)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v2
2+
name: kube-summary-exporter
3+
description: A Helm chart for kube-summary-exporter - Exports Prometheus metrics for the Kubernetes Summary API
4+
type: application
5+
version: 0.1.0
6+
appVersion: "latest"
7+
keywords:
8+
- kubernetes
9+
- prometheus
10+
- monitoring
11+
- metrics
12+
- summary-api
13+
home: https://github.com/utilitywarehouse/kube-summary-exporter
14+
sources:
15+
- https://github.com/utilitywarehouse/kube-summary-exporter
16+
maintainers:
17+
- name: kube-summary-exporter
18+
url: https://github.com/utilitywarehouse/kube-summary-exporter
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
1. Get the application URL by running these commands:
2+
{{- if contains "NodePort" .Values.service.type }}
3+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "kube-summary-exporter.fullname" . }})
4+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
5+
echo http://$NODE_IP:$NODE_PORT
6+
{{- else if contains "LoadBalancer" .Values.service.type }}
7+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
8+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "kube-summary-exporter.fullname" . }}'
9+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "kube-summary-exporter.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
10+
echo http://$SERVICE_IP:{{ .Values.service.port }}
11+
{{- else if contains "ClusterIP" .Values.service.type }}
12+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "kube-summary-exporter.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
13+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
14+
echo "Visit http://127.0.0.1:9779 to use your application"
15+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 9779:$CONTAINER_PORT
16+
{{- end }}
17+
18+
2. kube-summary-exporter provides the following endpoints:
19+
- /: Home page with links to other endpoints
20+
- /nodes: Metrics for all nodes in the cluster
21+
- /node/{node}: Metrics for a specific node
22+
- /metrics: Prometheus metrics about the exporter itself
23+
24+
3. Example Prometheus scrape configuration:
25+
Add the following to your Prometheus configuration to scrape metrics:
26+
27+
- job_name: "kubernetes-summary"
28+
kubernetes_sd_configs:
29+
- role: node
30+
relabel_configs:
31+
- source_labels: [__meta_kubernetes_node_label_role]
32+
action: replace
33+
target_label: role
34+
- source_labels: [__meta_kubernetes_node_name]
35+
regex: (.+)
36+
target_label: __metrics_path__
37+
replacement: /node/${1}
38+
- target_label: __address__
39+
replacement: {{ include "kube-summary-exporter.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.service.port }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "kube-summary-exporter.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "kube-summary-exporter.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "kube-summary-exporter.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "kube-summary-exporter.labels" -}}
37+
helm.sh/chart: {{ include "kube-summary-exporter.chart" . }}
38+
{{ include "kube-summary-exporter.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "kube-summary-exporter.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "kube-summary-exporter.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "kube-summary-exporter.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "kube-summary-exporter.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.rbac.create -}}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: {{ include "kube-summary-exporter.fullname" . }}
6+
labels:
7+
{{- include "kube-summary-exporter.labels" . | nindent 4 }}
8+
rules:
9+
{{- with .Values.rbac.rules }}
10+
{{- toYaml . | nindent 2 }}
11+
{{- end }}
12+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if .Values.rbac.create -}}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRoleBinding
4+
metadata:
5+
name: {{ include "kube-summary-exporter.fullname" . }}
6+
labels:
7+
{{- include "kube-summary-exporter.labels" . | nindent 4 }}
8+
roleRef:
9+
apiGroup: rbac.authorization.k8s.io
10+
kind: ClusterRole
11+
name: {{ include "kube-summary-exporter.fullname" . }}
12+
subjects:
13+
- kind: ServiceAccount
14+
name: {{ include "kube-summary-exporter.serviceAccountName" . }}
15+
namespace: {{ .Release.Namespace }}
16+
{{- end }}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "kube-summary-exporter.fullname" . }}
5+
labels:
6+
{{- include "kube-summary-exporter.labels" . | nindent 4 }}
7+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
selector:
10+
matchLabels:
11+
{{- include "kube-summary-exporter.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
{{- with .Values.podAnnotations }}
15+
annotations:
16+
{{- toYaml . | nindent 8 }}
17+
{{- end }}
18+
labels:
19+
{{- include "kube-summary-exporter.selectorLabels" . | nindent 8 }}
20+
spec:
21+
{{- with .Values.imagePullSecrets }}
22+
imagePullSecrets:
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
serviceAccountName: {{ include "kube-summary-exporter.serviceAccountName" . }}
26+
securityContext:
27+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
28+
containers:
29+
- name: {{ .Chart.Name }}
30+
securityContext:
31+
{{- toYaml .Values.securityContext | nindent 12 }}
32+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
33+
imagePullPolicy: {{ .Values.image.pullPolicy }}
34+
args:
35+
- --listen-address={{ .Values.config.listenAddress }}
36+
{{- if .Values.config.kubeconfig }}
37+
- --kubeconfig={{ .Values.config.kubeconfig }}
38+
{{- end }}
39+
ports:
40+
- name: http
41+
containerPort: {{ .Values.service.targetPort }}
42+
protocol: TCP
43+
livenessProbe:
44+
httpGet:
45+
path: /metrics
46+
port: http
47+
initialDelaySeconds: 30
48+
periodSeconds: 10
49+
readinessProbe:
50+
httpGet:
51+
path: /metrics
52+
port: http
53+
initialDelaySeconds: 5
54+
periodSeconds: 5
55+
resources:
56+
{{- toYaml .Values.resources | nindent 12 }}
57+
{{- with .Values.nodeSelector }}
58+
nodeSelector:
59+
{{- toYaml . | nindent 8 }}
60+
{{- end }}
61+
{{- with .Values.affinity }}
62+
affinity:
63+
{{- toYaml . | nindent 8 }}
64+
{{- end }}
65+
{{- with .Values.tolerations }}
66+
tolerations:
67+
{{- toYaml . | nindent 8 }}
68+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "kube-summary-exporter.fullname" . }}
5+
labels:
6+
{{- include "kube-summary-exporter.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.service.port }}
11+
targetPort: http
12+
protocol: TCP
13+
name: {{ .Values.service.name }}
14+
selector:
15+
{{- include "kube-summary-exporter.selectorLabels" . | nindent 4 }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "kube-summary-exporter.serviceAccountName" . }}
6+
labels:
7+
{{- include "kube-summary-exporter.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
{{- end }}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{{- if .Values.serviceMonitorNodes.enabled }}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: ServiceMonitor
4+
metadata:
5+
name: {{ include "kube-summary-exporter.fullname" . }}-nodes
6+
{{- if .Values.serviceMonitorNodes.namespace }}
7+
namespace: {{ .Values.serviceMonitorNodes.namespace }}
8+
{{- else }}
9+
namespace: {{ .Release.Namespace }}
10+
{{- end }}
11+
labels:
12+
{{- include "kube-summary-exporter.labels" . | nindent 4 }}
13+
{{- with .Values.serviceMonitorNodes.additionalLabels }}
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
{{- with .Values.serviceMonitorNodes.annotations }}
17+
annotations:
18+
{{- toYaml . | nindent 4 }}
19+
{{- end }}
20+
spec:
21+
jobLabel: {{ .Values.serviceMonitorNodes.jobLabel | default "app.kubernetes.io/name" }}
22+
selector:
23+
matchLabels:
24+
{{- include "kube-summary-exporter.selectorLabels" . | nindent 6 }}
25+
{{- with .Values.serviceMonitorNodes.selector }}
26+
{{- toYaml . | nindent 6 }}
27+
{{- end }}
28+
endpoints:
29+
- port: {{ .Values.service.name }}
30+
{{- with .Values.serviceMonitorNodes.interval }}
31+
interval: {{ . }}
32+
{{- end }}
33+
{{- with .Values.serviceMonitorNodes.scrapeTimeout }}
34+
scrapeTimeout: {{ . }}
35+
{{- end }}
36+
path: /nodes
37+
{{- with .Values.serviceMonitorNodes.honorLabels }}
38+
honorLabels: {{ . }}
39+
{{- end }}
40+
{{- with .Values.serviceMonitorNodes.metricRelabelings }}
41+
metricRelabelings:
42+
{{- toYaml . | nindent 8 }}
43+
{{- end }}
44+
{{- with .Values.serviceMonitorNodes.relabelings }}
45+
relabelings:
46+
{{- toYaml . | nindent 8 }}
47+
{{- end }}
48+
{{- with .Values.serviceMonitorNodes.targetLabels }}
49+
targetLabels:
50+
{{- toYaml . | nindent 4 }}
51+
{{- end }}
52+
{{- with .Values.serviceMonitorNodes.podTargetLabels }}
53+
podTargetLabels:
54+
{{- toYaml . | nindent 4 }}
55+
{{- end }}
56+
{{- with .Values.serviceMonitorNodes.namespaceSelector }}
57+
namespaceSelector:
58+
{{- toYaml . | nindent 4 }}
59+
{{- end }}
60+
{{- end }}

0 commit comments

Comments
 (0)