Skip to content

Commit 887430a

Browse files
committed
WIP - Add microshift installer
1 parent 29201a8 commit 887430a

20 files changed

Lines changed: 2942 additions & 0 deletions

File tree

03-install_microshift.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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: Load stack outputs and add hosts to inventory
18+
hosts: localhost
19+
gather_facts: false
20+
tasks:
21+
- name: Load stack output vars from file
22+
ansible.builtin.include_vars:
23+
file: "{{ hotstack_work_dir | default(playbook_dir) }}/{{ stack_name }}-outputs.yaml"
24+
name: stack_outputs
25+
26+
- name: Add controller-0 to the Ansible inventory
27+
ansible.builtin.add_host: "{{ stack_outputs.controller_ansible_host }}"
28+
29+
- name: Add microshift-0 to the Ansible inventory
30+
ansible.builtin.add_host: "{{ stack_outputs.microshift_ansible_host }}"
31+
32+
- name: Store stack outputs for next play
33+
ansible.builtin.set_fact:
34+
stack_outputs: "{{ stack_outputs }}"
35+
cacheable: true
36+
37+
- name: Install MicroShift
38+
hosts: microshifts,controllers
39+
gather_facts: true
40+
strategy: linear
41+
roles:
42+
- role: microshift_installer
43+
vars:
44+
microshift_config: "{{ hostvars['localhost']['stack_outputs']['microshift_config'] }}"
45+
microshift_nmstate_config: "{{ hostvars['localhost']['stack_outputs']['microshift_nmstate_config'] }}"

