The InfluxData Contributor License Agreement (CLA) is part of the legal framework for the open-source ecosystem that protects both you and InfluxData. To make substantial contributions to InfluxData telegraf-operator, first sign the InfluxData CLA. What constitutes a "substantial" change is at the discretion of InfluxData documentation maintainers.
Note: Typo and broken link fixes are greatly appreciated and do not require signing the CLA.
We have put effort into making contributing to telegraf-operator
as easy as possible.
Fork this repository and clone it to your local machine.
Due to complexity of how operators work, the recommended way to implement changes is to also implement testing to ensure your changes work as expected.
Tests should include both the happy path as well as all edge cases. This speeds up development compared to verifying code in Kubernetes-based environments.
In order to run tests, simply run the test
target - such as:
make test
This runs linting, vetting as well as tests themselves. The output from the command also includes a report including test coverage.
The recommended way of testing changes made to telegraf-operator in real environments is to use kind. This allows easy local development as long as Docker is available locally on your machine.
The kind
CLI is also needed and the
kind Quick Start guide describes the process of installing it.
The Makefile
bundled with telegraf-operator
includes several targets that simplify testing your changes in Kubernetes.
The kind-start
target invokes kind
CLI to create a new cluster called telegraf-operator-test
that can be used to test telegraf-operator
:
make kind-start
This operation deploys InfluxDB v1 along with Chronograf in the cluster, so that it is possible to verify the data is sent by Telegraf.
Deployment of InfluxDB is not needed to work or use telegraf-operator
, but is included as a convenience.
In order to build a container image based on local clone of the telegraf-repository
, simply run the kind-build
command.
make kind-build
This will build the telegraf-operator with the same image tag as the official image and will inject the image into the telegraf-operator-test
kind cluster.
The kind-test
target deploys telegraf operator - by deploying examples/classes.yml and deploy/dev.yml files to your local kind cluster.
make kind-test
This will deploy telegraf-operator
along with the mutating webhook configuration that will instruct kind cluster to allow telegraf-operator
to add the telegraf
sidecar container for any newly created pods.
It will also deploy a redis
statefulset in test
namespace that allows verifying that redis
was deployed with the telegraf sidecar container added.
If the kind-build
target was run prior to this command, the locally built image of telegraf-operator
will be used. If not, the upstream image of telegraf-operator
will be pulled by kind cluster.
The kind-delete-pod
target deletes the telegraf-operator
pod(s), so that Kubernetes restarts them.
make kind-delete-pod
Re-creating the pod will cause kind cluster to pick up any newer image of telegraf-operator
that was injected into the kind cluster.
This can be used along with kind-build
target to first build a new image of telegraf-operator and then force the kind cluster to create a new pod.
The kind-cleanup
target provides a way to delete all of the resources related to telegraf-operator
from the kind cluster.
make kind-cleanup
This command will delete telegraf-operator
and test
namespaces as well as mutating webhook configuration.
It's useful when ensuring that next invocation of kind-test
will re-create telegraf-operator from scratch, without having to delete and create the entire kind cluster.
Note that this command will keep the InfluxDB v1 instance running in your kind cluster.
The target kind-delete
can be used to delete the entire telegraf-operator-test
kind cluster.
make kind-delete
This will delete the telegraf-operator-test
kind cluster along with any resources that were deployed into it.
The list below contains a short version of make
targets, based on description above:
kind-start
- start a new kind (Kubernetes in Docker) cluster fortelegraf-operator
testing, along with an InfluxDB instancekind-build
- build an image oftelegraf-operator
locally and inject it into the kind clusterkind-test
- deploytelegraf-operator
along with any additional resources as well as aredis
statefulset intest
namespacekind-delete-pod
- deletestelegraf-operator
pod(s), which triggers a restart and new container image oftelegraf-operator
to be used, if it was injectedkind-cleanup
- deletes all resources related totelegraf-operator
from the kind cluster, leaving InfluxDB runningkind-delete
- deletes the entire kind cluster