Skip to content

Commit afb3f8d

Browse files
Use irso after pivot
Signed-off-by: Muhammad Adil Ghaffar <[email protected]>
1 parent 01530d0 commit afb3f8d

File tree

4 files changed

+221
-21
lines changed

4 files changed

+221
-21
lines changed

lib/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export CAPM3_BASE_URL="${CAPM3_BASE_URL:-metal3-io/cluster-api-provider-metal3}"
158158
export CAPM3REPO="${CAPM3REPO:-https://github.com/${CAPM3_BASE_URL}}"
159159
export CAPM3RELEASEBRANCH="${CAPM3RELEASEBRANCH:-main}"
160160

161-
export USE_IRSO="${USE_IRSO:-false}"
161+
export USE_IRSO="true"
162162
export IRSOPATH="${IRSOPATH:-${M3PATH}/ironic-standalone-operator}"
163163
export IRSO_BASE_URL="${IRSO_BASE_URL:-metal3-io/ironic-standalone-operator}"
164164
export IRSOREPO="${IRSOREPO:-https://github.com/${IRSO_BASE_URL}}"

tests/roles/run_tests/tasks/move.yml

Lines changed: 119 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
with_items: "{{ ironic_containers }}"
3838

3939
when: BOOTSTRAP_CLUSTER == "kind"
40-
become: yes
40+
become: true
4141
become_user: root
4242

4343
- name: Fetch container logs (minikube cluster)
@@ -53,18 +53,24 @@
5353
shell: "sudo {{ CONTAINER_RUNTIME }} logs {{ item }} > /tmp/{{ CONTAINER_RUNTIME }}/{{ item }}/stdout.log 2> /tmp/{{ CONTAINER_RUNTIME }}/{{ item }}/stderr.log"
5454
with_items: "{{ general_containers }}"
5555

56-
become: yes
56+
become: true
5757
become_user: root
5858
when: BOOTSTRAP_CLUSTER == "minikube"
5959

60-
- name: Remove Ironic from source cluster (minikube cluster)
60+
- name: Remove Ironic CR from source cluster (minikube cluster)
6161
kubernetes.core.k8s:
62-
name: "{{ NAMEPREFIX }}-ironic"
63-
kind: Deployment
62+
name: ironic
63+
kind: Ironic
64+
api_version: ironic.metal3.io/v1alpha1
6465
state: absent
6566
namespace: "{{ IRONIC_NAMESPACE }}"
6667
when: BOOTSTRAP_CLUSTER == "minikube"
6768

69+
- name: Remove IRSO from source cluster (minikube cluster)
70+
shell: "make -C {{ IRSOPATH }} uninstall undeploy"
71+
ignore_errors: true
72+
when: BOOTSTRAP_CLUSTER == "minikube"
73+
6874
- name: Label baremetalhost CRD to pivot.
6975
shell: "kubectl label --overwrite crds baremetalhosts.metal3.io {{ item }}"
7076
with_items:
@@ -127,7 +133,7 @@
127133
(target_running_pods.resources | length == 0)
128134

129135
# Install BMO
130-
- name: Install Baremetal Operator
136+
- name: Install Baremetal Operator in target cluster
131137
shell: "{{ BMOPATH }}/tools/deploy.sh -b {{ BMO_IRONIC_ARGS }}"
132138
environment:
133139
IRONIC_HOST: "{{ IRONIC_HOST }}"
@@ -136,15 +142,114 @@
136142
args:
137143
chdir: "{{ BMOPATH }}"
138144

