Skip to content

Commit ec2b161

Browse files
committed
WIP - Add MicroShift support
Introduces disk image building elements, Ansible roles, Heat templates, and bootstrap/setup playbooks for deploying MicroShift as an alternative to OCP. Assisted-By: Claude (claude-4.5-sonnet) Signed-off-by: Harald Jensås <hjensas@redhat.com>
1 parent 8f04e80 commit ec2b161

65 files changed

Lines changed: 2899 additions & 63 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ cloud-secret.*.yaml.bak
66
dataplane_ssh_keys_vars.yaml
77
*-outputs.yaml
88
hotstack_overrides.yaml
9+
images/*.qcow2
10+
images/.*-build/
11+
images/*.d/

03-install_ocp.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
- role: ocp_agent_installer
3737
delegate_to: controller-0
3838
vars:
39+
ocp_installer_type: "{{ stack_outputs.ocp_installer_type | default('agent') }}"
3940
install_config: "{{ stack_outputs.ocp_install_config }}"
4041
agent_config: "{{ stack_outputs.ocp_agent_config }}"
4142
pull_secret: "{{ slurp_pull_secret.content }}"

03-setup_microshift.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
- name: Setup MicroShift
18+
hosts: localhost
19+
gather_facts: true
20+
strategy: linear
21+
pre_tasks:
22+
- name: Load stack output vars from file
23+
ansible.builtin.include_vars:
24+
file: "{{ hotstack_work_dir | default(playbook_dir) }}/{{ stack_name }}-outputs.yaml"
25+
name: stack_outputs
26+
27+
- name: Add controller-0 to the Ansible inventory
28+
ansible.builtin.add_host: "{{ stack_outputs.controller_ansible_host }}"
29+
30+
- name: Add microshift-0 to the Ansible inventory
31+
when: stack_outputs.microshift_ansible_host is defined
32+
ansible.builtin.add_host: "{{ stack_outputs.microshift_ansible_host }}"
33+
34+
- name: Slurp the pull-secret file
35+
register: slurp_pull_secret
36+
ansible.builtin.slurp:
37+
src: "{{ pull_secret_file }}"
38+
39+
roles:
40+
- role: microshift_setup
41+
delegate_to: controller-0
42+
vars:
43+
pull_secret: "{{ slurp_pull_secret.content }}"

bootstrap.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
- name: Install Openshift Container Platform
2424
ansible.builtin.import_playbook: 03-install_ocp.yml
2525

26+
- name: Setup MicroShift
27+
ansible.builtin.import_playbook: 03-setup_microshift.yml
28+
2629
- name: Deploy RedFish Virtual BMC
2730
ansible.builtin.import_playbook: 04-redfish_virtual_bmc.yml
2831

images/.gitignore

Lines changed: 0 additions & 9 deletions
This file was deleted.

images/Makefile

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ CONTROLLER_IMAGE_NAME ?= controller.qcow2
22
CONTROLLER_IMAGE_FORMAT ?= raw
33
CONTROLLER_DIB_VENV ?= $(HOME)/controller-dib-venv
44
CONTROLLER_DIB_WORKDIR ?= $(CURDIR)/.controller-build
5+
MICROSHIFT_IMAGE_NAME ?= microshift.qcow2
6+
MICROSHIFT_IMAGE_FORMAT ?= raw
7+
MICROSHIFT_DIB_VENV ?= $(HOME)/microshift-dib-venv
8+
MICROSHIFT_DIB_WORKDIR ?= $(CURDIR)/.microshift-build
9+
MICROSHIFT_VERSION ?= 4.20
10+
MICROSHIFT_RPM_ARCHIVE ?=
511
BLANK_IMAGE_NAME ?= blank-image.qcow2
612
BLANK_IMAGE_FORMAT ?= raw
713
BLANK_IMAGE_SIZE ?= 1M
@@ -22,9 +28,9 @@ FORCE10_9_IMAGE ?=
2228
NXOS_IMAGE ?=
2329
SONIC_IMAGE ?=
2430

25-
all: controller blank nat64
31+
all: controller microshift blank nat64
2632

27-
clean: controller_clean blank_clean nat64_clean
33+
clean: controller_clean microshift_clean blank_clean nat64_clean
2834

2935
controller: controller_dib_setup controller_dib_build controller_convert
3036

@@ -70,6 +76,52 @@ controller_clean:
7076
sudo rm -rf $(CONTROLLER_DIB_WORKDIR); \
7177
fi
7278

79+
microshift: microshift_dib_setup microshift_dib_build microshift_convert
80+
81+
microshift_dib_setup:
82+
@if [ ! -d "$(MICROSHIFT_DIB_VENV)" ]; then \
83+
echo "Creating Python virtual environment at $(MICROSHIFT_DIB_VENV)..."; \
84+
python3 -m venv $(MICROSHIFT_DIB_VENV); \
85+
. $(MICROSHIFT_DIB_VENV)/bin/activate && \
86+
pip install --upgrade pip setuptools wheel && \
87+
pip install diskimage-builder; \
88+
else \
89+
echo "Virtual environment already exists at $(MICROSHIFT_DIB_VENV)"; \
90+
fi
91+
92+
microshift_dib_build: microshift_dib_setup
93+
@echo "Building MicroShift image using diskimage-builder..."
94+
@mkdir -p $(MICROSHIFT_DIB_WORKDIR)/cache
95+
@. $(MICROSHIFT_DIB_VENV)/bin/activate && \
96+
cd $(CURDIR) && \
97+
ELEMENTS_PATH=$(CURDIR)/dib/elements \
98+
DIB_IMAGE_CACHE=$(MICROSHIFT_DIB_WORKDIR)/cache \
99+
DIB_DEBUG_TRACE=1 \
100+
DIB_MICROSHIFT_VERSION=$(MICROSHIFT_VERSION) \
101+
DIB_MICROSHIFT_RPM_ARCHIVE=$(MICROSHIFT_RPM_ARCHIVE) \
102+
diskimage-builder dib/microshift-image.yaml
103+
@echo "MicroShift image built successfully: $(MICROSHIFT_IMAGE_NAME)"
104+
105+
microshift_convert:
106+
ifeq ($(MICROSHIFT_IMAGE_FORMAT),raw)
107+
@echo "Converting MicroShift image to raw format (in-place)..."
108+
qemu-img convert -p -f qcow2 -O raw $(MICROSHIFT_IMAGE_NAME) $(MICROSHIFT_IMAGE_NAME).tmp
109+
mv $(MICROSHIFT_IMAGE_NAME).tmp $(MICROSHIFT_IMAGE_NAME)
110+
@echo "MicroShift image converted to raw format: $(MICROSHIFT_IMAGE_NAME)"
111+
endif
112+
113+
microshift_clean:
114+
rm -f $(MICROSHIFT_IMAGE_NAME)
115+
rm -f $(MICROSHIFT_IMAGE_NAME).tmp
116+
rm -rf $(MICROSHIFT_DIB_VENV)
117+
@if [ -z "$(MICROSHIFT_DIB_WORKDIR)" ] || [ "$(MICROSHIFT_DIB_WORKDIR)" = "/" ]; then \
118+
echo "ERROR: MICROSHIFT_DIB_WORKDIR is not set or is dangerous: $(MICROSHIFT_DIB_WORKDIR)"; \
119+
exit 1; \
120+
fi
121+
@if [ -d "$(MICROSHIFT_DIB_WORKDIR)" ]; then \
122+
sudo rm -rf $(MICROSHIFT_DIB_WORKDIR); \
123+
fi
124+
73125
blank:
74126
qemu-img create -f $(BLANK_IMAGE_FORMAT) $(BLANK_IMAGE_NAME) $(BLANK_IMAGE_SIZE)
75127

images/README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ deployments. The tasks are executed using the `make` utility.
1313
- **controller**: A customized CentOS 9 Stream image with packages needed for
1414
the hotstack controller node. Built using diskimage-builder (DIB) with custom
1515
elements from the `dib/` subdirectory.
16+
- **microshift**: A CentOS 9 Stream image with MicroShift packages installed
17+
from GitHub releases. Built using diskimage-builder (DIB) with the
18+
`hotstack-microshift` element. The image is intentionally unconfigured and
19+
requires cloud-init or manual setup to enable services and configure runtime
20+
settings.
1621
- **blank**: A minimal blank image used for virtual baremetal node disks with
1722
Redfish virtual BMC
1823
- **nat64**: A NAT64 appliance image built using ci-framework for IPv6-only
@@ -108,6 +113,18 @@ directly use qcow2 images for VM disks.
108113
`CONTROLLER_IMAGE_FORMAT` (in-place conversion if `raw`).
109114
- `controller_clean`: Removes the controller image, virtual environment, and
110115
build artifacts.
116+
- `microshift`: Builds the MicroShift image using diskimage-builder (DIB).
117+
Depends on `microshift_dib_setup`, `microshift_dib_build`, and
118+
`microshift_convert`.
119+
- `microshift_dib_setup`: Creates a Python virtual environment and installs
120+
diskimage-builder.
121+
- `microshift_dib_build`: Builds the MicroShift image using DIB with the
122+
configuration from `dib/microshift-image.yaml` and the custom
123+
`hotstack-microshift` element from `dib/elements/`.
124+
- `microshift_convert`: Converts the image to the format specified by
125+
`MICROSHIFT_IMAGE_FORMAT` (in-place conversion if `raw`).
126+
- `microshift_clean`: Removes the MicroShift image, virtual environment, and
127+
build artifacts.
111128
- `blank`: A target that creates a blank image file of the specified size in the
112129
format specified by `BLANK_IMAGE_FORMAT`.
113130
- `blank_clean`: A target that removes the blank image file.
@@ -134,6 +151,26 @@ directly use qcow2 images for VM disks.
134151
specified by `SWITCH_HOST_IMAGE_FORMAT` (in-place conversion if `raw`).
135152
- `switch-host_clean`: A target that removes the switch-host image file.
136153

154+
### MicroShift Image Variables
155+
156+
- `MICROSHIFT_IMAGE_NAME`: The name of the MicroShift image file to be created
157+
(default: `microshift.qcow2`).
158+
- `MICROSHIFT_IMAGE_FORMAT`: The desired format for the MicroShift image
159+
(default: `raw`). Set to `qcow2` to skip conversion and keep the original
160+
DIB output format.
161+
- `MICROSHIFT_DIB_VENV`: Path to the Python virtual environment for
162+
diskimage-builder (default: `~/microshift-dib-venv`).
163+
- `MICROSHIFT_DIB_WORKDIR`: Working directory for DIB build artifacts and cache
164+
(default: `.microshift-build`).
165+
- `MICROSHIFT_VERSION`: MicroShift major.minor version for dependency
166+
resolution (default: `4.20`). This determines which OpenShift mirror
167+
repository to enable and which GitHub release to auto-discover.
168+
- `DIB_MICROSHIFT_RPM_ARCHIVE`: *Optional*. Direct URL to the MicroShift RPM
169+
archive (tgz file) from a GitHub release. When not set, the latest release
170+
matching `MICROSHIFT_VERSION` is auto-discovered from the
171+
`microshift-io/microshift` GitHub releases. Example:
172+
`https://github.com/microshift-io/microshift/releases/download/4.20.0_g153ff0ca9_4.20.0_okd_scos.16/microshift-rpms-x86_64.tgz`
173+
137174
### Examples
138175

139176
#### Cleanup
@@ -171,6 +208,45 @@ make clean
171208
--file controller.qcow2
172209
```
173210

211+
#### Building and uploading the MicroShift image to glance
212+
213+
1. Build the MicroShift image (using diskimage-builder):
214+
215+
The latest RPM archive for the configured version is auto-discovered from
216+
GitHub releases:
217+
218+
```shell
219+
make microshift \
220+
MICROSHIFT_VERSION=4.20 \
221+
MICROSHIFT_IMAGE_FORMAT=raw # Optional, defaults to raw
222+
```
223+
224+
To pin a specific release, set `DIB_MICROSHIFT_RPM_ARCHIVE` explicitly:
225+
226+
```shell
227+
make microshift \
228+
DIB_MICROSHIFT_RPM_ARCHIVE=https://github.com/microshift-io/microshift/releases/download/4.20.0_g153ff0ca9_4.20.0_okd_scos.16/microshift-rpms-x86_64.tgz \
229+
MICROSHIFT_VERSION=4.20
230+
```
231+
232+
This will create a Python virtual environment, install diskimage-builder,
233+
build the image using the configuration from `dib/microshift-image.yaml`, and
234+
convert it to raw format (default).
235+
236+
2. Upload the MicroShift image to Glance:
237+
238+
```shell
239+
openstack image create hotstack-microshift \
240+
--disk-format raw \
241+
--file microshift.qcow2 \
242+
--property hw_firmware_type=uefi \
243+
--property hw_machine_type=q35
244+
```
245+
246+
3. See `dib/elements/hotstack-microshift/README.rst` for detailed runtime
247+
configuration instructions, including firewall setup, LVM configuration for
248+
TopoLVM, kubeconfig setup, and service enablement.
249+
174250
#### Building and uploading the blank image to glance
175251

176252
1. Create the blank image:
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
===================
2+
hotstack-microshift
3+
===================
4+
5+
DIB element for building CentOS 9 Stream images with MicroShift packages.
6+
7+
This element installs MicroShift and supporting packages. Runtime configuration
8+
(firewall, MicroShift service, kubeconfig, LVM) is deferred to cloud-init or
9+
manual setup.
10+
11+
**Packages installed (via install.d):**
12+
13+
- microshift - Core MicroShift service
14+
- microshift-networking - OVN-Kubernetes networking
15+
- microshift-topolvm - TopoLVM storage provisioner
16+
- microshift-olm - Operator Lifecycle Manager
17+
- greenboot (pinned to 0.15.*) - Health check framework
18+
19+
**Packages installed (via package-installs.yaml):**
20+
21+
- iscsi-initiator-utils - iSCSI initiator for Cinder iSCSI backend
22+
- device-mapper-multipath - Multipath I/O for Cinder iSCSI backend
23+
- lvm2 - LVM tools for TopoLVM volume management
24+
- jq - JSON parsing for GitHub API
25+
- bash-completion - Shell completion for kubectl
26+
- createrepo_c - Local RPM repository creation (pre-install.d phase)
27+
28+
**Pre-configured Services (via post-install.d):**
29+
30+
- iscsid.service - iSCSI initiator daemon (enabled)
31+
- multipathd.service - Multipath daemon (enabled)
32+
33+
**Static Configuration Files (via install-static):**
34+
35+
- ``/etc/iscsi/iscsid.conf`` - iSCSI initiator configuration
36+
- ``/etc/multipath.conf`` - Multipath I/O configuration
37+
- ``/etc/sysctl.d/90-microshift-inotify.conf`` - Increased inotify limits
38+
39+
**Repositories:**
40+
41+
The OpenShift mirror dependency repository (``microshift-deps-*.repo``) is
42+
retained in the image after build, allowing runtime package updates from
43+
``mirror.openshift.com``. The temporary local RPM repository used during
44+
build is cleaned up in ``post-install.d``.
45+
46+
**Environment Variables:**
47+
48+
- ``DIB_MICROSHIFT_VERSION`` (default: ``4.20``)
49+
MicroShift major.minor version. Used for OpenShift mirror dependency
50+
resolution and auto-discovery of the latest GitHub release.
51+
- ``DIB_MICROSHIFT_RPM_ARCHIVE`` (default: auto-discovered)
52+
Direct URL to a MicroShift RPM archive (``.tgz``). When not set, the latest
53+
release matching ``DIB_MICROSHIFT_VERSION`` is auto-discovered from the
54+
``microshift-io/microshift`` GitHub releases.
55+
56+
**What's NOT Configured (Deferred to Runtime):**
57+
58+
The image is intentionally minimal and requires cloud-init or manual setup:
59+
60+
1. Firewall configuration - No firewall rules configured
61+
2. MicroShift service - NOT enabled (must be enabled at runtime)
62+
3. Kubeconfig symlink - ``/root/.kube/config`` not created
63+
4. LVM setup - TopoLVM volume group not created
64+
65+
**Example Runtime Configuration:**
66+
67+
.. code-block:: bash
68+
69+
# Setup firewall
70+
firewall-offline-cmd --zone=trusted --add-source=10.42.0.0/16
71+
firewall-offline-cmd --zone=trusted --add-source=169.254.169.1
72+
firewall-offline-cmd --zone=public --add-port=6443/tcp
73+
firewall-offline-cmd --zone=public --add-port=2379/tcp
74+
firewall-offline-cmd --zone=public --add-port=2380/tcp
75+
systemctl enable --now firewalld
76+
77+
# Setup LVM for TopoLVM
78+
pvcreate /dev/vdb
79+
vgcreate microshift /dev/vdb
80+
81+
# Setup kubeconfig
82+
mkdir -p /root/.kube
83+
ln -sf /var/lib/microshift/resources/kubeadmin/kubeconfig /root/.kube/config
84+
85+
# Enable and start MicroShift
86+
systemctl enable --now microshift
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
install-static
2+
package-installs
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright Red Hat, Inc.
2+
# All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
# not use this file except in compliance with the License. You may obtain
6+
# a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
# License for the specific language governing permissions and limitations
14+
# under the License.
15+
16+
export DIB_MICROSHIFT_VERSION=${DIB_MICROSHIFT_VERSION:-4.20}
17+
# Auto-discovered from GitHub releases if not set.
18+
export DIB_MICROSHIFT_RPM_ARCHIVE=${DIB_MICROSHIFT_RPM_ARCHIVE:-}

0 commit comments

Comments
 (0)