Skip to content

Commit cb80b98

Browse files
committed
WIP
Signed-off-by: Lennart Jern <[email protected]>
1 parent 714e01f commit cb80b98

File tree

9 files changed

+272
-410
lines changed

9 files changed

+272
-410
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: baremetal-operator-system
4+
# This is the kustomization that we build on. You can download it and change
5+
# the URL to a relative path if you do not want to access it over the network.
6+
# Note that the ref=main specifies the version to use.
7+
# We use main here simply because the integration with IrSO is not included in a release yet.
8+
resources:
9+
- https://github.com/metal3-io/baremetal-operator/config/use-irso?ref=main
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
mkdir disk-images
4+
5+
pushd disk-images
6+
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
7+
wget https://cloud-images.ubuntu.com/jammy/current/SHA256SUMS
8+
sha256sum --ignore-missing -c SHA256SUMS
9+
wget https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericCloud-9-latest.x86_64.qcow2
10+
wget https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericCloud-9-latest.x86_64.qcow2.SHA256SUM
11+
sha256sum -c CentOS-Stream-GenericCloud-9-latest.x86_64.qcow2.SHA256SUM
12+
wget https://artifactory.nordix.org/artifactory/metal3/images/k8s_v1.33.0/CENTOS_9_NODE_IMAGE_K8S_v1.33.0.qcow2
13+
sha256sum CENTOS_9_NODE_IMAGE_K8S_v1.33.0.qcow2
14+
popd
15+
16+
docker run --name image-server --rm -d -p 80:8080 \
17+
-v "$(pwd)/disk-images:/usr/share/nginx/html" nginxinc/nginx-unprivileged
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: ironic.metal3.io/v1alpha1
2+
kind: Ironic
3+
metadata:
4+
name: ironic
5+
namespace: baremetal-operator-system
6+
spec:
7+
networking:
8+
dhcp:
9+
rangeBegin: "192.168.222.100"
10+
rangeEnd: "192.168.222.200"
11+
networkCIDR: "192.168.222.0/24"
12+
interface: "eth0"
13+
ipAddress: "192.168.222.2"
14+
ipAddressManager: "keepalived"

docs/user-guide/examples/kind.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: kind.x-k8s.io/v1alpha4
2+
kind: Cluster
3+
nodes:
4+
- role: control-plane
5+
# Open ports for Ironic
6+
extraPortMappings:
7+
# Ironic httpd
8+
- containerPort: 6180
9+
hostPort: 6180
10+
listenAddress: "0.0.0.0"
11+
protocol: TCP
12+
# Ironic API
13+
- containerPort: 6385
14+
hostPort: 6385
15+
listenAddress: "0.0.0.0"
16+
protocol: TCP

