Out of tree (controller based) implementation for equinix-metal
as a new provider.
- The Equinix Metal, formerly Packet, out-of-tree provider implements the interface defined at MCM OOT Driver
Following are the basic principles kept in mind while developing the external plugin.
- Communication between this Machine Controller (MC) and Machine Controller Manager (MCM) is achieved using the Kubernetes native declarative approach.
- Machine Controller (MC) behaves as the controller used to interact with the cloud provider and manage the VMs corresponding to the machine objects.
- Machine Controller Manager (MCM) deals with higher level objects such as machine-set and machine-deployment objects.
- Steps to be followed while implementing a new provider are mentioned here
Prerequisites:
- git
- Three open terminal windows
- go, v1.15 or newer
- A deployed Kubernetes cluster to control machines. Any cluster will do, including one deployed on Equinix Metal, locally, or even kind or k3d
Theoretically, you need a target cluster as well, a cluster that the newly deployed machines will join. This cluster's control plane should have the following characteristics:
- reachable from any new machines you create
- userData that you supply to the newly-created machines is sufficient for them to join
However, since this local testing is not testing the entire flow, just the creation/deletion of machines, we will ignore cluster joining, and just check that the machine was created with the right userData.
For your deployed Kubernetes cluster, ensure that you know the following:
- path to the kubeconfig for the target cluster; for testing purposes, this will be your control cluster
- path to the kubeconfig for the control cluster which holds the machine custom resource objects
- namespace in the control cluster where you will deploy
Machine
andMachineDeployment
custom resource objects, defaults todefault
Process:
- In the first terminal window:
- Get the latest copy of the Machine Controller Manager (MCM), if you do not have it:
mkdir -p $GOPATH/src/github.com/gardener cd $_ git clone https://github.com/gardener/machine-controller-manager cd machine-controller-manager
- Deploy the required CRDs to the control cluster:
kubectl --kubeconfig=${CONTROL_KUBECONFIG} apply -f kubernetes/crds/
- Run the machine-controller-manager in the
cmi-client
branch:make start TARGET_KUBECONFIG=path/to/target/kubeconfig CONTROL_KUBECONFIG=path/to/control/kubeconfig CONTROL_NAMESPACE=control_namespace
- Get the latest copy of the Machine Controller Manager (MCM), if you do not have it:
- In the second terminal window:
- Get this repository, if you do not have it already
mkdir -p $GOPATH/src/github.com/gardener cd $_ git clone https://github.com/gardener/machine-controller-manager-provider-equinix-metal cd machine-controller-manager-provider-equinix-metal
- Start the driver in this repository with
make start
, setting the following make variables:make start TARGET_KUBECONFIG=path/to/target/kubeconfig CONTROL_KUBECONFIG=path/to/control/kubeconfig CONTROL_NAMESPACE=control_namespace`
- Get this repository, if you do not have it already
- In the third terminal:
- Change directory to this repository:
cd $GOPATH/src/github.com/gardener/machine-controller-manager-provider-equinix-metal
- All activities will be against the control cluster. With each command, you can run
kubectl --kubeconfig=${CONTROL_KUBECONFIG}
. However, to simplify the commands, set the environment variable:export KUBECONFIG=${CONTROL_KUBECONFIG}
- Fill in the object files given below and deploy them:
kubectl apply -f kubernetes/machine-class.yaml
- Copy the kubernetes
Secret
template to the temporary directory, then fill it in with your Equinix Metal API key and deploy:cp kubernetes/secret.yaml tmp/secret.yaml vi tmp/secret.yaml # fill in your actual key here kubectl apply -f tmp/secret.yaml
- Deploy various
Machine
objects and make sure they are created and have the userData you supplied.kubectl apply -f kubernetes/machines/
- Once the
Machine
s have passed testing, deploy aMachineDeployment
and make sure it is created and has the userData you supplied. If you provided it with an actual joinable target cluster and userData to join it, wait until all of the machines join that cluster successfully:kubectl apply -f kubernetes/machine-deployment.yaml
- Clean up by deleting both the
machine
andmachine-deployment
object after use.kubectl delete -f kubernetes/machine.yaml kubectl delete -f kubernetes/machine-deployment.yaml
- Change directory to this repository:
- Stop the processes in the first and second terminal windows