以下示例 MachineConfiguration
对象包含节点中断策略。
|
MachineConfiguration 对象和 MachineConfig 对象是不同的对象。MachineConfiguration 对象是 MCO 命名空间中的单例对象,包含 MCO 运算符的配置参数。MachineConfig 对象定义应用于机器配置池的更改。
|
以下示例 MachineConfiguration
对象显示没有用户定义的策略。默认节点中断策略值显示在 status
部分中。
默认节点中断策略
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
name: cluster
spec:
logLevel: Normal
managementState: Managed
operatorLogLevel: Normal
status:
nodeDisruptionPolicyStatus:
clusterPolicies:
files:
- actions:
- type: None
path: /etc/mco/internal-registry-pull-secret.json
- actions:
- type: None
path: /var/lib/kubelet/config.json
- actions:
- reload:
serviceName: crio.service
type: Reload
path: /etc/machine-config-daemon/no-reboot/containers-gpg.pub
- actions:
- reload:
serviceName: crio.service
type: Reload
path: /etc/containers/policy.json
- actions:
- type: Special
path: /etc/containers/registries.conf
- actions:
- reload:
serviceName: crio.service
type: Reload
path: /etc/containers/registries.d
- actions:
- type: None
path: /etc/nmstate/openshift
- actions:
- restart:
serviceName: coreos-update-ca-trust.service
type: Restart
- restart:
serviceName: crio.service
type: Restart
path: /etc/pki/ca-trust/source/anchors/openshift-config-user-ca-bundle.crt
sshkey:
actions:
- type: None
observedGeneration: 9
在以下示例中,当对 SSH 密钥进行更改时,MCO 会清空集群节点,重新加载 crio.service
,重新加载 systemd 配置,并重新启动 crio-service
。
SSH 密钥更改的节点中断策略示例
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
metadata:
name: cluster
namespace: openshift-machine-config-operator
# ...
spec:
nodeDisruptionPolicy:
sshkey:
actions:
- type: Drain
- reload:
serviceName: crio.service
type: Reload
- type: DaemonReload
- restart:
serviceName: crio.service
type: Restart
# ...
在以下示例中,当对 /etc/chrony.conf
文件进行更改时,MCO 会重新加载集群节点上的 chronyd.service
。如果向 /var/run
目录添加文件或修改文件,则 MCO 会应用更改,而无需执行其他操作。
配置文件更改的节点中断策略示例
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
metadata:
name: cluster
namespace: openshift-machine-config-operator
# ...
spec:
nodeDisruptionPolicy:
files:
- actions:
- reload:
serviceName: chronyd.service
type: Reload
path: /etc/chrony.conf
- actions:
- type: None
path: /var/run
在以下示例中,当对 auditd.service
systemd 单元进行更改时,MCO 会清空集群节点,重新加载 crio.service
,重新加载 systemd 管理器配置,并重新启动 crio-service
。
systemd 单元更改的节点中断策略示例
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
metadata:
name: cluster
namespace: openshift-machine-config-operator
# ...
spec:
nodeDisruptionPolicy:
units:
- name: auditd.service
actions:
- type: Drain
- type: Reload
reload:
serviceName: crio.service
- type: DaemonReload
- type: Restart
restart:
serviceName: crio.service
在以下示例中,当对 registries.conf
文件进行更改时(例如,通过编辑 ImageContentSourcePolicy
(ICSP) 对象),MCO 不会清空或重新引导节点,并应用更改而无需执行其他操作。
registries.conf 文件更改的节点中断策略示例
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
metadata:
name: cluster
namespace: openshift-machine-config-operator
# ...
spec:
nodeDisruptionPolicy:
files:
- actions:
- type: None
path: /etc/containers/registries.conf