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.go
andpkg/apis/cluster/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.go
andpkg/apis/cluster/v1alpha1/register.go
to 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.go
similar topkg/apis/machine/validation/awsmachineclass.go
- Update
pkg/controller/machine_util.go
to allow validation of the new provider. - Add a new driver into
pkg/driver/driver_provider.go
similar topkg/driver/driver_aws.go
to implement the driver interface. - Update
pkg/driver/driver.go
to add a new switch case to support the new provider driver. - Add a new method in
pkg/controller/machine_safety.go
called 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.go
to only start if your new machine class is under the available resources. - Update
pkg/controller/controller.go
to add new providerMachineClassLister, providerMachineClassQueue, awsMachineClassSynced into the controller struct. Also initialize them in NewController() method. - Add a new file
pkg/controller/providermachineclass.go
that allows re-queuing of machines which refer to an modified providerMachineClass. - Update
pkg/controller/controller.go
to extendWaitForCacheSync
and.Shutdown()
similar to other cloud providers. - Update the example ClusterRole in
kubernetes/deployment/clusterrole.yaml
to allow operations on your new machine class. - Update
pkg/controller/controller.go
,pkg/controller/secret.go
,pkg/controller/secret_util.go
to add event handlers to add/remove finalizers referenced by your machine Class. Refer this commit.