X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=deploy%2Fmetal3-vm%2F03_launch_mgmt_cluster.sh;h=b72a30b6737f164fd6a1e694aa6601b2eaa077eb;hb=e3be88235a3456ea1b7fd34460d21d894ba21871;hp=d59338076bce7187a2886d758e0695873df8b711;hpb=71cde293d4753a07a5da01f410a7c3f94b600ace;p=icn.git diff --git a/deploy/metal3-vm/03_launch_mgmt_cluster.sh b/deploy/metal3-vm/03_launch_mgmt_cluster.sh index d593380..b72a30b 100755 --- a/deploy/metal3-vm/03_launch_mgmt_cluster.sh +++ b/deploy/metal3-vm/03_launch_mgmt_cluster.sh @@ -1,5 +1,5 @@ -#!/bin/bash -set -xe +#!/usr/bin/env bash +set -eux -o pipefail # shellcheck disable=SC1091 source lib/logging.sh @@ -51,7 +51,7 @@ function clone_repos { } function launch_baremetal_operator { - docker pull integratedcloudnative/baremetal-operator:v1.0-icn + docker pull $IRONIC_BAREMETAL_IMAGE kubectl apply -f $BMODIR/namespace/namespace.yaml kubectl apply -f $BMODIR/rbac/service_account.yaml -n metal3 kubectl apply -f $BMODIR/rbac/role.yaml -n metal3 @@ -60,25 +60,9 @@ function launch_baremetal_operator { kubectl apply -f $BMODIR/operator/no_ironic/operator.yaml -n metal3 } -network_config_files() { -cat << 'EOF' -write_files: -- path: /opt/ironic_net.sh - owner: root:root - permissions: '0777' - content: | - #!/usr/bin/env bash - set -xe - for intf in /sys/class/net/*; do - sudo ifconfig `basename $intf` up - sudo dhclient -nw `basename $intf` - done -runcmd: - - [ /opt/ironic_net.sh ] -EOF -} - -create_userdata() { +# documentation for the values below may be found at +# https://cloudinit.readthedocs.io/en/latest/topics/modules.html +function create_userdata { name="$1" COMPUTE_NODE_FQDN="$name.akraino.icn.org" printf "#cloud-config\n" > $name-userdata.yaml @@ -100,11 +84,32 @@ create_userdata() { fi cat $HOME/.ssh/id_rsa.pub >> $name-userdata.yaml - network_config_files >> $name-userdata.yaml + cloud_init_scripts >> $name-userdata.yaml printf "\n" >> $name-userdata.yaml } -apply_userdata_credential() { +function cloud_init_scripts { + # set_dhcp_indentifier.sh: + # The IP address assigned to the provisioning NIC will change + # due to IPA using the MAC address as the client ID and systemd + # using a different ID. Tell systemd to use the MAC as the + # client ID. We can't do this in the network data as only the + # JSON format is supported by metal3, and the JSON format does + # not support the dhcp-identifier field. + cat << 'EOF' +write_files: +- path: /var/lib/cloud/scripts/per-instance/set_dhcp_identifier.sh + owner: root:root + permissions: '0777' + content: | + #!/usr/bin/env bash + set -eux -o pipefail + sed -i -e '/dhcp4: true$/!b' -e 'h;s/\S.*/dhcp-identifier: mac/;H;g' /etc/netplan/50-cloud-init.yaml + netplan apply +EOF +} + +function apply_userdata_credential { name="$1" cat < ./$name-user-data-credential.yaml apiVersion: v1 @@ -119,11 +124,33 @@ EOF kubectl apply -n metal3 -f $name-user-data-credential.yaml } +function create_networkdata { + name="$1" + node_networkdata $name > $name-networkdata.json +} + +function apply_networkdata_credential { + name="$1" + cat < ./$name-network-data-credential.yaml +apiVersion: v1 +data: + networkData: $(base64 -w 0 $name-networkdata.json) +kind: Secret +metadata: + name: $name-network-data + namespace: metal3 +type: Opaque +EOF + kubectl apply -n metal3 -f $name-network-data-credential.yaml +} + function make_bm_hosts { - while read -r name address user password mac; do + while IFS=',' read -r name address user password mac; do create_userdata $name apply_userdata_credential $name - go run "${BMOPATH}"/cmd/make-bm-worker/main.go \ + create_networkdata $name + apply_networkdata_credential $name + GO111MODULE=auto go run "${BMOPATH}"/cmd/make-bm-worker/main.go \ -address "$address" \ -password "$password" \ -user "$user" \ @@ -134,7 +161,12 @@ function make_bm_hosts { printf "\n checksum: ""%s" "${IMAGE_CHECKSUM}" >> $name-bm-node.yaml printf "\n userData:" >> $name-bm-node.yaml printf "\n name: ""%s" "$name""-user-data" >> $name-bm-node.yaml - printf "\n namespace: metal3\n" >> $name-bm-node.yaml + printf "\n namespace: metal3" >> $name-bm-node.yaml + printf "\n networkData:" >> $name-bm-node.yaml + printf "\n name: ""%s" "$name""-network-data" >> $name-bm-node.yaml + printf "\n namespace: metal3" >> $name-bm-node.yaml + printf "\n rootDeviceHints:" >> $name-bm-node.yaml + printf "\n minSizeGigabytes: 48\n" >> $name-bm-node.yaml kubectl apply -f $name-bm-node.yaml -n metal3 done }