139-
# Install Ironic
140-
- name: Install Ironic
141-
shell: "{{ BMOPATH }}/tools/deploy.sh -i {{ BMO_IRONIC_ARGS }}"
142-
environment:
143-
IRONIC_HOST: "{{ IRONIC_HOST }}"
144-
IRONIC_HOST_IP: "{{ IRONIC_HOST_IP }}"
145-
KUBECTL_ARGS: "{{ KUBECTL_ARGS }}"
145+
# Install IRSO and Ironic via IRSO
146+
- name: Set IPA_BASEURI in IRSO manager config
147+
lineinfile:
148+
path: "{{ IRSOPATH }}/config/manager/manager.env"
149+
line: 'IPA_BASEURI=https://artifactory.nordix.org/artifactory/openstack-remote-cache/ironic-python-agent/dib'
150+
create: yes
151+
152+
- name: Install IRSO in target cluster
153+
shell: "make install deploy IMG={{ IRSO_IMAGE }}"
146154
args:
147-
chdir: "{{ BMOPATH }}"
155+
chdir: "{{ IRSOPATH }}"
156+
environment:
157+
KUBECONFIG: "/tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml"
158+
159+
- name: Wait for IRSO controller manager to be available
160+
kubernetes.core.k8s_info:
161+
kind: Deployment
162+
name: ironic-standalone-operator-controller-manager
163+
namespace: ironic-standalone-operator-system
164+
kubeconfig: "/tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml"
165+
wait: true
166+
wait_condition:
167+
type: Available
168+
status: "True"
169+
wait_timeout: 60
170+
171+
- name: Create ironic CA cert secret in target cluster
172+
kubernetes.core.k8s:
173+
state: present
174+
kubeconfig: "/tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml"
175+
definition:
176+
apiVersion: v1
177+
kind: Secret
178+
metadata:
179+
name: ironic-cacert
180+
namespace: "{{ IRONIC_NAMESPACE }}"
181+
type: kubernetes.io/tls
182+
data:
183+
tls.crt: "{{ lookup('file', IRONIC_CACERT_FILE) | b64encode }}"
184+
tls.key: "{{ lookup('file', IRONIC_CAKEY_FILE) | b64encode }}"
185+
186+
- name: Create ironic-credentials secret in target cluster
187+
kubernetes.core.k8s:
188+
state: present
189+
kubeconfig: "/tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml"
190+
definition:
191+
apiVersion: v1
192+
kind: Secret
193+
metadata:
194+
name: ironic-credentials
195+
namespace: "{{ IRONIC_NAMESPACE }}"
196+
type: Opaque
197+
stringData:
198+
username: "{{ lookup('env','IRONIC_USERNAME') | trim }}"
199+
password: "{{ lookup('env','IRONIC_PASSWORD') | trim }}"
200+
201+
- name: Create Ironic CR
202+
set_fact:
203+
ironic_spec:
204+
apiVersion: ironic.metal3.io/v1alpha1
205+
kind: Ironic
206+
metadata:
207+
name: ironic
208+
namespace: "{{ IRONIC_NAMESPACE }}"
209+
spec:
210+
images:
211+
deployRamdiskBranch: "{{ IPA_BRANCH }}"
212+
deployRamdiskDownloader: "{{ IPA_DOWNLOADER_IMAGE }}"
213+
ironic: "{{ IRONIC_IMAGE }}"
214+
keepalived: "{{ IRONIC_KEEPALIVED_IMAGE }}"
215+
version: "{{ IRSO_IRONIC_VERSION }}"
216+
networking:
217+
dhcp:
218+
rangeBegin: "{{ CLUSTER_DHCP_RANGE_START }}"
219+
rangeEnd: "{{ CLUSTER_DHCP_RANGE_END }}"
220+
networkCIDR: "{{ BARE_METAL_PROVISIONER_NETWORK }}"
221+
interface: "{{ BARE_METAL_PROVISIONER_INTERFACE }}"
222+
ipAddress: "{{ CLUSTER_BARE_METAL_PROVISIONER_IP }}"
223+
ipAddressManager: keepalived
224+
deployRamdisk:
225+
sshKey: "{{ SSH_PUB_KEY_CONTENT }}"
226+
227+
- name: Add extraKernelParams for libvirt platform
228+
set_fact:
229+
ironic_spec: "{{ ironic_spec | combine({'spec': {'deployRamdisk': {'extraKernelParams': 'console=ttyS0'}}}, recursive=True) }}"
230+
when: NODES_PLATFORM == 'libvirt'
231+
232+
- name: Deploy Ironic CR in target cluster (retry if webhook not ready)
233+
kubernetes.core.k8s:
234+
state: present
235+
kubeconfig: "/tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml"
236+
definition: "{{ ironic_spec }}"
237+
register: ironic_create
238+
retries: 10
239+
delay: 3
240+
until: ironic_create is succeeded
241+
242+
- name: Wait for Ironic to be ready
243+
kubernetes.core.k8s_info:
244+
kind: Ironic
245+
name: ironic
246+
namespace: "{{ IRONIC_NAMESPACE }}"
247+
kubeconfig: "/tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml"
248+
wait: true
249+
wait_condition:
250+
type: Ready
251+
status: "True"
252+
wait_timeout: "{{ (IRONIC_ROLLOUT_WAIT | default(10) | int * 60) }}"
148253

149254
- name: Label baremetalhost CRD in target cluster to pivot back.
150255
shell: "kubectl --kubeconfig /tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml label crds baremetalhosts.metal3.io {{ item }} --overwrite "

tests/roles/run_tests/tasks/move_back.yml

Lines changed: 83 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,91 @@
2424
CONTAINER_RUNTIME: "{{ CONTAINER_RUNTIME }}"
2525
when: BOOTSTRAP_CLUSTER == "kind"
2626

27-
- name: Install Ironic in Source cluster (Bootstrap Cluster is minikube)
28-
shell: "{{ BMOPATH }}/tools/deploy.sh -i {{ BMO_IRONIC_ARGS }}"
29-
environment:
30-
IRONIC_HOST: "{{ IRONIC_HOST }}"
31-
IRONIC_HOST_IP: "{{ IRONIC_HOST_IP }}"
27+
28+
# Install IRSO and Ironic via IRSO
29+
- name: Set IPA_BASEURI in IRSO manager config
30+
lineinfile:
31+
path: "{{ IRSOPATH }}/config/manager/manager.env"
32+
line: 'IPA_BASEURI=https://artifactory.nordix.org/artifactory/openstack-remote-cache/ironic-python-agent/dib'
33+
create: yes
3234
when: BOOTSTRAP_CLUSTER == "minikube"
35+
36+
- name: Install and deploy IRSO
37+
shell: "make install deploy IMG={{ IRSO_IMAGE }}"
3338
args:
34-
chdir: "{{ BMOPATH }}"
39+
chdir: "{{ IRSOPATH }}"
40+
environment:
41+
KUBECONFIG: "/tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml"
42+
when: BOOTSTRAP_CLUSTER == "minikube"
43+
44+
- name: Wait for IRSO controller manager to be available
45+
kubernetes.core.k8s_info:
46+
kind: Deployment
47+
name: ironic-standalone-operator-controller-manager
48+
namespace: ironic-standalone-operator-system
49+
kubeconfig: "/tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml"
50+
wait: true
51+
wait_condition:
52+
type: Available
53+
status: "True"
54+
wait_timeout: 60
55+
when: BOOTSTRAP_CLUSTER == "minikube"
56+
57+
- name: Set Ironic spec
58+
when: BOOTSTRAP_CLUSTER == "minikube"
59+
set_fact:
60+
ironic_spec:
61+
apiVersion: ironic.metal3.io/v1alpha1
62+
kind: Ironic
63+
metadata:
64+
name: ironic
65+
namespace: "{{ IRONIC_NAMESPACE }}"
66+
spec:
67+
images:
68+
deployRamdiskBranch: "{{ IPA_BRANCH }}"
69+
deployRamdiskDownloader: "{{ IPA_DOWNLOADER_IMAGE }}"
70+
ironic: "{{ IRONIC_IMAGE }}"
71+
keepalived: "{{ IRONIC_KEEPALIVED_IMAGE }}"
72+
version: "{{ IRSO_IRONIC_VERSION }}"
73+
networking:
74+
dhcp:
75+
rangeBegin: "{{ CLUSTER_DHCP_RANGE_START }}"
76+
rangeEnd: "{{ CLUSTER_DHCP_RANGE_END }}"
77+
networkCIDR: "{{ BARE_METAL_PROVISIONER_NETWORK }}"
78+
interface: "{{ BARE_METAL_PROVISIONER_INTERFACE }}"
79+
ipAddress: "{{ CLUSTER_BARE_METAL_PROVISIONER_IP }}"
80+
ipAddressManager: keepalived
81+
deployRamdisk:
82+
sshKey: "{{ SSH_PUB_KEY_CONTENT }}"
83+
84+
- name: Add extraKernelParams for libvirt platform
85+
set_fact:
86+
ironic_spec: "{{ ironic_spec | combine({'spec': {'deployRamdisk': {'extraKernelParams': 'console=ttyS0'}}}, recursive=True) }}"
87+
when: NODES_PLATFORM == 'libvirt' and BOOTSTRAP_CLUSTER == "minikube"
88+
89+
- name: Deploy Ironic using IRSO (retry if webhook not ready)
90+
kubernetes.core.k8s:
91+
state: present
92+
kubeconfig: "/tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml"
93+
definition: "{{ ironic_spec }}"
94+
register: ironic_create
95+
retries: 10
96+
delay: 3
97+
until: ironic_create is succeeded
98+
when: BOOTSTRAP_CLUSTER == "minikube"
99+
100+
- name: Wait for Ironic to be ready
101+
when: BOOTSTRAP_CLUSTER == "minikube"
102+
kubernetes.core.k8s_info:
103+
kind: Ironic
104+
name: ironic
105+
namespace: "{{ IRONIC_NAMESPACE }}"
106+
kubeconfig: "/tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml"
107+
wait: true
108+
wait_condition:
109+
type: Ready
110+
status: "True"
111+
wait_timeout: "{{ (IRONIC_ROLLOUT_WAIT | default(10) | int * 60) }}"
35112

