machine-controller-manager

module
v1.2.5-dev9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2024 License: Apache-2.0, BSD-3-Clause

README

machine-controller-manager

CI Build status Go Report Card

⚠ We are in the progress of migrating and deprecating all the in-tree providers to OOT. Please avoid making any new feature enhancements to the intree providers. Kindly make it on the OOT providers available here. More details on adding new OOT providers can be found here.

Overview

Machine Controller Manager aka MCM is a group of cooperative controllers that manage the lifecycle of the worker machines. It is inspired by the design of Kube Controller Manager in which various sub controllers manage their respective Kubernetes Clients. MCM gives you the following benefits:

  • seamlessly manage machines/nodes with a declarative API (of course, across different cloud providers)
  • integrate generically with the cluster autoscaler
  • plugin with tools such as the node-problem-detector
  • transport the immutability design principle to machine/nodes
  • implement e.g. rolling upgrades of machines/nodes

MCM supports following providers. These provider code is maintained externally (out-of-tree), and the links for the same are linked below:

It can easily be extended to support other cloud providers as well.

Example of managing machine:

kubectl create/get/delete machine vm1

Key terminologies

Nodes/Machines/VMs are different terminologies used to represent similar things. We use these terms in the following way

  1. VM: A virtual machine running on any cloud provider. It could also refer to a physical machine (PM) in case of a bare metal setup.
  2. Node: Native kubernetes node objects. The objects you get to see when you do a "kubectl get nodes". Although nodes can be either physical/virtual machines, for the purposes of our discussions it refers to a VM.
  3. Machine: A VM that is provisioned/managed by the Machine Controller Manager.

Design of Machine Controller Manager

The design of the Machine Controller Manager is influenced by the Kube Controller Manager, where-in multiple sub-controllers are used to manage the Kubernetes clients.

Design Principles

It's designed to run in the master plane of a Kubernetes cluster. It follows the best principles and practices of writing controllers, including, but not limited to:

  • Reusing code from kube-controller-manager
  • leader election to allow HA deployments of the controller
  • workqueues and multiple thread-workers
  • SharedInformers that limit to minimum network calls, de-serialization and provide helpful create/update/delete events for resources
  • rate-limiting to allow back-off in case of network outages and general instability of other cluster components
  • sending events to respected resources for easy debugging and overview
  • Prometheus metrics, health and (optional) profiling endpoints

Objects of Machine Controller Manager

Machine Controller Manager reconciles a set of Custom Resources namely MachineDeployment, MachineSet and Machines which are managed & monitored by their controllers MachineDeployment Controller, MachineSet Controller, Machine Controller respectively along with another cooperative controller called the Safety Controller.

Machine Controller Manager makes use of 4 CRD objects and 1 Kubernetes secret object to manage machines. They are as follows:

Custom ResourceObject Description
MachineClass A MachineClass represents a template that contains cloud provider specific details used to create machines.
Machine A Machine represents a VM which is backed by the cloud provider.
MachineSet A MachineSet ensures that the specified number of Machine replicas are running at a given point of time.
MachineDeployment A MachineDeployment provides a declarative update for MachineSet and Machines.
Secret A Secret here is a Kubernetes secret that stores cloudconfig (initialization scripts used to create VMs) and cloud specific credentials.

See here for CRD API Documentation

Components of Machine Controller Manager

Controller Description
MachineDeployment controller Machine Deployment controller reconciles the MachineDeployment objects and manages the lifecycle of MachineSet objects. MachineDeployment consumes provider specific MachineClass` in its spec.template.spec which is the template of the VM spec that would be spawned on the cloud by MCM.
MachineSet controller MachineSet controller reconciles the MachineSet objects and manages the lifecycle of Machine objects.
Safety controller There is a Safety Controller responsible for handling the unidentified or unknown behaviours from the cloud providers. Safety Controller:
  • freezes the MachineDeployment controller and MachineSet controller if the number of Machine objects goes beyond a certain threshold on top of Spec.replicas. It can be configured by the flag --safety-up or --safety-down and also --machine-safety-overshooting-period`.
  • freezes the functionality of the MCM if either of the target-apiserver or the control-apiserver is not reachable.
  • unfreezes the MCM automatically once situation is resolved to normal. A freeze label is applied on MachineDeployment/MachineSet to enforce the freeze condition.

