4 SCRIPTDIR="$(readlink -f $(dirname ${BASH_SOURCE[0]}))"
5 LIBDIR="$(dirname $(dirname ${SCRIPTDIR}))/env/lib"
7 source $LIBDIR/logging.sh
8 source $LIBDIR/common.sh
14 kubectl get all -n ${NAMEPREFIX}-system
17 function check_interface_ip {
21 ip addr show dev ${interface}
22 if [[ $? -ne 0 ]]; then
26 local -r ipv4address=$(ip addr show dev ${interface} | awk '$1 == "inet" { sub("/.*", "", $2); print $2 }')
27 if [[ "$ipv4address" != "$ipaddr" ]]; then
32 function configure_ironic_bridge {
33 if [[ ! $(ip link show dev provisioning) ]]; then
34 ip link add dev provisioning type bridge
36 ip link set provisioning up
37 ip link set dev ${IRONIC_INTERFACE} master provisioning
38 if [[ ! $(ip addr show dev provisioning to 172.22.0.1) ]]; then
39 ip addr add dev provisioning 172.22.0.1/24
43 function configure_ironic_interfaces {
44 # Add firewall rules to ensure the IPA ramdisk can reach httpd,
45 # Ironic and the Inspector API on the host
46 if [ "${IRONIC_PROVISIONING_INTERFACE}" ]; then
47 check_interface_ip ${IRONIC_PROVISIONING_INTERFACE} ${IRONIC_PROVISIONING_INTERFACE_IP}
52 for port in 80 5050 6385 ; do
53 if ! sudo iptables -C INPUT -i ${IRONIC_PROVISIONING_INTERFACE} -p tcp -m tcp --dport ${port} -j ACCEPT > /dev/null 2>&1; then
54 sudo iptables -I INPUT -i ${IRONIC_PROVISIONING_INTERFACE} -p tcp -m tcp --dport ${port} -j ACCEPT
58 # Allow access to dhcp and tftp server for pxeboot
59 for port in 67 69 ; do
60 if ! sudo iptables -C INPUT -i ${IRONIC_PROVISIONING_INTERFACE} -p udp --dport ${port} -j ACCEPT 2>/dev/null ; then
61 sudo iptables -I INPUT -i ${IRONIC_PROVISIONING_INTERFACE} -p udp --dport ${port} -j ACCEPT
66 function deploy_bridge {
67 configure_ironic_bridge
68 configure_ironic_interfaces
71 function clean_bridge {
72 ip link set provisioning down || true
73 ip link del provisioning type bridge || true
76 # This may be used to update the in-place Ironic YAML files from the
77 # upstream project. We cannot use the upstream sources directly as
78 # they require an envsubst step before kustomize build.
79 function build_source {
80 clone_baremetal_operator_repository
82 KUSTOMIZATION_FILES=$(find ${BMOPATH}/ironic-deployment/{default,ironic} -type f)
83 for src in ${KUSTOMIZATION_FILES}; do
84 dst=${src/${BMOPATH}\/ironic-deployment/${SCRIPTDIR}\/base}
85 mkdir -p $(dirname ${dst})
86 envsubst <${src} >${dst}
88 sed -i -e '/name: quay.io\/metal3-io\/ironic/{n;s/newTag:.*/newTag: '"${BMO_VERSION}"'/;}' ${SCRIPTDIR}/icn/kustomization.yaml
93 kustomize build ${SCRIPTDIR}/icn | kubectl apply -f -
94 kubectl wait --for=condition=Available --timeout=600s deployment/${NAMEPREFIX}-ironic -n ${NAMEPREFIX}-system
98 kustomize build ${SCRIPTDIR}/icn | kubectl delete -f -
99 rm -rf ${IRONIC_DATA_DIR}
103 "build-source") build_source ;;
105 "clean-bridge") clean_bridge ;;
107 "deploy-bridge") deploy_bridge ;;
109 Usage: $(basename $0) COMMAND
112 build-source - Rebuild the in-tree Ironic YAML files
113 clean - Remove Ironic
114 clean-bridge - Uninstall provisioning network bridge
115 deploy - Deploy Ironic
116 deploy-bridge - Install provisioning network bridge