One of the main features of the instana-agent-operator
is to do leader election. In order to test this manually, we need a Kubernetes cluster where we can destroy nodes, so that we can observe if a new leader is elected in that case.
This page describes how to set up a local Kubernetes cluster with Kind and test the instana-agent-operator
in that cluster.
Kind (Kubernetes in Docker) will set up a local cluster where all nodes and the master run in Docker containers.
Install kind (a single executable that can be downloaded from the Github release page) and run the following commands to create the cluster:
./e2e-testing/with-kind/create-cluster.sh
You should see a cluster with one control-pane and two worker nodes up and running.
This script will also do the following:
- Build the
instana/instana-agent-operator
Docker image locally and load it into the local Kind cluster - Pull the latest
instana/agent
Docker image locally and load it into the local Kind cluster
Follow the steps described in Install Operator Manually.
Instead of using the instana-agent-operator.yaml
file directly from the latest GitHub release, download that latest instana-agent-operator.yaml
file locally, and change the imagePullPolicy
for the Deployment
from Always
to IfNotPresent
.
This will ensure that it uses the locally built instana/instana-agent-operator
image.
kubectl -n instana-agent get pods
This should show one instance of the instana-agent-operator
(see the number of replicas
configured in olm/operator-resources/instana-agent-operator.yaml
), and two instances of instana-agent
(one on each worker node in the cluster).
Delete one of the worker nodes that is running the instana-agent
leader pod. The operator should reassign leadership to another agent pod.
You should see the reassignment if you tail the logs for the operator pod.
./e2e-testing/with-kind/delete-cluster.sh