Along with the above Custom Controllers and Resources, MCM requires the MachineClass to use K8s Secret that stores cloudconfig (initialization scripts used to create VMs) and cloud specific credentials. All these controllers work in an co-operative manner. They form a parent-child relationship with MachineDeployment Controller being the grandparent, MachineSet Controller being the parent, and Machine Controller being the child.

Development

To start using or developing the Machine Controller Manager, see the documentation in the /docs repository, please find the index here.

FAQ

An FAQ is available here

Cluster-api Implementation

Directories

Path Synopsis
cmd
pkg
apis/machine
Package machine is the internal version of the API.
Package machine is the internal version of the API.
apis/machine/v1alpha1
Package v1alpha1 is the v1alpha1 version of the API.
Package v1alpha1 is the v1alpha1 version of the API.
apis/machine/validation
Package validation is used to validate all the machine CRD objects
Package validation is used to validate all the machine CRD objects
client/clientset/internalversion
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/clientset/internalversion/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/internalversion/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/internalversion/typed/machine/internalversion
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/internalversion/typed/machine/internalversion/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
client/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/versioned/typed/machine/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/machine/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
controller
Package controller is used to provide the core functionalities of machine-controller-manager
Package controller is used to provide the core functionalities of machine-controller-manager
driver
Package driver contains the cloud provider specific implementations to manage machines
Package driver contains the cloud provider specific implementations to manage machines
features
Package features is reserved for future purposes
Package features is reserved for future purposes
openapi
Package openapi exists to hold generated openapi code
Package openapi exists to hold generated openapi code
options
Package options is used to specify options to MCM
Package options is used to specify options to MCM
util/annotations
Package annotations implements utilites for working with annotatoins
Package annotations implements utilites for working with annotatoins
util/client/metrics/prometheus
Package prometheus creates and registers prometheus metrics with rest clients.
Package prometheus creates and registers prometheus metrics with rest clients.
util/clientbuilder/machine
Package controller is used to provide the core functionalities of machine-controller-manager
Package controller is used to provide the core functionalities of machine-controller-manager
util/k8sutils
Package k8sutils is used to provider helper consts and functions for k8s operations
Package k8sutils is used to provider helper consts and functions for k8s operations
util/nodeops
Package nodeops is used to provide the node functionalities
Package nodeops is used to provide the node functionalities
util/permits
Package permits is used to provide permitGiver which maintains a sync map whose values can be deleted if not accessed for a configured time
Package permits is used to provide permitGiver which maintains a sync map whose values can be deleted if not accessed for a configured time
util/provider/drain
Package drain is used to drain nodes
Package drain is used to drain nodes
util/provider/driver
Package driver contains the cloud provider specific implementations to manage machines
Package driver contains the cloud provider specific implementations to manage machines
util/provider/machinecodes/codes
Package codes defines the canonical error codes used by machineAPIs for gardener/machine-controller-manager
Package codes defines the canonical error codes used by machineAPIs for gardener/machine-controller-manager
util/provider/machinecodes/status
Package status implements errors returned by MachineAPIs.
Package status implements errors returned by MachineAPIs.
util/provider/machinecontroller
Package controller is used to provide the core functionalities of machine-controller-manager
Package controller is used to provide the core functionalities of machine-controller-manager
util/provider/machineutils
Package machineutils contains the consts and global vaariables for machine operation
Package machineutils contains the consts and global vaariables for machine operation
util/provider/options
Package options is used to specify options to MCM
Package options is used to specify options to MCM
util/reflector/prometheus
Package prometheus sets the cache DefaultMetricsFactory to produce prometheus metrics.
Package prometheus sets the cache DefaultMetricsFactory to produce prometheus metrics.
util/strings
Package strings is used to provide some util string functions
Package strings is used to provide some util string functions
util/taints
Package taints implements utilites for working with taints
Package taints implements utilites for working with taints
util/time
Package time is used to provide the core functionalities of machine-controller-manager
Package time is used to provide the core functionalities of machine-controller-manager

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL