Skip to content

Commit 4dd20fd

Browse files
Merge pull request openshift#8477 from gryf/OCPBUGS-33973
OCPBUGS-33973: Openstack UPI - Reintroduce unique resource names.
2 parents 03dfc1e + aae81ab commit 4dd20fd

File tree

9 files changed

+75
-31
lines changed

9 files changed

+75
-31
lines changed

docs/user/openstack/install_upi.md

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ of this method of installation.
2727
- [OpenShift Configuration Directory](#openshift-configuration-directory)
2828
- [Red Hat Enterprise Linux CoreOS (RHCOS)](#red-hat-enterprise-linux-coreos-rhcos)
2929
- [API and Ingress Floating IP Addresses](#api-and-ingress-floating-ip-addresses)
30+
- [Network identifier](#network-identifier)
3031
- [Create network, API and ingress ports](#create-network-api-and-ingress-ports)
3132
- [Install Config](#install-config)
3233
- [Configure the machineNetwork.CIDR apiVIP and ingressVIP](#configure-the-machinenetworkcidr-apivip-and-ingressvip)
@@ -270,6 +271,23 @@ api.openshift.example.com. A 203.0.113.23
270271

271272
They will need to be available to your developers, end users as well as the OpenShift installer process later in this guide.
272273

274+
## Network identifier
275+
276+
Resources like network, subnet (or subnets), router and API and ingress ports need to have unique name to not interfere with other deployments running on the same OpenStack cloud.
277+
Please, keep in mind, those OpenStack resources will have different name scheme then all the other resources which will be created on next steps, although they will be tagged by the infraID later on.
278+
Let's create environment variable `OS_NET_ID` and `netid.json` file, which will be used by ansible playbooks later on.
279+
280+
<!--- e2e-openstack-upi: INCLUDE START --->
281+
```sh
282+
$ export OS_NET_ID="openshift-$(dd if=/dev/urandom count=4 bs=1 2>/dev/null |hexdump -e '"%02x"')"
283+
$ echo "{\"os_net_id\": \"$OS_NET_ID\"}" | tee netid.json
284+
```
285+
<!--- e2e-openstack-upi: INCLUDE END --->
286+
287+
Make sure your shell session has the `$OS_NET_ID` environment variable set when you run the commands later in this document.
288+
289+
Note, this identifier has nothing in common with OpenShift `infraID` defined later on.
290+
273291
## Create network, API and ingress ports
274292

275293
Please note that value of the API and Ingress VIPs fields will be overwritten in the `inventory.yaml` with the respective addresses assigned to the Ports. Run the following playbook to create necessary resources:
@@ -336,22 +354,39 @@ values:
336354

337355
<!--- e2e-openstack-upi: INCLUDE START --->
338356
```sh
339-
$ python -c 'import yaml
357+
$ python -c 'import os
358+
import sys
359+
import yaml
360+
import re
361+
re_os_net_id = re.compile(r"{{\s*os_net_id\s*}}")
362+
os_net_id = os.getenv("OS_NET_ID")
363+
path = "common.yaml"
364+
facts = None
365+
for _dict in yaml.safe_load(open(path))[0]["tasks"]:
366+
if "os_network" in _dict.get("set_fact", {}):
367+
facts = _dict["set_fact"]
368+
break
369+
if not facts:
370+
print("Cannot find `os_network` in common.yaml file. Make sure OpenStack resource names are defined in one of the tasks.")
371+
sys.exit(1)
372+
os_network = re_os_net_id.sub(os_net_id, facts["os_network"])
373+
os_subnet = re_os_net_id.sub(os_net_id, facts["os_subnet"])
340374
path = "install-config.yaml"
341375
data = yaml.safe_load(open(path))
342376
inventory = yaml.safe_load(open("inventory.yaml"))["all"]["hosts"]["localhost"]
343377
machine_net = [{"cidr": inventory["os_subnet_range"]}]
344378
api_vips = [inventory["os_apiVIP"]]
345379
ingress_vips = [inventory["os_ingressVIP"]]
346-
ctrl_plane_port = {"network": {"name": inventory["os_network"]}, "fixedIPs": [{"subnet": {"name": inventory["os_subnet"]}}]}
347-
if inventory.get("os_subnet6"):
380+
ctrl_plane_port = {"network": {"name": os_network}, "fixedIPs": [{"subnet": {"name": os_subnet}}]}
381+
if inventory.get("os_subnet6_range"):
382+
os_subnet6 = re_os_net_id.sub(os_net_id, facts["os_subnet6"])
348383
machine_net.append({"cidr": inventory["os_subnet6_range"]})
349384
api_vips.append(inventory["os_apiVIP6"])
350385
ingress_vips.append(inventory["os_ingressVIP6"])
351386
data["networking"]["networkType"] = "OVNKubernetes"
352387
data["networking"]["clusterNetwork"].append({"cidr": inventory["cluster_network6_cidr"], "hostPrefix": inventory["cluster_network6_prefix"]})
353388
data["networking"]["serviceNetwork"].append(inventory["service_subnet6_range"])
354-
ctrl_plane_port["fixedIPs"].append({"subnet": {"name": inventory["os_subnet6"]}})
389+
ctrl_plane_port["fixedIPs"].append({"subnet": {"name": os_subnet6}})
355390
data["networking"]["machineNetwork"] = machine_net
356391
data["platform"]["openstack"]["apiVIPs"] = api_vips
357392
data["platform"]["openstack"]["ingressVIPs"] = ingress_vips

upi/openstack/bootstrap.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
- "{{ os_sg_master }}"
2020
allowed_address_pairs:
2121
- ip_address: "{{ os_apiVIP }}"
22-
when: os_subnet6 is not defined
22+
when: os_subnet6_range is not defined
2323

2424
- name: 'Create the bootstrap dualstack server port'
2525
os_port:
@@ -30,7 +30,7 @@
3030
allowed_address_pairs:
3131
- ip_address: "{{ os_apiVIP }}"
3232
- ip_address: "{{ os_apiVIP6 }}"
33-
when: os_subnet6 is defined
33+
when: os_subnet6_range is defined
3434

3535
- name: 'Set bootstrap port tag'
3636
command:

upi/openstack/common.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33

44
vars_files:
55
- metadata.json
6+
- netid.json
67

78
tasks:
9+
- name: "Check if metadata.json exists"
10+
ansible.builtin.stat:
11+
path: metadata.json
12+
register: sym
13+
814
- name: 'Compute resource names'
915
set_fact:
1016
cluster_id_tag: "openshiftClusterID={{ infraID }}"
@@ -24,3 +30,14 @@
2430
os_compute_server_group_name: "{{ infraID }}-worker"
2531
# Ignition files
2632
os_bootstrap_ignition: "{{ infraID }}-bootstrap-ignition.json"
33+
when: sym.stat.exists
34+
35+
- name: 'Compute network resource names'
36+
set_fact:
37+
os_network: "{{ os_net_id }}-network"
38+
os_subnet: "{{ os_net_id }}-nodes"
39+
os_subnet6: "{{ os_net_id }}-nodes-v6"
40+
os_router: "{{ os_net_id }}-external-router"
41+
# Port names
42+
os_port_api: "{{ os_net_id }}-api-port"
43+
os_port_ingress: "{{ os_net_id }}-ingress-port"

upi/openstack/compute-nodes.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
- ip_address: "{{ os_ingressVIP }}"
2222
with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"
2323
register: ports
24-
when: os_subnet6 is not defined
24+
when: os_subnet6_range is not defined
2525

2626
- name: 'Create the dualstack Compute ports'
2727
openstack.cloud.port:
@@ -34,7 +34,7 @@
3434
- ip_address: "{{ os_ingressVIP6 }}"
3535
with_indexed_items: "{{ [os_port_worker] * os_compute_nodes_number }}"
3636
register: ports
37-
when: os_subnet6 is defined
37+
when: os_subnet6_range is defined
3838

3939
- name: 'Set Compute ports tag'
4040
ansible.builtin.command:

upi/openstack/control-plane.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
- ip_address: "{{ os_ingressVIP }}"
2323
with_indexed_items: "{{ [os_port_master] * os_cp_nodes_number }}"
2424
register: ports
25-
when: os_subnet6 is not defined
25+
when: os_subnet6_range is not defined
2626

2727
- name: 'Create the dualstack Control Plane ports'
2828
openstack.cloud.port:
@@ -37,7 +37,7 @@
3737
- ip_address: "{{ os_ingressVIP6 }}"
3838
with_indexed_items: "{{ [os_port_master] * os_cp_nodes_number }}"
3939
register: ports
40-
when: os_subnet6 is defined
40+
when: os_subnet6_range is defined
4141

4242
- name: 'Set Control Plane ports tag'
4343
ansible.builtin.command:

upi/openstack/inventory.yaml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ all:
44
ansible_connection: local
55
ansible_python_interpreter: "{{ansible_playbook_python}}"
66

7-
# Network resource names
8-
os_network: ocp-network
9-
os_port_api: ocp-api-port
10-
os_port_ingress: ocp-ingress-port
11-
os_router: ocp-external-router
12-
os_subnet: ocp-subnet-v4
13-
147
# User-provided values
158
os_subnet_range: '10.0.0.0/16'
169
os_flavor_master: 'm1.xlarge'
@@ -73,11 +66,8 @@ all:
7366
# nodes is zero
7467
os_master_schedulable: "{{ os_compute_nodes_number | int == 0 }}"
7568

76-
# Name of the IPv6 subnet. Uncomment to enable dual-stack support
77-
#os_subnet6: ocp-subnet-v6
78-
79-
# IPv6 subnet CIDR
80-
os_subnet6_range: 'fd2e:6f44:5dd8:c956::/64'
69+
# IPv6 subnet CIDR. Uncomment to enable dual-stack support.
70+
#os_subnet6_range: 'fd2e:6f44:5dd8:c956::/64'
8171

8272
# Modes are one of: slaac, dhcpv6-stateful or dhcpv6-stateless
8373
os_subnet6_address_mode: slaac

upi/openstack/network.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# openstacksdk
66
# netaddr
77

8+
- ansible.builtin.import_playbook: common.yaml
9+
810
- hosts: all
911
gather_facts: no
1012

@@ -30,7 +32,7 @@
3032
ip_version: 6
3133
ipv6_address_mode: "{{ os_subnet6_address_mode }}"
3234
ipv6_ra_mode: "{{ os_subnet6_router_advertisements_mode }}"
33-
when: os_subnet6 is defined
35+
when: os_subnet6_range is defined
3436

3537
- name: 'Create external router for IPv4'
3638
openstack.cloud.router:
@@ -40,7 +42,7 @@
4042
when:
4143
- os_external_network is defined
4244
- os_external_network|length>0
43-
- os_subnet6 is not defined
45+
- os_subnet6_range is not defined
4446

4547
- name: 'Create external router for dualstack'
4648
openstack.cloud.router:
@@ -52,7 +54,7 @@
5254
when:
5355
- os_external_network is defined
5456
- os_external_network|length>0
55-
- os_subnet6 is defined
57+
- os_subnet6_range is defined
5658

5759
- name: 'Create the API port'
5860
openstack.cloud.port:
@@ -62,7 +64,7 @@
6264
- subnet: "{{ os_subnet }}"
6365
ip_address: "{{ os_apiVIP }}"
6466
register: _api_ports
65-
when: os_subnet6 is not defined
67+
when: os_subnet6_range is not defined
6668

6769
- set_fact:
6870
api_ports: "{{ _api_ports }}"
@@ -73,7 +75,7 @@
7375
name: "{{ os_port_api }}"
7476
network: "{{ os_network }}"
7577
register: _api_ports
76-
when: os_subnet6 is defined
78+
when: os_subnet6_range is defined
7779

7880
- set_fact:
7981
api_ports: "{{ _api_ports }}"
@@ -87,7 +89,7 @@
8789
- subnet: "{{ os_subnet }}"
8890
ip_address: "{{ os_ingressVIP }}"
8991
register: _ingress_ports
90-
when: os_subnet6 is not defined
92+
when: os_subnet6_range is not defined
9193

9294
- set_fact:
9395
ingress_ports: "{{ _ingress_ports }}"
@@ -98,7 +100,7 @@
98100
name: "{{ os_port_ingress }}"
99101
network: "{{ os_network }}"
100102
register: _ingress_ports
101-
when: os_subnet6 is defined
103+
when: os_subnet6_range is defined
102104

103105
- set_fact:
104106
ingress_ports: "{{ _ingress_ports }}"

upi/openstack/security-groups.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,4 +408,4 @@
408408
port_range_min: 30000
409409
port_range_max: 32767
410410

411-
when: os_subnet6 is defined
411+
when: os_subnet6_range is defined

upi/openstack/update-network-resources.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
- name: 'Set tags on primary cluster subnet IPv6'
2323
ansible.builtin.command:
2424
cmd: "openstack subnet set --tag {{ cluster_id_tag }} {{ os_subnet6 }}"
25-
when: os_subnet6 is defined
25+
when: os_subnet6_range is defined
2626

2727
- name: 'Set tags on the API VIP port'
2828
ansible.builtin.command:

0 commit comments

Comments
 (0)