This guide describes how to run the STACKIT MCM provider against a real Gardener shoot on STACKIT. A local kind cluster is not suitable because the provider creates real STACKIT VMs that must join a real Kubernetes cluster.
Before you begin, ensure you have the following:
- A Gardener installation on STACKIT
- A shoot cluster created in that Gardener
- Access to the seed and shoot via
gardenctl - A local Go toolchain
You will run the provider and MCM locally while pointing them at real clusters:
$TARGET_KUBECONFIGpoints to the cluster where you want machines to join (the shoot).$CONTROL_KUBECONFIGpoints to the cluster that stores Machine objects (the seed).$CONTROL_NAMESPACEis where MCM watches Machine objects (usuallyshoot--projectname--shootnameon the seed).
MachineClass objects and Secrets are assumed to already exist. Running the provider locally results in faster feedback loops when developing new features and enables using the go debugger.
Set these shell variables (replace with your values):
export SHOOT_NAME=foobar
export SEED_NAME=foobar-seedExport kubeconfigs using gardenctl:
# Target (shoot) kubeconfig
gardenctl kubeconfig --raw --shoot $SHOOT_NAME > /tmp/target.kubeconfig
# Control (seed) kubeconfig
gardenctl kubeconfig --raw --seed $SEED_NAME > /tmp/control.kubeconfigSet these environment variables on every spun up terminal:
export TARGET_KUBECONFIG=/tmp/target.kubeconfig
export CONTROL_KUBECONFIG=/tmp/control.kubeconfig
export CONTROL_NAMESPACE=shoot--testing--$SHOOT_NAMEScale the existing MCM in the seed to 0, so your local controller can take over:
kubectl --kubeconfig "$CONTROL_KUBECONFIG" -n "$CONTROL_NAMESPACE" scale deployment/machine-controller-manager --replicas=0Since Gardener periodically scales the deployment back up, you can use a watch command in a separate terminal to continuously scale it down:
watch -n 5 "kubectl --kubeconfig '$CONTROL_KUBECONFIG' -n '$CONTROL_NAMESPACE' scale deployment/machine-controller-manager --replicas=0"This will check and scale down the deployment every 5 seconds.
Make sure to set the environment variables.
Set the environment varialbes from above and run another terminal in your provider repo:
make startOn another terminal in the Gardener MCM repository:
git clone git@github.com:gardener/machine-controller-manager.git
cd machine-controller-managerSet the environment varialbes from above and run the MCM:
make start- This workflow assumes MachineClass and Secret objects already exist and are valid.
- The local controllers should reconcile existing resources and provision STACKIT VMs that join the shoot.
- Re-enable the in-cluster MCM after testing by scaling it back up.
Create a classic personal access token in GitHub. Set an expiration date and enable the write:packages scope.
Note: Using a token generated by the gh cli is not sufficient.
Login to the ghcr.io registry. When asked for a password, paste the access token:
ko login -u <your_username> --password-stdin ghcr.ioBuild image and push to the regsitry:
make imageThe pushed image name and tag are logged to the console.