Configuring a shared container partition for the image-based upgrade
Your single-node OpenShift clusters need to have a shared /var/lib/containers partition for the image-based upgrade. You can do this at install time.
Configuring a shared container partition between ostree stateroots
Apply a MachineConfig to both the seed and the target clusters during installation time to create a separate partition and share the /var/lib/containers partition between the two ostree stateroots that will be used during the upgrade process.
You must complete this procedure at installation time.
Procedure
-
Apply a
MachineConfigto create a separate partition:apiVersion: machineconfiguration.openshift.io/v1kind: MachineConfigmetadata:labels:machineconfiguration.openshift.io/role: mastername: 98-var-lib-containers-partitionedspec:config:ignition:version: 3.2.0storage:disks:- device: /dev/disk/by-path/<root_disk>partitions:- label: var-lib-containersstartMiB: <start_of_partition>sizeMiB: <partition_size>filesystems:- device: /dev/disk/by-partlabel/var-lib-containersformat: xfsmountOptions:- defaults- prjquotapath: /var/lib/containerswipeFilesystem: truesystemd:units:- contents: |-# Generated by Butane[Unit]Before=local-fs.targetRequires=systemd-fsck@dev-disk-by\x2dpartlabel-var\x2dlib\x2dcontainers.serviceAfter=systemd-fsck@dev-disk-by\x2dpartlabel-var\x2dlib\x2dcontainers.service[Mount]Where=/var/lib/containersWhat=/dev/disk/by-partlabel/var-lib-containersType=xfsOptions=defaults,prjquota[Install]RequiredBy=local-fs.targetenabled: truename: var-lib-containers.mountwhere:
<root_disk>- Specifies the root disk, for example
pci-0000:01:00.0-scsi-0:2:0:0. <start_of_partition>- Specifies the start of the partition in MiB. If the value is too small, the installation will fail.
<partition_size>- Specifies a minimum size for the partition of 500 GB (512000 MiB) to ensure adequate disk space for precached images. If the value is too small, the deployments after installation will fail.
Configuring a shared container directory between ostree stateroots when using GitOps ZTP
When you are using the GitOps Zero Touch Provisioning (ZTP) workflow, you do the following procedure to create a separate disk partition on both the seed and target cluster and to share the /var/lib/containers partition.
You must complete this procedure at installation time.
Prerequisites
- You have installed Butane. For more information, see "Installing Butane".
Procedure
-
Create the
storage.bufile:variant: fcosversion: 1.3.0storage:disks:- device: /dev/disk/by-path/pci-<root_disk>wipe_table: falsepartitions:- label: var-lib-containersstart_mib: <start_of_partition>size_mib: <partition_size>filesystems:- path: /var/lib/containersdevice: /dev/disk/by-partlabel/var-lib-containersformat: xfswipe_filesystem: truewith_mount_unit: truemount_options:- defaults- prjquotawhere:
<root_disk>- Specifies the root disk.
<start_of_partition>- Specifies the start of the partition in MiB. If the value is too small, the installation will fail.
<partition_size>- Specifies a minimum size for the partition of 500 GB to ensure adequate disk space for precached images. If the value is too small, the deployments after installation will fail.
-
Convert the
storage.buto an Ignition file by running the following command:$ butane storage.buExample output:
{"ignition":{"version":"3.2.0"},"storage":{"disks":[{"device":"/dev/disk/by-path/pci-0000:00:17.0-ata-1.0","partitions":[{"label":"var-lib-containers","sizeMiB":0,"startMiB":250000}],"wipeTable":false}],"filesystems":[{"device":"/dev/disk/by-partlabel/var-lib-containers","format":"xfs","mountOptions":["defaults","prjquota"],"path":"/var/lib/containers","wipeFilesystem":true}]},"systemd":{"units":[{"contents":"# Generated by Butane\n[Unit]\nRequires=systemd-fsck@dev-disk-by\\x2dpartlabel-var\\x2dlib\\x2dcontainers.service\nAfter=systemd-fsck@dev-disk-by\\x2dpartlabel-var\\x2dlib\\x2dcontainers.service\n\n[Mount]\nWhere=/var/lib/containers\nWhat=/dev/disk/by-partlabel/var-lib-containers\nType=xfs\nOptions=defaults,prjquota\n\n[Install]\nRequiredBy=local-fs.target","enabled":true,"name":"var-lib-containers.mount"}]}} -
Copy the output into the
spec.nodes[].ignitionConfigOverridefield in theClusterInstanceCR:apiVersion: siteconfig.open-cluster-management.io/v1alpha1kind: ClusterInstancemetadata:name: "example-sno"namespace: "example-sno"spec:# ...nodes:- hostName: "node1.example.com"role: "master"ignitionConfigOverride: '{"ignition":{"version":"3.2.0"},"storage":{"disks":[{"device":"/dev/disk/by-path/pci-0000:00:17.0-ata-1.0","partitions":[{"label":"var-lib-containers","sizeMiB":0,"startMiB":250000}],"wipeTable":false}],"filesystems":[{"device":"/dev/disk/by-partlabel/var-lib-containers","format":"xfs","mountOptions":["defaults","prjquota"],"path":"/var/lib/containers","wipeFilesystem":true}]},"systemd":{"units":[{"contents":"# Generated by Butane\n[Unit]\nRequires=systemd-fsck@dev-disk-by\\x2dpartlabel-var\\x2dlib\\x2dcontainers.service\nAfter=systemd-fsck@dev-disk-by\\x2dpartlabel-var\\x2dlib\\x2dcontainers.service\n\n[Mount]\nWhere=/var/lib/containers\nWhat=/dev/disk/by-partlabel/var-lib-containers\nType=xfs\nOptions=defaults,prjquota\n\n[Install]\nRequiredBy=local-fs.target","enabled":true,"name":"var-lib-containers.mount"}]}}'
Verification
-
During or after installation, verify on the hub cluster that the
BareMetalHostobject shows the annotation by running the following command:$ oc get bmh -n my-sno-ns my-sno -ojson | jq '.metadata.annotations["bmac.agent-install.openshift.io/ignition-config-overrides"]'Example output:
"{\"ignition\":{\"version\":\"3.2.0\"},\"storage\":{\"disks\":[{\"device\":\"/dev/disk/by-path/pci-0000:00:17.0-ata-1.0\",\"partitions\":[{\"label\":\"var-lib-containers\",\"sizeMiB\":0,\"startMiB\":250000}],\"wipeTable\":false}],\"filesystems\":[{\"device\":\"/dev/disk/by-partlabel/var-lib-containers\",\"format\":\"xfs\",\"mountOptions\":[\"defaults\",\"prjquota\"],\"path\":\"/var/lib/containers\",\"wipeFilesystem\":true}]},\"systemd\":{\"units\":[{\"contents\":\"# Generated by Butane\\n[Unit]\\nRequires=systemd-fsck@dev-disk-by\\\\x2dpartlabel-var\\\\x2dlib\\\\x2dcontainers.service\\nAfter=systemd-fsck@dev-disk-by\\\\x2dpartlabel-var\\\\x2dlib\\\\x2dcontainers.service\\n\\n[Mount]\\nWhere=/var/lib/containers\\nWhat=/dev/disk/by-partlabel/var-lib-containers\\nType=xfs\\nOptions=defaults,prjquota\\n\\n[Install]\\nRequiredBy=local-fs.target\",\"enabled\":true,\"name\":\"var-lib-containers.mount\"}]}}" -
After installation, check the single-node OpenShift disk status by running the following commands:
# lsblkExample output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTSsda 8:0 0 446.6G 0 disk├─sda1 8:1 0 1M 0 part├─sda2 8:2 0 127M 0 part├─sda3 8:3 0 384M 0 part /boot├─sda4 8:4 0 243.6G 0 part /var│ /sysroot/ostree/deploy/rhcos/var│ /usr│ /etc│ /│ /sysroot└─sda5 8:5 0 202.5G 0 part /var/lib/containers# df -hExample output:
Filesystem Size Used Avail Use% Mounted ondevtmpfs 4.0M 0 4.0M 0% /devtmpfs 126G 84K 126G 1% /dev/shmtmpfs 51G 93M 51G 1% /run/dev/sda4 244G 5.2G 239G 3% /sysroottmpfs 126G 4.0K 126G 1% /tmp/dev/sda5 203G 119G 85G 59% /var/lib/containers/dev/sda3 350M 110M 218M 34% /boottmpfs 26G 0 26G 0% /run/user/1000
Additional resources