/machine-controller-manager-provider-equinix-metal

Out of tree (controller based) implementation for `Equinix Metal` as provider.

Primary LanguageGoOtherNOASSERTION

machine-controller-manager-provider-equinix-metal

Out of tree (controller based) implementation for equinix-metal as a new provider.

About

Fundamental Design Principles:

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.

Support for a new provider

  • Steps to be followed while implementing a new provider are mentioned here

Testing the Equinix Metal Out of Tree Provider

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 and MachineDeployment custom resource objects, defaults to default

Process:

  1. In the first terminal window:
    1. 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
    2. Deploy the required CRDs to the control cluster:
      kubectl --kubeconfig=${CONTROL_KUBECONFIG} apply -f kubernetes/crds/
    3. 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
  2. In the second terminal window:
    1. 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
    2. 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`
      
  3. In the third terminal:
    1. Change directory to this repository:
      cd $GOPATH/src/github.com/gardener/machine-controller-manager-provider-equinix-metal
    2. 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}
    3. Fill in the object files given below and deploy them:
      kubectl apply -f kubernetes/machine-class.yaml
    4. 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
    5. Deploy various Machine objects and make sure they are created and have the userData you supplied.
      kubectl apply -f kubernetes/machines/
    6. Once the Machines have passed testing, deploy a MachineDeployment 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
    7. Clean up by deleting both the machine and machine-deployment object after use.
      kubectl delete -f kubernetes/machine.yaml
      kubectl delete -f kubernetes/machine-deployment.yaml
  4. Stop the processes in the first and second terminal windows