36113
- name: Re-pivot everything back to source cluster
37114
shell: "clusterctl move --kubeconfig /tmp/kubeconfig-{{ CLUSTER_NAME }}.yaml --to-kubeconfig /home/$USER/.kube/config -n {{ NAMESPACE }} -v 10"

tests/roles/run_tests/vars/main.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,21 @@ WORKER_MACHINE_COUNT: "{{ lookup('env', 'WORKER_MACHINE_COUNT') | default(1, tru
1616
NUM_NODES: "{{ lookup('env', 'NUM_NODES') | default(2, true) }}"
1717
NODE_DRAIN_TIMEOUT: "{{ lookup('env', 'NODE_DRAIN_TIMEOUT') | default('0s', true) }}"
1818
BMOPATH: "{{ lookup('env', 'BMOPATH') }}"
19+
IRSOPATH: "{{ lookup('env', 'IRSOPATH') }}"
20+
IRONIC_ROLLOUT_WAIT: "{{ lookup('env', 'IRONIC_ROLLOUT_WAIT') | default(10, true) }}"
21+
IPA_DOWNLOADER_IMAGE: "{{ lookup('env', 'IPA_DOWNLOADER_IMAGE') | default('registry.nordix.org/metal3/ironic-python-agent-downloader:latest', true) }}"
22+
IRSO_IMAGE: "{{ lookup('env', 'IRSO_IMAGE') | default('registry.nordix.org/metal3/ironic-standalone-operator:latest', true) }}"
23+
IRONIC_IMAGE: "{{ lookup('env', 'IRONIC_IMAGE') | default('registry.nordix.org/metal3/ironic:latest', true) }}"
24+
IRONIC_KEEPALIVED_IMAGE: "{{ lookup('env', 'IRONIC_KEEPALIVED_IMAGE') | default('registry.nordix.org/metal3/ironic-keepalived:latest', true) }}"
25+
IRSO_IRONIC_VERSION: "{{ lookup('env', 'IRSO_IRONIC_VERSION') | default('latest', true) }}"
26+
CLUSTER_DHCP_RANGE_START: "{{ lookup('env', 'CLUSTER_DHCP_RANGE_START') | default('172.22.0.10', true) }}"
27+
CLUSTER_DHCP_RANGE_END: "{{ lookup('env', 'CLUSTER_DHCP_RANGE_END') | default('172.22.0.100', true) }}"
28+
BARE_METAL_PROVISIONER_NETWORK: "{{ lookup('env', 'BARE_METAL_PROVISIONER_NETWORK') | default('172.22.0.0/24', true) }}"
29+
BARE_METAL_PROVISIONER_INTERFACE: "{{ lookup('env', 'BARE_METAL_PROVISIONER_INTERFACE') | default('ironicendpoint', true) }}"
30+
CLUSTER_BARE_METAL_PROVISIONER_IP: "{{ lookup('env', 'CLUSTER_BARE_METAL_PROVISIONER_IP') | default('172.22.0.2', true) }}"
31+
IPA_BRANCH: "{{ lookup('env', 'IPA_BRANCH') | default('main', true) }}"
1932
IRONIC_DATA_DIR: "{{ lookup('env', 'IRONIC_DATA_DIR') }}"
33+
NODES_PLATFORM: "{{ lookup('env', 'NODES_PLATFORM') | default('libvirt', true) }}"
2034
KUBECONFIG_PATH: "/home/ubuntu/.kube/config"
2135
KUBERNETES_VERSION: "{{ lookup('env', 'KUBERNETES_VERSION') | default('v1.34.1', true) }}"
2236
UPGRADED_K8S_VERSION: "{{ lookup('env', 'UPGRADED_K8S_VERSION') | default('v1.34.1', true) }}"
@@ -72,6 +86,10 @@ CAPI_VERSION: "{{ lookup('env', 'CAPI_VERSION') | default('v1beta2', true) }}"
7286
CAPM3_VERSION: "{{ lookup('env', 'CAPM3_VERSION') | default('v1beta1', true) }}"
7387
IRONIC_IMAGE_DIR: "{{ lookup('env', 'IRONIC_IMAGE_DIR') | default('/opt/metal3-dev-env/ironic/html/images') }}"
7488
IRONIC_ENDPOINT_BRIDGE: "{{ lookup('env', 'BARE_METAL_PROVISIONER_INTERFACE') | default('provisioning', true) }}"
89+
IRONIC_CACERT_FILE: "{{ lookup('env', 'IRONIC_CACERT_FILE') | default(IRONIC_IMAGE_DIR + '/opt/metal3-dev-env/certs/ironic-ca.pem', true) }}"
90+
IRONIC_CAKEY_FILE: "{{ lookup('env', 'IRONIC_CAKEY_FILE') | default(IRONIC_IMAGE_DIR + '/opt/metal3-dev-env/certs/ironic-ca.key', true) }}"
91+
IRONIC_USERNAME: "{{ lookup('env', 'IRONIC_USERNAME') | default('admin', true) }}"
92+
IRONIC_PASSWORD: "{{ lookup('env', 'IRONIC_PASSWORD') | default('password', true) }}"
7593
UPGRADED_IMAGE_NAME: "{{ lookup('env', 'UPGRADED_IMAGE_NAME') }}"
7694
UPGRADED_RAW_IMAGE_NAME: "{{ lookup('env', 'UPGRADED_RAW_IMAGE_NAME') }}"
7795

0 commit comments

Comments
 (0)