Skip to content

Latest commit

 

History

History
116 lines (76 loc) · 3.45 KB

File metadata and controls

116 lines (76 loc) · 3.45 KB

Development

Run MCM locally

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.

Prerequisites

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

Overview

You will run the provider and MCM locally while pointing them at real clusters:

  • $TARGET_KUBECONFIG points to the cluster where you want machines to join (the shoot).
  • $CONTROL_KUBECONFIG points to the cluster that stores Machine objects (the seed).
  • $CONTROL_NAMESPACE is where MCM watches Machine objects (usually shoot--projectname--shootname on 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.

1. Get kubeconfigs with gardenctl

Set these shell variables (replace with your values):

export SHOOT_NAME=foobar
export SEED_NAME=foobar-seed

Export 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.kubeconfig

Set 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_NAME

2. Scale down the in-cluster MCM

Scale 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=0

Since 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.

3. Run the provider (driver)

Set the environment varialbes from above and run another terminal in your provider repo:

make start

4. Run MCM locally

On another terminal in the Gardener MCM repository:

git clone git@github.com:gardener/machine-controller-manager.git
cd machine-controller-manager

Set the environment varialbes from above and run the MCM:

make start

Notes

  • 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.

Build Container Image locally

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.io

Build image and push to the regsitry:

make image

The pushed image name and tag are logged to the console.