Skip to content

Commit e9fe43f

Browse files
committed
add grafana agent
1 parent 7a4e1ab commit e9fe43f

File tree

13 files changed

+543
-0
lines changed

13 files changed

+543
-0
lines changed

charts/grafana-agent/Chart.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v2
2+
name: grafana-agent
3+
description: |-
4+
Helm chart to deploy [grafana-agent](https://github.com/grafana/agent).
5+
type: application
6+
version: 0.0.1
7+
appVersion: v0.26.1
8+
home: https://github.com/slamdev/helm-charts/tree/master/charts/grafana-agent
9+
icon: https://grafana.com/static/assets/internal/grafana_logo-web-white-text.svg
10+
maintainers:
11+
- name: slamdev
12+
email: valentin.fedoskin@gmail.com

charts/grafana-agent/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# grafana-agent
2+
3+
![Version: 0.0.1](https://img.shields.io/badge/Version-0.0.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.26.1](https://img.shields.io/badge/AppVersion-v0.26.1-informational?style=flat-square)
4+
5+
Helm chart to deploy [grafana-agent](https://github.com/grafana/agent).
6+
7+
**Homepage:** <https://github.com/slamdev/helm-charts/tree/master/charts/grafana-agent>
8+
9+
## Maintainers
10+
11+
| Name | Email | Url |
12+
| ---- | ------ | --- |
13+
| slamdev | <valentin.fedoskin@gmail.com> | |
14+
15+
## Values
16+
17+
| Key | Type | Default | Description |
18+
|-----|------|---------|-------------|
19+
| additionalResources | list | `[]` | list of additional resources to create (are processed via `tpl` function) |
20+
| affinity | object | `{}` | affinity for scheduler pod assignment |
21+
| args[0] | string | `"--config.file=/grafana-agent.yaml"` | |
22+
| conf | string | `"server:\n log_level: info"` | grafana-agent config to provision inside of the container |
23+
| containerPorts | list | `[{"containerPort":12345,"name":"http"},{"containerPort":12346,"name":"grpc"}]` | ports exposed by container |
24+
| env | list | `[{"name":"HOSTNAME","valueFrom":{"fieldRef":{"fieldPath":"spec.nodeName"}}},{"name":"POD_NAME","valueFrom":{"fieldRef":{"fieldPath":"metadata.name"}}},{"name":"POD_IP","valueFrom":{"fieldRef":{"fieldPath":"status.podIP"}}}]` | additional environment variables for the deployment |
25+
| fullnameOverride | string | `""` | full name of the chart. |
26+
| image.pullPolicy | string | `"IfNotPresent"` | image pull policy |
27+
| image.repository | string | `"grafana/grafana-agent"` | image repository |
28+
| image.tag | string | `""` | image tag (chart's appVersion value will be used if not set) |
29+
| imagePullSecrets | list | `[]` | image pull secret for private images |
30+
| livenessProbe.httpGet.path | string | `"/http-metrics/-/ready"` | path for liveness probe |
31+
| livenessProbe.httpGet.port | string | `"http"` | port for liveness probe |
32+
| nameOverride | string | `""` | override name of the chart |
33+
| nodeSelector | object | `{}` | node for scheduler pod assignment |
34+
| podAnnotations | object | `{}` | annotations to add to the pod |
35+
| podSecurityContext | object | `{}` | specifies security settings for a pod |
36+
| readinessProbe.httpGet.path | string | `"/http-metrics/-/ready"` | path for readiness probe |
37+
| readinessProbe.httpGet.port | string | `"http"` | port for readiness probe |
38+
| resources | object | `{}` | custom resource configuration |
39+
| securityContext | object | `{}` | specifies security settings for a container |
40+
| service.annotations | object | `{}` | service annotations |
41+
| service.ports | list | `[{"name":"http","port":12345,"targetPort":"http"},{"name":"grpc","port":12346,"targetPort":"grpc"}]` | service ports |
42+
| service.type | string | `"ClusterIP"` | service type |
43+
| serviceAccount.annotations | object | `{}` | annotations to add to the service account |
44+
| serviceAccount.create | bool | `false` | specifies whether a service account should be created |
45+
| serviceAccount.name | string | `nil` | the name of the service account to use; if not set and create is true, a name is generated using the fullname template |
46+
| startupProbe.httpGet.path | string | `"/http-metrics/-/ready"` | path for startup probe |
47+
| startupProbe.httpGet.port | string | `"http"` | port for startup probe |
48+
| tolerations | list | `[]` | tolerations for scheduler pod assignment |
49+
| volumeMounts | list | `[]` | additional volume mounts |
50+
| volumes | list | `[]` | additional volumes |
51+
| workload.annotations | object | `{}` | annotations to add to the workload |
52+
| workload.daemonSetSpec.updateStrategy | object | `{}` | an update strategy to replace existing DaemonSet pods with new pods |
53+
| workload.deploymentSpec.replicas | int | `1` | number of desired pods |
54+
| workload.deploymentSpec.strategy | object | `{}` | the deployment strategy to use to replace existing pods with new ones. |
55+
| workload.kind | string | `"deployment"` | can be deployment, statefulSet or daemonSet |
56+
| workload.labels | object | `{}` | labels to add to the workload |
57+
| workload.statefulSetSpec.podManagementPolicy | string | `"OrderedReady"` | controls how pods are created during initial scale up |
58+
| workload.statefulSetSpec.replicas | int | `1` | number of desired pods |
59+
| workload.statefulSetSpec.updateStrategy | object | `{}` | indicates the StatefulSetUpdateStrategy that will be employed to update Pods in the StatefulSet when a revision is made to Template |
60+
| workload.statefulSetSpec.volumeClaimTemplates | object | `{}` | a list of claims that pods are allowed to reference |
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 "grafana-agent.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 "grafana-agent.fullname" . }}'
9+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "grafana-agent.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 "grafana-agent.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
13+
echo "Visit http://127.0.0.1:8080 to use your application"
14+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
15+
{{- end }}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "grafana-agent.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "grafana-agent.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "grafana-agent.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Common labels
36+
*/}}
37+
{{- define "grafana-agent.labels" -}}
38+
helm.sh/chart: {{ include "grafana-agent.chart" . }}
39+
{{ include "grafana-agent.selectorLabels" . }}
40+
{{- if .Chart.AppVersion }}
41+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
42+
{{- end }}
43+
app.kubernetes.io/managed-by: {{ .Release.Service }}
44+
{{- end -}}
45+
46+
{{/*
47+
Selector labels
48+
*/}}
49+
{{- define "grafana-agent.selectorLabels" -}}
50+
app.kubernetes.io/name: {{ include "grafana-agent.name" . }}
51+
app.kubernetes.io/instance: {{ .Release.Name }}
52+
{{- end -}}
53+
54+
{{/*
55+
Create the name of the service account to use
56+
*/}}
57+
{{- define "grafana-agent.serviceAccountName" -}}
58+
{{- if .Values.serviceAccount.create -}}
59+
{{ default (include "grafana-agent.fullname" .) .Values.serviceAccount.name }}
60+
{{- else -}}
61+
{{ default "default" .Values.serviceAccount.name }}
62+
{{- end -}}
63+
{{- end -}}
64+
65+
{{/*
66+
Create the tag for the docker image to use
67+
*/}}
68+
{{- define "grafana-agent.tag" -}}
69+
{{- .Values.image.tag | default .Chart.AppVersion -}}
70+
{{- end -}}
71+
72+
{{/*
73+
grafana-agent.rawResource will create a resource template that can be
74+
merged with each item in `.Values.additionalResources`.
75+
*/}}
76+
{{- define "grafana-agent.rawResource" -}}
77+
metadata:
78+
labels:
79+
{{- include "grafana-agent.labels" . | nindent 4 }}
80+
{{- end }}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{{- define "grafana-agent.pod" -}}
2+
metadata:
3+
labels:
4+
{{- include "grafana-agent.selectorLabels" . | nindent 4 }}
5+
annotations:
6+
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
7+
{{- with .Values.podAnnotations }}
8+
{{- toYaml . | nindent 4 }}
9+
{{- end }}
10+
spec:
11+
{{- with .Values.imagePullSecrets }}
12+
imagePullSecrets:
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
15+
serviceAccountName: {{ include "grafana-agent.serviceAccountName" . }}
16+
securityContext:
17+
{{- toYaml .Values.podSecurityContext | nindent 4 }}
18+
containers:
19+
- name: {{ .Chart.Name }}
20+
{{- with .Values.args }}
21+
args:
22+
{{- toYaml . | nindent 8 }}
23+
{{- end }}
24+
securityContext:
25+
{{- toYaml .Values.securityContext | nindent 8 }}
26+
image: "{{ .Values.image.repository }}:{{ include "grafana-agent.tag" . }}"
27+
imagePullPolicy: {{ .Values.image.pullPolicy }}
28+
{{- with .Values.containerPorts }}
29+
ports:
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
32+
livenessProbe:
33+
{{- toYaml .Values.livenessProbe | nindent 8 }}
34+
readinessProbe:
35+
{{- toYaml .Values.readinessProbe | nindent 8 }}
36+
startupProbe:
37+
{{- toYaml .Values.startupProbe | nindent 8 }}
38+
resources:
39+
{{- toYaml .Values.resources | nindent 8 }}
40+
{{- with .Values.env }}
41+
env:
42+
{{- toYaml . | nindent 8 }}
43+
{{- end }}
44+
volumeMounts:
45+
- name: {{ include "grafana-agent.fullname" . }}
46+
mountPath: /grafana-agent.yaml
47+
subPath: grafana-agent.yaml
48+
{{- with .Values.volumeMounts }}
49+
{{- toYaml . | nindent 8 }}
50+
{{- end }}
51+
volumes:
52+
- name: {{ include "grafana-agent.fullname" . }}
53+
configMap:
54+
name: {{ include "grafana-agent.fullname" . }}
55+
defaultMode: 0644
56+
{{- with .Values.volumes }}
57+
{{- toYaml . | nindent 4 }}
58+
{{- end }}
59+
{{- with .Values.nodeSelector }}
60+
nodeSelector:
61+
{{- toYaml . | nindent 4 }}
62+
{{- end }}
63+
{{- with .Values.affinity }}
64+
affinity:
65+
{{- toYaml . | nindent 4 }}
66+
{{- end }}
67+
{{- with .Values.tolerations }}
68+
tolerations:
69+
{{- toYaml . | nindent 4 }}
70+
{{- end }}
71+
72+
{{- end -}}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{- $template := fromYaml (include "grafana-agent.rawResource" .) -}}
2+
{{- range $i, $t := .Values.additionalResources }}
3+
---
4+
{{ toYaml (merge (tpl $t $ | fromYaml) $template) -}}
5+
{{- end }}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "grafana-agent.fullname" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
{{- include "grafana-agent.labels" . | nindent 4 }}
8+
data:
9+
grafana-agent.yaml: |-
10+
{{ .Values.conf | nindent 4 }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- if eq .Values.workload.kind "daemonSet" }}
2+
apiVersion: apps/v1
3+
kind: DaemonSet
4+
metadata:
5+
name: {{ include "grafana-agent.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
{{- with .Values.workload.annotations }}
8+
annotations:
9+
{{- toYaml . | nindent 4 }}
10+
{{- end }}
11+
labels:
12+
{{- include "grafana-agent.labels" . | nindent 4 }}
13+
{{- .Values.workload.labels | toYaml . | nindent 4 }}
14+
spec:
15+
{{- with .Values.workload.daemonSetSpec.updateStrategy }}
16+
updateStrategy:
17+
{{- toYaml . | nindent 4 }}
18+
{{- end }}
19+
selector:
20+
matchLabels:
21+
{{- include "grafana-agent.selectorLabels" . | nindent 6 }}
22+
template:
23+
{{- include "grafana-agent.pod" . | nindent 4 }}
24+
{{- end }}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{- if eq .Values.workload.kind "deployment" }}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ include "grafana-agent.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
{{- with .Values.workload.annotations }}
8+
annotations:
9+
{{- toYaml . | nindent 4 }}
10+
{{- end }}
11+
labels:
12+
{{- include "grafana-agent.labels" . | nindent 4 }}
13+
{{- .Values.workload.labels | toYaml . | nindent 4 }}
14+
spec:
15+
replicas: {{ .Values.workload.deploymentSpec.replicas }}
16+
{{- with .Values.workload.deploymentSpec.strategy }}
17+
strategy:
18+
{{- toYaml . | nindent 4 }}
19+
{{- end }}
20+
selector:
21+
matchLabels:
22+
{{- include "grafana-agent.selectorLabels" . | nindent 6 }}
23+
template:
24+
{{- include "grafana-agent.pod" . | nindent 4 }}
25+
{{- end }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "grafana-agent.fullname" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
{{- include "grafana-agent.labels" . | nindent 4 }}
8+
{{- with .Values.service.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
type: {{ .Values.service.type }}
14+
{{- with .Values.service.ports }}
15+
ports:
16+
{{- toYaml . | nindent 4 }}
17+
{{- end }}
18+
selector:
19+
{{- include "grafana-agent.selectorLabels" . | nindent 4 }}

0 commit comments

Comments
 (0)