November 2, 2022

OpenShift 4.6 Automation and Integration: Machine Config Pool and Machine Config

Introduction

1.4. About Red Hat Enterprise Linux CoreOS (RHCOS) and Ignition
1.2. About the control plane
https://access.redhat.com/documentation/en-us/openshift_container_platform/4.6/html-single/architecture/index#coreos-and-ignition

Red Hat discourages directly manipulating a RHCOS configuration. Instead, provide initial instance configuration in the form of Ignition files.

After the instance is provisioned, changes to RHCOS are managed by the Machine Config Operator.

7.2.2. Creating a machine set
https://access.redhat.com/documentation/en-us/openshift_container_platform/4.6/html-single/machine_management/index#machineset-creating_creating-infrastructure-machinesets

4.2.7. Customization
https://access.redhat.com/documentation/en-us/openshift_container_platform/4.6/html-single/security_and_compliance/index#customization-2

Example MachineConfig (mc)

apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
  labels:
    machineconfiguration.openshift.io/role: infra
  name: 50-foo-config
spec:
  config:
    ignition:
      version: 3.1.0
    storage:
      files:
      - contents:
          source: data:text/plain;charset=utf-8;base64,LS0t...LQo=
        filesystem: root
        mode: 0644
        path: /etc/foo-config

7.2.4. Creating a machine config pool for infrastructure machines
https://access.redhat.com/documentation/en-us/openshift_container_platform/4.6/html-single/machine_management/index#creating-infra-machines_creating-infrastructure-machinesets

Example MachineConfigPool (mcp)

apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigPool
metadata:
  name: infra
spec:
  machineConfigSelector:
    matchExpressions:
      - {key: machineconfiguration.openshift.io/role, operator: In, values: [worker,infra]}
  nodeSelector:
    matchLabels:
      node-role.kubernetes.io/infra: ""
$ oc get mcp

$ oc get mc --show-labels

$ oc get mc --selector=machineconfiguration.openshift.io/role=infra

Label Nodes

Add a label to worker node

$ oc label node/worker03 node-role.kubernetes.io/infra=

Remove label from worker node

$ oc label node/worker03 node-role.kubernetes.io/infra-

Configuring Pod Scheduling

7.4. Moving resources to infrastructure machine sets
https://access.redhat.com/documentation/en-us/openshift_container_platform/4.6/html-single/machine_management/index#moving-resources-to-infrastructure-machinesets

3.7. Placing pods on specific nodes using node selectors
https://access.redhat.com/documentation/en-us/openshift_container_platform/4.6/html-single/nodes/index#nodes-scheduler-node-selectors

apiVersion: apps/v1
kind: Deployment
metadata:
  name: foo
spec:
  replicas: 2
  selector:
    matchLabels:
      app: foo
  template:
    metadata:
      labels:
        app: foo
    spec:
      nodeSelector:
        node-role.kubernetes.io/infra: ""
      containers:
...

4.1.2. Creating daemonsets
https://access.redhat.com/documentation/en-us/openshift_container_platform/4.6/html-single/nodes/index

If you fail to debug a node, this could be because of a defaultNodeSelector is defined, then you must specify a node selector to override the default.

$ oc adm new-project debug --node-selector=""
$ oc debug node/master03 -n debug

Observing Machine Config Pool Updates

https://github.com/openshift/machine-config-operator/blob/master/docs/MachineConfigController.md

Following annotations on node object will be used by UpdateController to coordinate node update with MachineConfigDaemon.

  • machine-config-daemon.v1.openshift.com/currentConfig: defines the current MachineConfig applied by MachineConfigDaemon.
  • machine-config-daemon.v1.openshift.com/desiredConfig: defines the desired MachineConfig that need to be applied by MachineConfigDaemon
  • machine-config-daemon.v1.openshift.com/state: defines the state of the MachineConfigDaemon, It can be done, working and degraded.
$ oc describe node/worker03

No comments: