Skip to content

Commit b21d3c8

Browse files
veera-damisettiroot
andauthored
Enhancement: Support for zVM compute nodes to Hosted Control Plane - vswitch FCP/DASD (#227)
Enhancement: Support for zVM compute nodes to Hosted Control Plane - vswitch FCP/DASD - Code changes for supporting zVM for Hosted Control Plane - Supported network type : vswitch - Supported disk types: FCP/DASD - Updated the documentation for the same --------- Signed-off-by: root <[email protected]> Co-authored-by: root <[email protected]>
1 parent 3d66a58 commit b21d3c8

File tree

18 files changed

+305
-40
lines changed

18 files changed

+305
-40
lines changed

docs/run-the-playbooks-for-hypershift.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Run the Playbooks
22
## Prerequisites
33
* Running OCP Cluster ( Management Cluster )
4-
* KVM host with root user access or user with sudo privileges
4+
* KVM host with root user access or user with sudo privileges if compute nodes are KVM.
5+
* zvm host ( bastion ) and nodes if compute nodes are zVM.
56

67
### Network Prerequisites
78
* DNS entry to resolve api.${cluster}.${domain} , api-int.${cluster}.${domain} , *apps.${cluster}.${domain} to a load balancer deployed to redirect incoming traffic to the ingresses pod ( Bastion ).
89
* If using dynamic IP for agents, make sure you have entries in DHCP Server for macaddresses you are using in installation to map to IPv4 addresses and along with this DHCP server should make your IPs to use nameserver which you have configured.
910
## Note:
10-
* As of now we are supporting only macvtap for hypershift Agent based installation.
11+
* As of now we are supporting only macvtap for hypershift Agent based installation for KVM compute nodes.
1112

1213
## Step-1: Setup Ansible Vault for Management Cluster Credentials
1314
### Overview
@@ -36,7 +37,7 @@ ansible-vault edit playbooks/secrets.yaml
3637

3738
## Step-2: Initial Setup for Hypershift
3839
* Navigate to the [root folder of the cloned Git repository](https://github.com/IBM/Ansible-OpenShift-Provisioning) in your terminal (`ls` should show [ansible.cfg](https://github.com/IBM/Ansible-OpenShift-Provisioning/blob/main/ansible.cfg)).
39-
* Update all the variables in Section-16 ( Hypershift ) and Section-3 ( File Server : ip , protocol and iso_mount_dir ) in [all.yaml](https://github.com/veera-damisetti/Ansible-OpenShift-Provisioning/blob/main/inventories/default/group_vars/all.yaml.template) before running the playbooks.
40+
* Update variables as per the compute node type (zKVM /zVM) in Section-16 ( Hypershift ) and Section-3 ( File Server : ip , protocol and iso_mount_dir ) in [all.yaml](https://github.com/veera-damisetti/Ansible-OpenShift-Provisioning/blob/main/inventories/default/group_vars/all.yaml.template) before running the playbooks.
4041
* First playbook to be run is setup_for_hypershift.yaml which will create inventory file for hypershift and will add ssh key to the kvm host.
4142

4243
* Run this shell command:

docs/set-variables-group-vars.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
## 16 - Hypershift ( Optional )
199199
**Variable Name** | **Description** | **Example**
200200
:--- | :--- | :---
201+
**hypershift.compute_node_type** | Select the compute node type for HCP , either zKVM or zVM | zvm
201202
**hypershift.kvm_host** | IPv4 address of KVM host for hypershift <br /> (kvm host where you want to run all oc commands and create VMs)| 192.168.10.1
202203
**hypershift.kvm_host_user** | User for KVM host | root
203204
**hypershift.bastion_hypershift** | IPv4 address for bastion of Hosted Cluster | 192.168.10.1
@@ -232,15 +233,23 @@
232233
**hypershift.asc.iso_url** | Give URL for ISO image | https://... <br /> ...s390x-live.s390x.iso
233234
**hypershift.asc.root_fs_url** | Give URL for rootfs image | https://... <br /> ... live-rootfs.s390x.img
234235
**hypershift.asc.mce_namespace** | Namespace where your Multicluster Engine Operator is installed. <br /> Recommended Namespace for MCE is 'multicluster-engine'. <br /> Change this only if MCE is installed in other namespace. | multicluster-engine
236+
**hypershift.agents_parms.agents_count** | Number of agents for the hosted cluster <br /> The same number of compute nodes will be attached to Hosted Cotrol Plane | 2
235237
**hypershift.agents_parms.static_ip_parms.static_ip** | true or false - use static IPs for agents using NMState | true
236238
**hypershift.agents_parms.static_ip_parms.ip** | List of IP addresses for agents | 192.168.10.1
237239
**hypershift.agents_parms.static_ip_parms.interface** | Interface for agents for configuring NMStateConfig | eth0
238-
**hypershift.agents_parms.agents_count** | Number of agents for the hosted cluster <br /> The same number of compute nodes will be attached to Hosted Cotrol Plane | 2
239240
**hypershift.agents_parms.agent_mac_addr** | List of macaddresses for the agents. <br /> Configure in DHCP if you are using dynamic IPs for Agents. | - 52:54:00:ba:d3:f7
240241
**hypershift.agents_parms.disk_size** | Disk size for agents | 100G
241242
**hypershift.agents_parms.ram** | RAM for agents | 16384
242243
**hypershift.agents_parms.vcpus** | vCPUs for agents | 4
243244
**hypershift.agents_parms.nameserver** | Nameserver to be used for agents | 192.168.10.1
245+
**hypershift.agents_parms.zvm_parameters.network_mode** | Network mode for zvm nodes <br /> Supported modes: vswitch | vswitch
246+
**hypershift.agents_parms.zvm_parameters.disk_type** | Disk type for zvm nodes <br /> Supported disk types: fcp, dasd | dasd
247+
**hypershift.agents_parms.zvm_parameters.vcpus** | CPUs for each zvm node | 4
248+
**hypershift.agents_parms.zvm_parameters.memory** | RAM for each zvm node | 16384
249+
**hypershift.agents_parms.zvm_parameters.nameserver** | Nameserver for compute nodes | 192.168.10.1
250+
**hypershift.agents_parms.zvm_parameters.subnetmask** | Subnet mask for compute nodes | 255.255.255.0
251+
**hypershift.agents_parms.zvm_parameters.gateway** | Gateway for compute nodes | 192.168.10.1
252+
**hypershift.agents_parms.zvm_parameters.nodes** | Set of parameters for zvm nodes <br /> Give the details of each zvm node here |
244253

245254
## 17 - (Optional) Disconnected cluster setup
246255
**Variable Name** | **Description** | **Example**

inventories/default/group_vars/all.yaml.template

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ env:
175175
kvm: [ libguestfs, libvirt-client, libvirt-daemon-config-network, libvirt-daemon-kvm, cockpit-machines, libvirt-devel, virt-top, qemu-kvm, python3-lxml, cockpit, lvm2 ]
176176
bastion: [ haproxy, httpd, bind, bind-utils, expect, firewalld, mod_ssl, python3-policycoreutils, rsync ]
177177
hypershift: [ make, jq, git, virt-install ]
178+
zvm: [ git, python3-pip, python3-devel, openssl-devel, rust, cargo, libffi-devel, wget, tar, jq, gcc, make, x3270, python39 ]
178179

179180
# Section 12 - OpenShift Settings
180181
install_config:
@@ -239,13 +240,15 @@ rhcos_live_rootfs: "rhcos-4.12.3-s390x-live-rootfs.s390x.img"
239240
# Section 16 - Hypershift ( Optional )
240241

241242
hypershift:
243+
compute_node_type: # KVM or zVM
244+
242245
kvm_host:
243246
kvm_host_user:
244247
bastion_hypershift:
245248
bastion_hypershift_user:
246249

247-
create_bastion: true
248-
networking_device: enc1100
250+
create_bastion: true
251+
networking_device: enc1100 # Following set of parameters required only if create_bastion is true
249252
gateway:
250253

251254
bastion_parms:
@@ -257,6 +260,9 @@ hypershift:
257260
gateway:
258261
subnet_mask:
259262

263+
264+
# Parameters for oc login
265+
260266
mgmt_cluster_nameserver:
261267
oc_url:
262268

@@ -291,20 +297,76 @@ hypershift:
291297
mce_namespace: multicluster-engine # This is the Recommended Namespace for Multicluster Engine operator
292298

293299
agents_parms:
300+
agents_count:
301+
302+
# KVM specific parameters - KVM on s390x
303+
294304
static_ip_parms:
295305
static_ip: true
296306
ip: # Required only if static_ip is true
297307
#-
298308
#-
299309
interface: eth0
300-
agents_count:
301310
# If you want to use specific mac addresses, provide them here
302311
agent_mac_addr:
303312
#-
304313
disk_size: 100G
305314
ram: 16384
306315
vcpus: 4
307316
nameserver:
317+
318+
319+
320+
# zVM specific parameters - s390x
321+
322+
zvm_parameters:
323+
network_mode: vswitch # Supported modes: vswitch
324+
disk_type: # Supported modes: fcp , dasd
325+
vcpus: 4
326+
memory: 16384
327+
nameserver:
328+
subnetmask:
329+
gateway:
330+
331+
nodes:
332+
- name:
333+
host:
334+
user:
335+
password:
336+
osa:
337+
ifname: encbdf0
338+
id: 0.0.bdf0,0.0.bdf1,0.0.bdf2
339+
ip:
340+
341+
# Required if disk_type is dasd
342+
dasd:
343+
disk_id:
344+
345+
# Required if disk_type is fcp
346+
lun:
347+
- id:
348+
paths:
349+
- wwpn:
350+
fcp:
351+
352+
- name:
353+
host:
354+
user:
355+
password:
356+
osa:
357+
ifname: encbdf0
358+
id: 0.0.bdf0,0.0.bdf1,0.0.bdf2
359+
ip:
360+
361+
dasd:
362+
disk_id:
363+
364+
lun:
365+
- id:
366+
paths:
367+
- wwpn:
368+
fcp:
369+
308370

309371
# Section 17 - (Optional) Setup disconnected clusters
310372
# Warning: currently, the oc-mirror plugin is officially downloadable to amd64 only.

playbooks/create_agents_and_wait_for_install_complete.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44
roles:
55
- boot_agents_hypershift
66

7+
- name: Boot zvm nodes
8+
hosts: bastion_hypershift
9+
tasks:
10+
- name: Install tessia baselib
11+
import_role:
12+
name: install_tessia_baselib
13+
when: hypershift.compute_node_type | lower == 'zvm'
14+
15+
- name: Start zvm nodes
16+
include_tasks: ../roles/boot_zvm_nodes_hypershift/tasks/main.yaml
17+
loop: "{{ range(hypershift.agents_parms.agents_count | int) | list }}"
18+
when: hypershift.compute_node_type | lower == 'zvm'
19+
720
- name: Scale Nodepool & Configure Haproxy on bastion for hosted workers
821
hosts: bastion_hypershift
922
roles:

playbooks/create_hosted_cluster.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
- name: Setting host
99
set_fact:
1010
host: 'kvm_host_hypershift'
11+
when: hypershift.compute_node_type | lower != 'zvm'
12+
1113
- name: Install Prereqs on host
1214
import_role:
1315
name: install_prerequisites_host_hypershift
16+
when: hypershift.compute_node_type | lower != 'zvm'
1417

1518
- name: Create macvtap network
1619
hosts: kvm_host_hypershift
@@ -20,9 +23,12 @@
2023
set_fact:
2124
networking:
2225
device1: "{{ hypershift.networking_device }}"
26+
when: hypershift.compute_node_type | lower != 'zvm'
27+
2328
- name: Creating macvtap network
2429
import_role:
2530
name: macvtap
31+
when: hypershift.compute_node_type | lower != 'zvm'
2632

2733
- name: Create bastion for hypershift
2834
hosts: kvm_host_hypershift
@@ -33,7 +39,9 @@
3339
- name: Creating Bastion
3440
include_role:
3541
name: create_bastion_hypershift
36-
when: hypershift.create_bastion == true
42+
when:
43+
- hypershift.create_bastion == true
44+
- hypershift.compute_node_type | lower != 'zvm'
3745

3846
- name: Configuring Bastion
3947
hosts: bastion_hypershift
@@ -67,7 +75,7 @@
6775
- create_hcp_InfraEnv_hypershift
6876

6977
- name: Download Required images for booting Agents
70-
hosts: kvm_host_hypershift
78+
hosts: "{{ 'kvm_host_hypershift' if 'kvm_host_hypershift' in groups['all'] else 'bastion_hypershift' }}"
7179
become: true
7280
roles:
7381
- setup_for_agents_hypershift

roles/add_hc_workers_to_haproxy_hypershift/tasks/main.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
mode tcp
1313
bind {{ hypershift.bastion_hypershift }}:443
1414
bind {{ hypershift.bastion_hypershift }}:80
15+
marker: "# console"
1516

1617
- name: Add Hosted Cluster Worker IPs to Haproxy
1718
lineinfile:
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
- name: Creating agents
3+
block:
4+
- name: Getting script for booting
5+
template:
6+
src: ../templates/boot_nodes.py
7+
dest: /root/ansible_workdir/boot_nodes.py
8+
9+
- name: Debug
10+
debug:
11+
msg: "Booting agent-{{ item }}"
12+
13+
- name: Booting zvm node
14+
shell: |
15+
python /root/ansible_workdir/boot_nodes.py \
16+
--zvmname "{{ hypershift.agents_parms.zvm_parameters.nodes[item].name }}" \
17+
--zvmhost "{{ hypershift.agents_parms.zvm_parameters.nodes[item].host }}" \
18+
--zvmuser "{{ hypershift.agents_parms.zvm_parameters.nodes[item].user }}" \
19+
--zvmpass "{{ hypershift.agents_parms.zvm_parameters.nodes[item].password }}" \
20+
--cpu "{{ hypershift.agents_parms.zvm_parameters.vcpus }}" \
21+
--memory "{{ hypershift.agents_parms.zvm_parameters.memory }}" \
22+
--kernel 'file:///var/lib/libvirt/images/pxeboot/kernel.img' \
23+
--initrd 'file:///var/lib/libvirt/images/pxeboot/initrd.img' \
24+
--cmdline "$(cat /root/ansible_workdir/agent-{{ item }}.parm)"
25+
26+
- name: Attaching dasd disk
27+
shell: vmcp attach {{ hypershift.agents_parms.zvm_parameters.nodes[item].dasd.disk_id }} to {{ hypershift.agents_parms.zvm_parameters.nodes[item].name }}
28+
when: "{{ hypershift.agents_parms.zvm_parameters.disk_type | lower == 'dasd' }}"
29+
30+
- name: Attaching fcp disks
31+
shell: vmcp attach {{ hypershift.agents_parms.zvm_parameters.nodes[item].lun[0].paths[0].fcp.split('.')[-1] }} to {{ hypershift.agents_parms.zvm_parameters.nodes[item].name }}
32+
when: "{{ hypershift.agents_parms.zvm_parameters.disk_type | lower == 'fcp' }}"
33+
34+
- name: Wait for the agent to come up
35+
shell: oc get agents -n "{{ hypershift.hcp.clusters_namespace }}-{{ hypershift.hcp.hosted_cluster_name }}" --no-headers -o custom-columns=NAME:.metadata.name,APPROVED:.spec.approved | awk '$2 == "false"' | wc -l
36+
register: agent_count
37+
until: agent_count.stdout | int == 1
38+
retries: 40
39+
delay: 10
40+
41+
- name: Get the name of agent
42+
shell: oc get agents -n {{ hypershift.hcp.clusters_namespace }}-{{ hypershift.hcp.hosted_cluster_name }} --no-headers -o custom-columns=NAME:.metadata.name,APPROVED:.spec.approved | awk '$2 == "false"'
43+
register: agent_name
44+
45+
- name: Approve agents
46+
shell: oc -n {{ hypershift.hcp.clusters_namespace }}-{{ hypershift.hcp.hosted_cluster_name }} patch agent {{ agent_name.stdout.split(' ')[0] }} -p '{"spec":{"approved":true,"hostname":"compute-{{item}}.{{ hypershift.hcp.hosted_cluster_name }}.{{ hypershift.hcp.basedomain }}","installerArgs":"[\"--append-karg\",\"rd.neednet=1\", \"--append-karg\", \"ip={{ hypershift.agents_parms.zvm_parameters.nodes[item].osa.ip }}::{{ hypershift.agents_parms.zvm_parameters.gateway }}:{{ hypershift.agents_parms.zvm_parameters.subnetmask }}:compute-{{ item }}.{{ hypershift.hcp.hosted_cluster_name }}.{{ hypershift.hcp.basedomain }}:{{ hypershift.agents_parms.zvm_parameters.nodes[item].osa.ifname }}:none\", \"--append-karg\", \"nameserver={{ hypershift.agents_parms.zvm_parameters.nameserver }}\", \"--append-karg\",\"rd.znet=qeth,{{ hypershift.agents_parms.zvm_parameters.nodes[item].osa.id }},layer2=1\",\"--append-karg\", {% if hypershift.agents_parms.zvm_parameters.disk_type | lower != 'fcp' %}\"rd.dasd=0.0.{{ hypershift.agents_parms.zvm_parameters.nodes[item].dasd.disk_id }}\"{% else %}\"rd.zfcp={{ hypershift.agents_parms.zvm_parameters.nodes[item].lun[0].paths[0].fcp}},{{ hypershift.agents_parms.zvm_parameters.nodes[item].lun[0].paths[0].wwpn }},{{ hypershift.agents_parms.zvm_parameters.nodes[item].lun[0].id }}\"{% endif %}]"}}' --type merge
47+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env python3
2+
from tessia.baselib.hypervisors.zvm.zvm import HypervisorZvm
3+
import argparse
4+
5+
parser = argparse.ArgumentParser(description="Get the environment.")
6+
7+
parser.add_argument("--zvmname", type=str, help="z/VM Hypervisor name", required=True)
8+
parser.add_argument("--zvmhost", type=str, help="z/VM Hostname or IP", required=True)
9+
parser.add_argument("--zvmuser", type=str, help="z/VM user", required=True)
10+
parser.add_argument("--zvmpass", type=str, help="z/VM user password", required=True)
11+
parser.add_argument("--cpu", type=int, help="number of Guest CPUs", required=True)
12+
parser.add_argument("--memory", type=int, help="Guest memory in MB", required=True)
13+
parser.add_argument("--kernel", type=str, help="kernel URI", required=True, default='')
14+
parser.add_argument("--cmdline", type=str, help="kernel cmdline", required=True, default='')
15+
parser.add_argument("--initrd", type=str, help="Initrd URI", required=True, default='')
16+
17+
args = parser.parse_args()
18+
19+
parameters = {
20+
'transfer-buffer-size': 8000
21+
}
22+
23+
guest_parameters = {
24+
"boot_method": "network",
25+
"storage_volumes" : [],
26+
"ifaces" : [],
27+
"netboot": {
28+
"cmdline": args.cmdline,
29+
"kernel_uri": args.kernel,
30+
"initrd_uri": args.initrd,
31+
}
32+
}
33+
34+
zvm = HypervisorZvm(args.zvmname,args.zvmhost, args.zvmuser, args.zvmpass, parameters)
35+
zvm.login()
36+
print("Logged in ")
37+
zvm.start(args.zvmuser, args.cpu, args.memory, guest_parameters)
38+
print("VM Started")
39+
zvm.logoff()
40+
print("Logged out")

roles/create_hcp_InfraEnv_hypershift/tasks/main.yaml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,29 +98,39 @@
9898
- name: Creating list of mac addresses
9999
set_fact:
100100
agent_mac_addr: []
101-
when: hypershift.agents_parms.static_ip_parms.static_ip == true
101+
when:
102+
- hypershift.agents_parms.static_ip_parms.static_ip == true
103+
- hypershift.compute_node_type | lower != 'zvm'
102104

103105
- name: Getting mac addresss for agents
104106
set_fact:
105107
agent_mac_addr: "{{ hypershift.agents_parms.agent_mac_addr }}"
106-
when: ( hypershift.agents_parms.static_ip_parms.static_ip == true ) and ( hypershift.agents_parms.agent_mac_addr != None )
108+
when:
109+
- ( hypershift.agents_parms.static_ip_parms.static_ip == true ) and ( hypershift.agents_parms.agent_mac_addr != None )
110+
- hypershift.compute_node_type | lower != 'zvm'
107111

108112
- name: Generate mac addresses for agents
109113
set_fact:
110114
agent_mac_addr: "{{ agent_mac_addr + ['52:54:00' | community.general.random_mac] }}"
111-
when: ( hypershift.agents_parms.static_ip_parms.static_ip == true ) and ( hypershift.agents_parms.agent_mac_addr == None )
115+
when:
116+
- ( hypershift.agents_parms.static_ip_parms.static_ip == true ) and ( hypershift.agents_parms.agent_mac_addr == None )
117+
- hypershift.compute_node_type | lower != 'zvm'
112118
loop: "{{ range(hypershift.agents_parms.agents_count|int) | list }}"
113119

114120
- name: Create NMState Configs
115121
template:
116122
src: nmStateConfig.yaml.j2
117123
dest: /root/ansible_workdir/nmStateConfig-agent-{{ item }}.yaml
118-
when: hypershift.agents_parms.static_ip_parms.static_ip == true
124+
when:
125+
- hypershift.agents_parms.static_ip_parms.static_ip == true
126+
- hypershift.compute_node_type | lower != 'zvm'
119127
loop: "{{ range(hypershift.agents_parms.agents_count|int) | list }}"
120128

121129
- name: Deploy NMState Configs
122130
command: oc apply -f /root/ansible_workdir/nmStateConfig-agent-{{ item }}.yaml
123-
when: hypershift.agents_parms.static_ip_parms.static_ip == true
131+
when:
132+
- hypershift.agents_parms.static_ip_parms.static_ip == true
133+
- hypershift.compute_node_type | lower != 'zvm'
124134
loop: "{{ range(hypershift.agents_parms.agents_count|int) | list }}"
125135

126136
- name: Wait for ISO to generate in InfraEnv
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
{% if hypershift.compute_node_type | lower != 'zvm' %}
12
[kvm_host_hypershift]
23
kvm_host_hypershift ansible_host={{ hypershift.kvm_host }} ansible_user={{ hypershift.kvm_host_user }} ansible_become_password={{ kvm_host_password }}
34

4-
5-
5+
{% endif %}
66
[bastion_hypershift]
77
bastion_hypershift ansible_host={{ hypershift.bastion_hypershift }} ansible_user={{ hypershift.bastion_hypershift_user }}

0 commit comments

Comments
 (0)