bootstrap_microshift.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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: Bootstrap virtual infrastructure on Openstack cloud
18+
ansible.builtin.import_playbook: 01-infra.yml
19+
20+
- name: Bootstrap controller node
21+
ansible.builtin.import_playbook: 02-bootstrap_controller.yml
22+
23+
- name: Install MicroShift
24+
ansible.builtin.import_playbook: 03-install_microshift.yml
25+
26+
# - name: Deploy RedFish Virtual BMC
27+
# ansible.builtin.import_playbook: 04-redfish_virtual_bmc.yml
28+
29+
# - name: Deploy RHOSO
30+
# ansible.builtin.import_playbook: 05_deploy_rhoso.yml
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# MicroShift Installer Role
2+
3+
This Ansible role installs and configures MicroShift on RHEL 9 systems.
4+
It handles subscription management, package installation, network
5+
configuration using nmstate, and initial cluster bootstrapping.
6+
7+
## Requirements
8+
9+
- RHEL 9.x system
10+
- Valid Red Hat subscription with access to MicroShift repositories
11+
- Network connectivity to Red Hat repositories
12+
- Sufficient system resources (4GB RAM, 2 CPUs minimum recommended)
13+
14+
## Role Variables
15+
16+
### Required Variables
17+
18+
```yaml
19+
# Subscription Manager credentials
20+
subscription_manager_org_id: "your-org-id"
21+
subscription_manager_activation_key: "your-activation-key"
22+
23+
# MicroShift configuration from Heat stack output (raw YAML for /etc/microshift/config.yaml)
24+
microshift_config:
25+
dns:
26+
baseDomain: openstack.lab
27+
node:
28+
hostnameOverride: microshift-0
29+
nodeIP: 192.168.32.10
30+
31+
# nmstate network configuration from Heat stack output
32+
microshift_nmstate_config:
33+
interfaces: [] # nmstate interface configuration
34+
```
35+
36+
### Optional Variables
37+
38+
```yaml
39+
# MicroShift version (default: "4.18")
40+
microshift_installer_version: "4.18"
41+
42+
# Service configuration
43+
microshift_installer_service_enable: true
44+
microshift_installer_service_state: started
45+
46+
# Kubeconfig paths
47+
microshift_installer_kubeconfig_path: "/var/lib/microshift/resources/kubeadmin/kubeconfig"
48+
49+
# Cluster ready timeout (seconds)
50+
microshift_installer_wait_timeout: 600
51+
52+
# Packages to install on MicroShift node
53+
microshift_installer_packages:
54+
- microshift
55+
- microshift-networking
56+
- microshift-selinux
57+
- nmstate
58+
- containernetworking-plugins
59+
```
60+
61+
## Dependencies
62+
63+
This role has no external dependencies beyond the built-in Ansible modules.
64+
65+
## Example Playbook
66+
67+
```yaml
68+
- hosts: microshift_hosts
69+
vars:
70+
subscription_manager_org_id: "{{ lookup('env', 'RH_ORG_ID') }}"
71+
subscription_manager_activation_key: "{{ lookup('env', 'RH_ACTIVATION_KEY') }}"
72+
microshift_config: "{{ heat_stack_outputs.microshift_config }}"
73+
microshift_nmstate_config: "{{ heat_stack_outputs.microshift_nmstate_config }}"
74+
roles:
75+
- microshift_installer
76+
```
77+
78+
**Note**: The role handles privilege escalation internally using
79+
`become: true` for tasks that require root access, so it's not
80+
necessary to set `become: true` at the play level.
81+
82+
## Installation Process
83+
84+
The role performs the following steps on the MicroShift node:
85+
86+
1. **System Registration**: Registers the RHEL system with Red Hat
87+
Subscription Manager using the provided organization ID and activation
88+
key.
89+
90+
2. **Repository Enablement**: Enables the required repositories:
91+
- `rhocp-<version>-for-rhel-9-x86_64-rpms`
92+
- `fast-datapath-for-rhel-9-x86_64-rpms`
93+
94+
3. **Package Installation**: Installs MicroShift and dependencies:
95+
- microshift
96+
- microshift-networking
97+
- microshift-selinux
98+
- nmstate
99+
- containernetworking-plugins
100+
101+
4. **Network Configuration**: Applies nmstate network configuration for:
102+
- Physical interfaces
103+
- VLAN interfaces
104+
- Linux bridges
105+
- IP addressing
106+
107+
5. **MicroShift Configuration**: Creates `/etc/microshift/config.yaml` with:
108+
- Base domain
109+
- Hostname override
110+
- Node IP address
111+
112+
6. **Service Management**: Starts and enables the MicroShift service.
113+
114+
7. **Cluster Bootstrap**: Waits for the cluster to be ready and the
115+
kubeconfig to be available.
116+
117+
The role also performs controller-specific tasks:
118+
119+
1. **OC Client Installation**: Downloads and installs the `oc` CLI on the
120+
controller node.
121+
122+
2. **Kubeconfig Setup**: Fetches the kubeconfig from the MicroShift node
123+
and sets it up on the controller at `~/.kube/config`.
124+
125+
## Network Configuration
126+
127+
The role uses nmstate to configure complex network topologies. The
128+
`microshift_nmstate_config` should contain nmstate-compatible
129+
configuration with interface definitions. This is typically generated from
130+
the Heat stack output.
131+
132+
Example network configuration includes:
133+
134+
- Physical Ethernet interfaces
135+
- VLAN-tagged interfaces for OpenStack networks
136+
- Linux bridges for OVN and Ironic
137+
- Static IP addressing
138+
139+
## MicroShift Cluster Access
140+
141+
After successful installation, the kubeconfig is available at:
142+
143+
- System location: `/var/lib/microshift/resources/kubeadmin/kubeconfig`
144+
- User location: `~/.kube/config` (copied by the role)
145+
146+
Access the cluster:
147+
148+
```bash
149+
export KUBECONFIG=~/.kube/config
150+
oc get nodes
151+
oc get pods -A
152+
```
153+
154+
## Integration with Hotstack
155+
156+
This role is designed to be used with the Hotstack automation framework
157+
as a replacement for `ocp_agent_installer` in MicroShift-based scenarios.
158+
It expects the `microshift_config` variable to be populated from Heat
159+
stack outputs.
160+
161+
## Troubleshooting
162+
163+
### Service Logs
164+
165+
```bash
166+
journalctl -u microshift -f
167+
```
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
# Subscription Manager configuration
18+
subscription_manager_org_id: ""
19+
subscription_manager_activation_key: ""
20+
21+
# MicroShift configuration from heat stack output
22+
microshift_config: {}
23+
24+
# MicroShift service configuration
25+
microshift_installer_service_enable: true
26+
microshift_installer_service_state: started
27+
28+
# Kubeconfig location on MicroShift node
29+
microshift_installer_kubeconfig_path: "/var/lib/microshift/resources/kubeadmin/kubeconfig"
30+
31+
# Wait for cluster ready timeout (seconds)
32+
microshift_installer_wait_timeout: 600
33+
34+
# Packages to install on MicroShift node
35+
microshift_installer_packages:
36+
- microshift
37+
- microshift-networking
38+
- microshift-selinux
39+
- nmstate
40+
- containernetworking-plugins
41+
42+
# MicroShift version for repository enablement and client download
43+
microshift_installer_version: "4.18"
44+
45+
# OpenShift client download configuration (for controller)
46+
microshift_installer_mirror_url: https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp
47+
microshift_installer_client_url: "{{ microshift_installer_mirror_url }}/stable-{{ microshift_installer_version }}/openshift-client-linux.tar.gz"
48+
49+
# Controller paths
50+
microshift_installer_base_dir: /home/zuul
51+
microshift_installer_bin_dir: "{{ microshift_installer_base_dir }}/bin"
52+
microshift_installer_kube_config_dir: "{{ microshift_installer_base_dir }}/.kube"
53+
microshift_installer_download_dir: "{{ microshift_installer_base_dir }}/downloads"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
galaxy_info:
18+
author: OpenStack K8s Operators
19+
description: Install and configure MicroShift on RHEL 9
20+
company: Red Hat
21+
license: Apache-2.0
22+
min_ansible_version: "2.9"
23+
platforms:
24+
- name: EL
25+
versions:
26+
- "9"
27+
galaxy_tags:
28+
- openshift
29+
- microshift
30+
- kubernetes
31+
- edge
32+
33+
dependencies: []

0 commit comments

Comments
 (0)