docs/user-guide/examples/net.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<network>
2+
<name>baremetal-e2e</name>
3+
<forward mode='nat'>
4+
<nat>
5+
<port start='1024' end='65535'/>
6+
</nat>
7+
</forward>
8+
<bridge name='metal3'/>
9+
<ip address='192.168.222.1' netmask='255.255.255.0'>
10+
<dhcp>
11+
<range start='192.168.222.3' end='192.168.222.99'/>
12+
<bootp file='http://192.168.222.2:6180/boot.ipxe'/>
13+
</dhcp>
14+
</ip>
15+
</network>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/usr/bin/env bash
2+
3+
kind create cluster --config kind.yaml
4+
5+
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/latest/download/cert-manager.yaml
6+
7+
# Ensure that cert-manager is up and running
8+
echo "Waiting for cert-manager to be ready..."
9+
10+
# Wait for cert-manager pods to be ready
11+
kubectl -n cert-manager wait --for=condition=Available deployment/cert-manager-webhook --timeout=300s
12+
13+
# Create a test namespace for cert-manager readiness check
14+
kubectl create namespace cert-manager-test
15+
16+
# Function to check cert-manager readiness with retries
17+
check_cert_manager_ready() {
18+
local max_attempts=30
19+
local attempt=1
20+
local sleep_time=10
21+
22+
while [ $attempt -le $max_attempts ]; do
23+
echo "Attempt $attempt/$max_attempts: Creating test Issuer and Certificate..."
24+
25+
# Create a self-signed Issuer
26+
if kubectl apply -f - <<EOF
27+
apiVersion: cert-manager.io/v1
28+
kind: Issuer
29+
metadata:
30+
name: test-selfsigned
31+
namespace: cert-manager-test
32+
spec:
33+
selfSigned: {}
34+
EOF
35+
then
36+
echo "Issuer created successfully"
37+
38+
# Create a Certificate using the Issuer
39+
if kubectl apply -f - <<EOF
40+
apiVersion: cert-manager.io/v1
41+
kind: Certificate
42+
metadata:
43+
name: test-certificate
44+
namespace: cert-manager-test
45+
spec:
46+
secretName: test-certificate-secret
47+
isCA: false
48+
dnsNames:
49+
- test.example.com
50+
issuerRef:
51+
name: test-selfsigned
52+
kind: Issuer
53+
EOF
54+
then
55+
echo "Certificate created successfully"
56+
57+
# Wait for the Certificate to become ready
58+
if kubectl wait --for=condition=ready certificate/test-certificate -n cert-manager-test --timeout=60s 2>/dev/null; then
59+
echo "cert-manager is ready!"
60+
return 0
61+
else
62+
echo "Certificate not ready yet, will retry..."
63+
fi
64+
else
65+
echo "Failed to create Certificate, webhook may not be ready yet..."
66+
fi
67+
else
68+
echo "Failed to create Issuer, webhook may not be ready yet..."
69+
fi
70+
71+
# Clean up before retry
72+
kubectl delete certificate test-certificate -n cert-manager-test --ignore-not-found=true 2>/dev/null
73+
kubectl delete issuer test-selfsigned -n cert-manager-test --ignore-not-found=true 2>/dev/null
74+
75+
attempt=$((attempt + 1))
76+
if [ $attempt -le $max_attempts ]; then
77+
echo "Waiting ${sleep_time}s before retry..."
78+
sleep $sleep_time
79+
fi
80+
done
81+
82+
echo "ERROR: cert-manager did not become ready after $max_attempts attempts"
83+
return 1
84+
}
85+
86+
# Run the readiness check
87+
if check_cert_manager_ready; then
88+
# Clean up test resources
89+
kubectl delete namespace cert-manager-test
90+
else
91+
# Clean up and exit with error
92+
kubectl delete namespace cert-manager-test
93+
exit 1
94+
fi
95+
96+
97+
kubectl apply -f https://github.com/metal3-io/ironic-standalone-operator/releases/latest/download/install.yaml
98+
99+
kubectl create ns baremetal-operator-system
100+
101+
kubectl apply -f ironic.yaml
102+
kubectl apply -k bmo
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
# Define and start the baremetal-e2e network
4+
virsh -c qemu:///system net-define net.xml
5+
virsh -c qemu:///system net-start baremetal-e2e
6+
7+
# Start the sushy-emulator container that acts as BMC
8+
docker run --name sushy-tools --rm --network host -d \
9+
-v /var/run/libvirt:/var/run/libvirt \
10+
-v "$(pwd)/sushy-tools.conf:/etc/sushy/sushy-emulator.conf" \
11+
-e SUSHY_EMULATOR_CONFIG=/etc/sushy/sushy-emulator.conf \
12+
quay.io/metal3-io/sushy-tools:latest sushy-emulator
13+
14+
# Generate a VM definition xml file and then define the VM
15+
# use --ram=8192 for Scenario 2
16+
virt-install \
17+
--connect qemu:///system \
18+
--name bmh-vm-01 \
19+
--description "Virtualized BareMetalHost" \
20+
--osinfo=ubuntu-lts-latest \
21+
--ram=4096 \
22+
--vcpus=2 \
23+
--disk size=25 \
24+
--boot hd,network \
25+
--import \
26+
--network network=baremetal-e2e,mac="00:60:2f:31:81:01" \
27+
--noautoconsole \
28+
--print-xml > bmh-vm-01.xml
29+
virsh define bmh-vm-01.xml
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Listen on the local IP address 192.168.222.1
2+
SUSHY_EMULATOR_LISTEN_IP = u'192.168.222.1'
3+
4+
# Bind to TCP port 8000
5+
SUSHY_EMULATOR_LISTEN_PORT = 8000
6+
7+
# Serve this SSL certificate to the clients
8+
SUSHY_EMULATOR_SSL_CERT = None
9+
10+
# If SSL certificate is being served, this is its RSA private key
11+
SUSHY_EMULATOR_SSL_KEY = None
12+
13+
# The OpenStack cloud ID to use. This option enables OpenStack driver.
14+
SUSHY_EMULATOR_OS_CLOUD = None
15+
# The libvirt URI to use. This option enables libvirt driver.
16+
SUSHY_EMULATOR_LIBVIRT_URI = u'qemu:///system'
17+
18+
# Instruct the libvirt driver to ignore any instructions to
19+
# set the boot device. Allowing the UEFI firmware to instead
20+
# rely on the EFI Boot Manager
21+
# Note: This sets the legacy boot element to dev="fd"
22+
# and relies on the floppy not existing, it likely wont work
23+
# your VM has a floppy drive.
24+
SUSHY_EMULATOR_IGNORE_BOOT_DEVICE = False
25+
26+
# The map of firmware loaders dependant on the boot mode and
27+
# system architecture. Ideally the x86_64 loader will be capable
28+
# of secure boot or not based on the chosen nvram.
29+
SUSHY_EMULATOR_BOOT_LOADER_MAP = {
30+
u'UEFI': {
31+
u'x86_64': u'/usr/share/OVMF/OVMF_CODE.secboot.fd'
32+
},
33+
u'Legacy': {
34+
u'x86_64': None
35+
}
36+
}

0 commit comments

Comments
 (0)