For adding support for a new cloud provider in the Machine Controller Manager, follow the steps described below. Replace provider with your provider-name.
- Add a ProviderMachineClass CRD similar to existing AWSMachineClass into
kubernetes/crds.yaml. - Add ProviderMachineClass structs similar to existing AWSMachineClass into the machine APIs into
pkg/apis/machine/types.goandpkg/apis/machine/v1alpha1/types.go. This would be the machineClass template used to describe provider specific configurations. - Add the Go structures of your machine class (list) to
pkg/apis/machine/register.goandpkg/apis/machine/v1alpha1/register.goto allow reporting events on these objects. - Regenerate the machine API clients by running
./hack/generate-code - Add validation for the new provider machine class at
pkg/apis/machine/validation/providermachineclass.gosimilar topkg/apis/machine/validation/awsmachineclass.go - Update
pkg/controller/machine_util.goto allow validation of the new provider. - Add a new driver into
pkg/driver/driver_provider.gosimilar topkg/driver/driver_aws.goto implement the driver interface. - Update
pkg/driver/driver.goto add a new switch case to support the new provider driver. - Add a new method in
pkg/controller/machine_safety.gocalled checkProviderMachineClass similar to the existing method called checkAWSMachineClass present in the same file. Now invoke this method as a go-routine in the method checkVMObjects. - Extend the
StartControllers()function incmd/machine-controller-manager/app/controllermanager.goto only start if your new machine class is under the available resources. - Update
pkg/controller/controller.goto add new providerMachineClassLister, providerMachineClassQueue, awsMachineClassSynced into the controller struct. Also initialize them in NewController() method. - Add a new file
pkg/controller/providermachineclass.gothat allows re-queuing of machines which refer to an modified providerMachineClass. - Update
pkg/controller/controller.goto extendWaitForCacheSyncand.Shutdown()similar to other cloud providers. - Update the example ClusterRole in
kubernetes/deployment/clusterrole.yamlto allow operations on your new machine class. - Update
pkg/controller/controller.go,pkg/controller/secret.go,pkg/controller/secret_util.goto add event handlers to add/remove finalizers referenced by your machine Class. Refer this commit.