machine-api-operator

module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2019 License: Apache-2.0

README

Machine API Operator

The Machine API Operator manages the lifecycle of specific purpose CRDs, controllers and RBAC objects that extend the Kubernetes API. This allows to convey desired state of machines in a cluster in a declarative fashion.

Architecture

Machine API Operator overview

CRDs

  • MachineSet
  • Machine
  • Cluster
  • MachineHealthCheck

Controllers

Cluster API controllers
  • Reconciles desired state of machines by matching IP addresses of machine objects with IP addresses of node objects and annotates nodes with a special machine annotation containing the machine name. The cluster-api node controller interprets the annotation and sets the corresponding nodeRef field of each relevant machine.

  • Build:

$ make nodelink-controller
Machine healthcheck controller
  • Reconciles desired state for MachineHealthChecks by ensuring that machines targeted by machineHealthCheck objects are healthy or remediated otherwise.

  • Build:

    $ make machine-healthcheck
    
  • How to test it:

    1. Create a machineset and locate its selector. Assuming the selector corresponds to the following list of match labels:

      sigs.k8s.io/cluster-api-cluster: cluster
      sigs.k8s.io/cluster-api-machine-role: worker
      sigs.k8s.io/cluster-api-machine-type: worker
      sigs.k8s.io/cluster-api-machineset: cluster-worker-us-east-1a
      
    2. Define a MachineHealthCheck manifest that will be watching all machines of the machinset based on its match labels:

      apiVersion: healthchecking.openshift.io/v1alpha1
      kind: MachineHealthCheck
      metadata:
        name: example
        namespace: default
      spec:
        selector:
          matchLabels:
            sigs.k8s.io/cluster-api-cluster: cluster
            sigs.k8s.io/cluster-api-machine-role: worker
            sigs.k8s.io/cluster-api-machine-type: worker
            sigs.k8s.io/cluster-api-machineset: cluster-worker-us-east-1a
      
    3. Pick a node that is managed by one of the machineset's machines

    4. SSH into the node, disable and stop the kubelet services:

      # systemctl disable kubelet
      # systemctl stop kubelet
      
    5. After some time the node will transition into Unready state

    6. Watch the machine healthcheck controller logs to see how it notices a node in Unready state and starts to reconcile the node

    7. After some time the current node instance is terminated and new instance is created. Followed by new node joining the cluster and turning in Ready state.

Dev

  • Build:

    $ make build
    
  • Run:

    $ ./bin/machine-api-operator --kubeconfig ${HOME}/.kube/config --images-json=pkg/operator/fixtures/images.json
    
  • Image:

    $ make image
    

The Machine API Operator is designed to work in conjunction with the Cluster Version Operator. You can see it in action by running an OpenShift Cluster deployed by the Installer.

However you can run it in a vanilla Kubernetes cluster by precreating some assets:

CI & tests

Run unit test:

$ make test

Run e2e-aws-operator tests. This tests assume that a cluster deployed by the Installer is up and running and a KUBECONFIG environment variable is set:

$ make test-e2e

Tests are located under machine-api-operator repository and executed in prow CI system. A link to failing tests is published as a comment in PR by @openshift-ci-robot. Current test status for all OpenShift components can be found in https://deck-ci.svc.ci.openshift.org.

CI configuration is stored under openshift/release repository and is split into 4 files:

More information about those files can be found in ci-operator onboarding file.

Directories

Path Synopsis
cmd
pkg
apis/healthchecking/v1alpha1
Package v1alpha1 contains API Schema definitions for the healthchecking v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=healthchecking.openshift.io Package v1alpha1 contains API Schema definitions for the healthchecking v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=healthchecking.openshift.io
Package v1alpha1 contains API Schema definitions for the healthchecking v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=healthchecking.openshift.io Package v1alpha1 contains API Schema definitions for the healthchecking v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=healthchecking.openshift.io
test
e2e

Jump to

Keyboard shortcuts

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