added repo

This commit is contained in:
Your Name
2026-08-26 03:39:42 +05:30
parent 45c25a95af
commit b8575bb8b9
6889 changed files with 1217125 additions and 0 deletions
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
@@ -0,0 +1,21 @@
apiVersion: v2
appVersion: v1.3.11
description: A Helm chart for Kubernetes to deploy telegraf-operator
home: https://github.com/influxdata/telegraf-operator
keywords:
- telegraf
- telegraf-operator
- sidecar
- operator
- injector
- mutatingwebhook
- influxdata
- influxdb
kubeVersion: '>= 1.13.0-r0'
maintainers:
- email: wkocjan@influxdata.com
name: wojciechka
- name: rawkode
name: telegraf-operator
type: application
version: 1.4.0
@@ -0,0 +1,85 @@
# Telegraf-operator Helm chart
> Default installation expects `cert-manager` to be running in the cluster.
## Prerequisites
- Helm v2 or later
- Kubernetes 1.11+ with Beta APIs enabled
## Install the chart
1. Add the InfluxData Helm repository:
```bash
helm repo add influxdata https://helm.influxdata.com/
```
2. Run the following command, providing a name for your release:
```bash
helm upgrade --install my-release influxdata/telegraf-operator
```
> **Tip**: `--install` can be shortened to `-i`.
This command deploys Telegraf-operator on the Kubernetes cluster using the default configuration. To find parameters you can configure during installation, see [Configure the chart](#configure-the-chart).
> **Tip**: To view all Helm chart releases, run `helm list`.
## Uninstall the chart
To uninstall the `my-release` deployment, use the following command:
```bash
helm uninstall my-release
```
This command removes all the Kubernetes components associated with the chart and deletes the release.
## Configure the chart
Configurable parameters, their descriptions, and their default values are stored in `values.yaml`.
To configure the chart, do either of the following:
- Specify each parameter using the `--set key=value[,key=value]` argument to `helm upgrade --install`. For example, use the following command:
```bash
helm upgrade --install my-release \
--set persistence.enabled=true \
influxdata/telegraf-operator
```
This command enables persistence.
- Provide a YAML file that specifies parameter values while installing the chart. For example, use the following command:
```bash
helm upgrade --install my-release -f values.yaml influxdata/telegraf-operator
```
> **Tip**: Use the default [values.yaml](values.yaml).
For information about running Telegraf-operator in Docker, see the [full image documentation](https://hub.docker.com/_/kapacitor/).
## Contribute to the chart
```shell
helm template --namespace=telegraf-operator telegraf-operator .
```
### Test installation with Kind
```shell
kind create cluster --name=telegraf-operator-test
kubectl config use-context kind-telegraf-operator-test
kubectl apply -f tests/influxdb.yml
helm install telegraf-operator .
kubectl apply -f tests/redis.yml
kind delete cluster --name=telegraf-operator-test
```
## Cert-manager integration
For better security there is already an integration with cert-manger >0.13 that can be enabled but you have to provide your own instalation of cert-manager in the cluster
@@ -0,0 +1,116 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "telegraf-operator.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "telegraf-operator.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "telegraf-operator.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "telegraf-operator.labels" -}}
helm.sh/chart: {{ include "telegraf-operator.chart" . }}
{{ include "telegraf-operator.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Selector labels
*/}}
{{- define "telegraf-operator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "telegraf-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "telegraf-operator.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "telegraf-operator.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Generate certificates for telegraf-operator mutating webhook
*/}}
{{- define "telegraf-operator.non_certmanager" -}}
{{- $altNames := list ( printf "%s.%s" (include "telegraf-operator.fullname" .) .Release.Namespace ) ( printf "%s.%s.svc" (include "telegraf-operator.fullname" .) .Release.Namespace ) -}}
{{- $ca := genCA "telegraf-operator-ca" 365 -}}
{{- $cert := genSignedCert ( include "telegraf-operator.fullname" . ) nil $altNames 365 $ca -}}
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
annotations:
cert-manager.io/inject-ca-from: "{{ .Values.namespace }}/{{ include "telegraf-operator.fullname" . }}"
labels:
{{- include "telegraf-operator.labels" . | nindent 4 }}
name: {{ include "telegraf-operator.fullname" . }}
webhooks:
- clientConfig:
service:
name: {{ include "telegraf-operator.fullname" . }}
namespace: {{ .Release.Namespace }}
path: /mutate-v1-pod
caBundle: {{ $ca.Cert | b64enc }}
failurePolicy: Ignore
sideEffects: None
admissionReviewVersions:
- 'v1'
name: telegraf.influxdata.com
rules:
- apiGroups:
- '*'
apiVersions:
- '*'
operations:
- CREATE
- DELETE
resources:
- pods
---
apiVersion: v1
kind: Secret
type: kubernetes.io/tls
metadata:
name: telegraf-operator-tls
labels:
{{- include "telegraf-operator.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": "pre-install,pre-upgrade"
"helm.sh/hook-delete-policy": "before-hook-creation"
data:
tls.crt: {{ $cert.Cert | b64enc }}
tls.key: {{ $cert.Key | b64enc }}
{{- end -}}
@@ -0,0 +1,18 @@
{{- if .Values.certManager.enable -}}
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ include "telegraf-operator.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "telegraf-operator.labels" . | nindent 4 }}
spec:
dnsNames:
- "{{ include "telegraf-operator.fullname" . }}.{{ .Release.Namespace }}.svc"
- "{{ include "telegraf-operator.fullname" . }}.{{ .Release.Namespace }}"
isCA: true
issuerRef:
kind: Issuer
name: telegraf-operator-issuer
secretName: telegraf-operator-tls
{{- end -}}
@@ -0,0 +1,23 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
{{- include "telegraf-operator.labels" . | nindent 4 }}
name: {{ include "telegraf-operator.fullname" . }}
rules:
- apiGroups:
- ""
resources:
- secrets
verbs:
- '*'
- apiGroups:
- ""
resources:
- namespaces
verbs: ["get", "list"]
- apiGroups:
- ""
resources:
- pods
verbs: ["get"]
@@ -0,0 +1,14 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
{{- include "telegraf-operator.labels" . | nindent 4 }}
name: {{ include "telegraf-operator.fullname" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "telegraf-operator.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "telegraf-operator.fullname" . }}
namespace: {{ .Release.Namespace }}
@@ -0,0 +1,88 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "telegraf-operator.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "telegraf-operator.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "telegraf-operator.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "telegraf-operator.selectorLabels" . | nindent 8 }}
{{- if eq .Values.certManager.enable false }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/tls.yml") . | sha256sum }}
{{- end }}
spec:
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "--telegraf-default-class={{ .Values.classes.default }}"
- --telegraf-classes-directory=/etc/telegraf-operator
{{- if eq .Values.enableDefaultInternalPlugin true }}
- --enable-default-internal-plugin
{{- end }}
- "--telegraf-image={{ .Values.image.sidecarImage }}"
{{- if eq .Values.requireAnnotationsForSecret true }}
- "--require-annotations-for-secret"
{{- end }}
- "--telegraf-requests-cpu={{ .Values.sidecarResources.requests.cpu }}"
- "--telegraf-requests-memory={{ .Values.sidecarResources.requests.memory }}"
- "--telegraf-limits-cpu={{ .Values.sidecarResources.limits.cpu }}"
- "--telegraf-limits-memory={{ .Values.sidecarResources.limits.memory }}"
{{- if eq .Values.hotReload true }}
- "--telegraf-watch-config=inotify"
{{- end }}
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
ports:
- name: https
containerPort: 9443
protocol: TCP
volumeMounts:
- mountPath: /etc/certs
name: certs
readOnly: true
- mountPath: /etc/telegraf-operator
name: classes
readOnly: true
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "telegraf-operator.fullname" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
volumes:
- name: certs
secret:
secretName: telegraf-operator-tls
- name: classes
secret:
secretName: {{ .Values.classes.secretName }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
@@ -0,0 +1,11 @@
{{- if .Values.certManager.enable -}}
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: telegraf-operator-issuer
namespace: {{ .Release.Namespace }}
labels:
{{- include "telegraf-operator.labels" . | nindent 4 }}
spec:
selfSigned: {}
{{- end -}}
@@ -0,0 +1,31 @@
{{- if eq .Values.certManager.enable true -}}
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
annotations:
cert-manager.io/inject-ca-from: "{{ .Release.Namespace }}/{{ include "telegraf-operator.fullname" . }}"
labels:
{{- include "telegraf-operator.labels" . | nindent 4 }}
name: {{ include "telegraf-operator.fullname" . }}
webhooks:
- clientConfig:
service:
name: {{ include "telegraf-operator.fullname" . }}
namespace: {{ .Release.Namespace }}
path: /mutate-v1-pod
failurePolicy: Ignore
sideEffects: None
admissionReviewVersions:
- 'v1'
name: telegraf.influxdata.com
rules:
- apiGroups:
- '*'
apiVersions:
- '*'
operations:
- CREATE
- DELETE
resources:
- pods
{{- end }}
@@ -0,0 +1,16 @@
{{- if .Capabilities.APIVersions.Has "policy/v1" }}
apiVersion: policy/v1
{{- else }}
apiVersion: policy/v1beta1
{{- end }}
kind: PodDisruptionBudget
metadata:
name: {{ include "telegraf-operator.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "telegraf-operator.labels" . | nindent 4 }}
spec:
minAvailable: 1
selector:
matchLabels:
{{- include "telegraf-operator.selectorLabels" . | nindent 6 }}
@@ -0,0 +1,8 @@
{{- if .Values.classes.data }}
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.classes.secretName }}
namespace: {{ .Release.Namespace }}
stringData: {{ .Values.classes.data | toYaml | nindent 2 }}
{{- end }}
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "telegraf-operator.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "telegraf-operator.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- name: https
port: 443
protocol: TCP
targetPort: 9443
selector:
{{- include "telegraf-operator.selectorLabels" . | nindent 4 }}
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "telegraf-operator.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "telegraf-operator.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
@@ -0,0 +1,3 @@
{{- if eq .Values.certManager.enable false -}}
{{ ( include "telegraf-operator.non_certmanager" . ) }}
{{- end }}
@@ -0,0 +1,42 @@
apiVersion: v1
kind: Namespace
metadata:
name: influxdb
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: influxdb
namespace: influxdb
spec:
replicas: 1
selector:
matchLabels:
app: influxdb
template:
metadata:
labels:
app: influxdb
spec:
containers:
- name: influxdb
image: influxdb:1.7.9
- name: chronograf
image: chronograf:1.6.2
args: ["--influxdb-url=http://localhost:8086"]
---
apiVersion: v1
kind: Service
metadata:
labels:
app: influxdb
name: influxdb
namespace: influxdb
spec:
ports:
- name: server
port: 8086
- name: chronograf
port: 8888
selector:
app: influxdb
@@ -0,0 +1,25 @@
apiVersion: v1
kind: Namespace
metadata:
name: test
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: redis
namespace: test
spec:
selector:
matchLabels:
app: redis
serviceName: redis
template:
metadata:
labels:
app: redis
annotations:
telegraf.influxdata.com/ports: "8080,9090"
spec:
containers:
- name: redis
image: redis:alpine
@@ -0,0 +1,59 @@
replicaCount: 3
image:
repository: quay.io/influxdb/telegraf-operator
pullPolicy: IfNotPresent
sidecarImage: "docker.io/library/telegraf:1.22"
classes:
secretName: "telegraf-operator-classes"
default: "infra"
data:
infra: |
[[outputs.influxdb]]
urls = ["http://influxdb.influxdb:8086"]
[global_tags]
env = "ci"
hostname = "$HOSTNAME"
nodename = "$NODENAME"
type = "infra"
certManager:
enable: false
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Annotations to add to the service account
annotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
resources:
limits:
cpu: 200m
memory: 256Mi
requests:
cpu: 50m
memory: 64Mi
sidecarResources:
limits:
cpu: 200m
memory: 200Mi
requests:
cpu: 10m
memory: 10Mi
nodeSelector: {}
tolerations: []
affinity: {}
requireAnnotationsForSecret: false
enableDefaultInternalPlugin: true
# allow hot reload ; disabled by default to support versions of telegraf
# that do not support hot-reload and --watch-config flag
hotReload: false