Machine Config¶
Machine Config Operator Documentation
Creating a Machine Configuration File¶
-
Base64 encode the content for inclusion in a MachineConfig:
-
Place the encoded value after
base64,in the MachineConfig (the base64 stringbXlzZWNyZXR2YWx1ZQ==decodes tomysecretvalue):apiVersion: machineconfiguration.openshift.io/v1 kind: MachineConfig metadata: name: 99-worker-example labels: machineconfiguration.openshift.io/role: worker spec: config: ignition: version: 3.5.0 storage: files: - path: /etc/file.conf mode: 0644 overwrite: true contents: source: data:text/plain;charset=utf-8;base64,bXlzZWNyZXR2YWx1ZQ== -
Apply:
Warning
Applying a MachineConfig that changes file content, systemd units, or other non-SSH configuration will cause the Machine Config Operator to drain and reboot every node in the target pool. Ensure the cluster has sufficient capacity. To defer the reboot, pause the pool first:
oc patch mcp worker --type merge -p '{"spec":{"paused":true}}'. Unpause after:oc patch mcp worker --type merge -p '{"spec":{"paused":false}}'.
Use a File¶
CONTENT=$(base64 -w0 /path/to/myfile.conf)
cat <<EOF
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: worker
name: 99-worker-myfile
spec:
config:
ignition:
version: 3.5.0
storage:
files:
- path: /etc/myfile.conf
mode: 0644
overwrite: true
contents:
source: data:text/plain;base64,${CONTENT}
EOF
To decode/verify:
Creating a Machine Configuration File with Butane¶
Butane transpiles human-readable configs into MachineConfig resources, avoiding manual base64 encoding.
-
Install Butane:
-
Write a Butane config — create
99-worker-example.bu: -
Transpile to MachineConfig:
-
Apply:
Using a Local File¶
Instead of inline, reference a local file: