minor fix in baremetal clean up script
[icn.git] / env / metal3 / 03_launch_prereq.sh
index 771c765..0d81e5a 100755 (executable)
@@ -76,31 +76,44 @@ function check_k8s_node_status {
     fi
 }
 
-function install_podman {
+function install_ironic_container {
     # set password for mariadb
     mariadb_password=$(echo $(date;hostname)|sha256sum |cut -c-20)
 
-    # Create pod
-    podman pod create -n ironic-pod
+    # Start image downloader container
+    docker run -d --net host --privileged --name ipa-downloader \
+        --env-file "${PWD}/ironic.env" \
+        -v "$IRONIC_DATA_DIR:/shared" "${IPA_DOWNLOADER_IMAGE}" /usr/local/bin/get-resource.sh
 
-    # Start dnsmasq, http, mariadb, and ironic containers using same image
-    podman run -d --net host --privileged --name dnsmasq  --pod ironic-pod \
-        -v $IRONIC_DATA_DIR:/shared --entrypoint /bin/rundnsmasq ${IRONIC_IMAGE}
-
-    podman run -d --net host --privileged --name httpd --pod ironic-pod \
-        -v $IRONIC_DATA_DIR:/shared --entrypoint /bin/runhttpd ${IRONIC_IMAGE}
-
-    podman run -d --net host --privileged --name mariadb --pod ironic-pod \
-        -v $IRONIC_DATA_DIR:/shared --entrypoint /bin/runmariadb \
-        --env MARIADB_PASSWORD=$mariadb_password ${IRONIC_IMAGE}
+    docker wait ipa-downloader
 
-    podman run -d --net host --privileged --name ironic --pod ironic-pod \
-        --env MARIADB_PASSWORD=$mariadb_password \
-        -v $IRONIC_DATA_DIR:/shared ${IRONIC_IMAGE}
+    # Start dnsmasq, http, mariadb, and ironic containers using same image
+    # See this file for env vars you can set, like IP, DHCP_RANGE, INTERFACE
+    docker run -d --net host --privileged --name dnsmasq \
+        --env-file "${PWD}/ironic.env" \
+        -v "$IRONIC_DATA_DIR:/shared" --entrypoint /bin/rundnsmasq "${IRONIC_IMAGE}"
+
+    # For available env vars, see:
+    docker run -d --net host --privileged --name httpd \
+        --env-file "${PWD}/ironic.env" \
+        -v "$IRONIC_DATA_DIR:/shared" --entrypoint /bin/runhttpd "${IRONIC_IMAGE}"
+
+    # https://github.com/metal3-io/ironic/blob/master/runmariadb.sh
+    docker run -d --net host --privileged --name mariadb \
+        --env-file "${PWD}/ironic.env" \
+        -v "$IRONIC_DATA_DIR:/shared" --entrypoint /bin/runmariadb \
+        --env "MARIADB_PASSWORD=$mariadb_password" "${IRONIC_IMAGE}"
+
+    # See this file for additional env vars you may want to pass, like IP and INTERFACE
+    docker run -d --net host --privileged --name ironic \
+        --env-file "${PWD}/ironic.env" \
+        --env "MARIADB_PASSWORD=$mariadb_password" \
+        -v "$IRONIC_DATA_DIR:/shared" "${IRONIC_IMAGE}"
 
     # Start Ironic Inspector
-    podman run -d --net host --privileged --name ironic-inspector \
-        --pod ironic-pod "${IRONIC_INSPECTOR_IMAGE}"
+    docker run -d --net host --privileged --name ironic-inspector \
+        --env-file "${PWD}/ironic.env" \
+        -v "$IRONIC_DATA_DIR:/shared" "${IRONIC_INSPECTOR_IMAGE}"
 }
 
 function remove_k8s_noschedule_taint {
@@ -134,18 +147,39 @@ function install_dhcp {
     kubectl create -f $PWD/04_dhcp.yaml
 }
 
+function reset_dhcp {
+    kubectl delete -f $PWD/04_dhcp.yaml
+    if [ -d $BS_DHCP_DIR ]; then
+        rm -rf $BS_DHCP_DIR
+    fi
+}
+
+function create_ironic_env {
+    cat <<EOF > ${PWD}/ironic.env
+PROVISIONING_INTERFACE=provisioning
+DHCP_RANGE=172.22.0.10,172.22.0.100
+DEPLOY_KERNEL_URL=http://172.22.0.1/images/ironic-python-agent.kernel
+DEPLOY_RAMDISK_URL=http://172.22.0.1/images/ironic-python-agent.initramfs
+IRONIC_ENDPOINT=http://172.22.0.1:6385/v1/
+IRONIC_INSPECTOR_ENDPOINT=http://172.22.0.1:5050/v1/
+CACHEURL=http://172.22.0.1/images
+IRONIC_FAST_TRACK=false
+EOF
+}
+
 function install {
+    #Kubeadm usage is deprecated in v1,0,0 version
     #install_kubernetes
-    install_k8s_single_node
-    check_cni_network $1
-    create_k8s_regular_user
-    check_k8s_node_status
-    remove_k8s_noschedule_taint
+    #install_k8s_single_node
+    #check_cni_network $1
+    #create_k8s_regular_user
+    #check_k8s_node_status
+    #remove_k8s_noschedule_taint
 
     #install_podman
     #Todo - error handling mechanism
-    install_podman
-    install_dhcp
+    create_ironic_env
+    install_ironic_container
 }
 
 if [ "$1" == "-o" ]; then
@@ -153,4 +187,18 @@ if [ "$1" == "-o" ]; then
     exit 0
 fi
 
+if [ "$1" == "--dhcp-start" ]; then
+    install_dhcp
+    echo "wait for 320s for nodes to be assigned"
+    sleep 6m
+    exit 0
+fi
+
+if [ "$1" == "--dhcp-reset" ]; then
+    reset_dhcp
+    echo "wait for 320s for nodes to be re-assigned"
+    sleep 6m
+    exit 0
+fi
+
 install