Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add initcontainers, sidecars and extra k8s objects to telegraf charts #523

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions charts/telegraf-ds/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ spec:
serviceAccountName: {{ template "telegraf.serviceAccountName" . }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName | quote }}
{{- end }}
{{- if .Values.initContainers }}
initContainers:
{{ toYaml .Values.initContainers | indent 6 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
Expand Down Expand Up @@ -57,15 +61,22 @@ spec:
- name: hostfsro
mountPath: /hostfs
readOnly: true
{{- if hasPrefix "unix" .Values.config.docker_endpoint }}
- name: docker-socket
mountPath: {{ trimPrefix "unix://" .Values.config.docker_endpoint }}
{{- if hasPrefix "unix" .Values.config.runtime_endpoint }}
- name: runtime-socket
mountPath: {{ trimPrefix "unix://" .Values.config.runtime_endpoint }}
{{- end }}
- name: config
mountPath: /etc/telegraf
{{- if .Values.mountPoints }}
{{ toYaml .Values.mountPoints | indent 8 }}
{{- end }}
{{- if .Values.ports }}
ports:
{{ toYaml .Values.ports | indent 10 }}
{{- end }}
{{- if .Values.sideCars }}
{{ toYaml .Values.sideCars | indent 6 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
Expand All @@ -82,10 +93,10 @@ spec:
- name: hostfsro
hostPath:
path: /
{{- if hasPrefix "unix" .Values.config.docker_endpoint }}
- name: docker-socket
{{- if hasPrefix "unix" .Values.config.runtime_endpoint }}
- name: runtime-socket
hostPath:
path: {{ trimPrefix "unix://" .Values.config.docker_endpoint }}
path: {{ trimPrefix "unix://" .Values.config.runtime_endpoint }}
type: Socket
{{- end }}
- name: varrunutmpro
Expand Down
4 changes: 4 additions & 0 deletions charts/telegraf-ds/templates/extra-objects.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{ range .Values.extraObjects }}
---
{{ tpl (toYaml .) $ }}
{{ end }}
19 changes: 18 additions & 1 deletion charts/telegraf-ds/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ resources:
cpu: 1
## Pod annotations
podAnnotations: {}
## override the app label
# nameOverride: telegraf-poller
## Pod labels
podLabels: {}
## telegraf Container ports
ports: []
# - containerPort: 9127
# protocol: UDP
# hostPort: 9127
# name: statsd
## Configure args passed to Telegraf containers
args: []
## The name of a secret in the same kubernetes namespace which contains values to
Expand Down Expand Up @@ -145,4 +153,13 @@ config:
user_agent: "telegraf"
insecure_skip_verify: false
monitor_self: false
docker_endpoint: "unix:///var/run/docker.sock"
runtime_endpoint: "unix:///var/run/docker.sock"
extraObjects: []
initContainers: []
# - name: hello
# image: library:busybox
# command: ["/bin/sh", "-c", "echo 'OK'"]
sideCars: []
# - name: hello
# image: library:busybox
# command: ["/bin/sh", "-c", "sleep 30000"]
Empty file modified charts/telegraf/Chart.yaml
100755 → 100644
Empty file.
7 changes: 7 additions & 0 deletions charts/telegraf/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ spec:
{{ toYaml .Values.securityContext | indent 8 }}
{{- end }}
serviceAccountName: {{ template "telegraf.serviceAccountName" . }}
{{- if .Values.initContainers }}
initContainers:
{{ toYaml .Values.initContainers | indent 6 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
{{- if .Values.containerSecurityContext }}
Expand Down Expand Up @@ -96,6 +100,9 @@ spec:
path: /
port: {{ trimPrefix "http://:" .service_address | int64 }}
{{- end }}
{{- if .Values.sideCars }}
{{ toYaml .Values.sideCars | indent 6 }}
{{- end }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.imagePullSecrets | indent 8 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/telegraf/templates/extra-objects.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{ range .Values.extraObjects }}
---
{{ tpl (toYaml .) $ }}
{{ end }}
24 changes: 24 additions & 0 deletions charts/telegraf/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ image:
tag: "1.25-alpine"
pullPolicy: IfNotPresent
podAnnotations: {}
## override the app label
# nameOverride: telegraf-poller
podLabels: {}
imagePullSecrets: []
## Configure args passed to Telegraf containers
Expand Down Expand Up @@ -172,3 +174,25 @@ pdb:
create: true
minAvailable: 1
# maxUnavailable: 1
extraObjects: []
# - apiVersion: autoscaling/v1
# kind: HorizontalPodAutoscaler
# metadata:
# name: telegraf
# spec:
# maxReplicas: 8
# minReplicas: 1
# scaleTargetRef:
# apiVersion: apps/v1
# kind: Deployment
# name: telegraf
# targetCPUUtilizationPercentage: 90

initContainers: []
# - name: hello
# image: library:busybox
# command: ["/bin/sh", "-c", "echo 'OK'"]
sideCars: []
# - name: hello
# image: library:busybox
# command: ["/bin/sh", "-c", "sleep 30000"]