-
Integrate controller-runtime into project.
-
Add deployment controller that runs business logic on each reconcile event for Deployments in specified namespace.
-
Controller is started alongside the FastHTTP server.
- Uses controller-runtime's manager to run a controller for Deployments.
- Adds OTEL environment variables to the deployment and creates OTEL collector ConfigMap object. Deployment MUST have label set:
app=nodejs
- To compile controller, run:
make build- To start server, run
./k8s-controller --log-level trace --kubeconfig ~/.kube/config server --namespace <namespace> --labelSelectors labelName=labelValue-
Create a new deployment or modify existing one by setting
app=nodejslabel set.- E.g.: create a new deployment.
kubectl create deploy nodejs-app --image=<image> --replicas=1 --labels=app=nodejs -n <namespace>
- E.g.: Add required label set
app=nodejsto existing deployment.
kubectl label deployment test app=nodejs -n <namespace>
-
Verify specified namespace, and observe newly added environment variables and annotations for OTEL automatic instrumentation to the deployment and new ConfigMap object done by controller's business logic.
kubectl describe deploy <name> -n <namespace>
kubectl get cm -n <namespace>