X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=deploy%2Fmetal3-vm%2F03_launch_mgmt_cluster.sh;h=b72a30b6737f164fd6a1e694aa6601b2eaa077eb;hb=11441a8b2aedc39665e64c6aac45f8a31186d777;hp=62ab2941f2ce542103a01650587dd4d41a6c62d9;hpb=d044b7f516e10eecdb313b1f003185326a1f29c8;p=icn.git diff --git a/deploy/metal3-vm/03_launch_mgmt_cluster.sh b/deploy/metal3-vm/03_launch_mgmt_cluster.sh index 62ab294..b72a30b 100755 --- a/deploy/metal3-vm/03_launch_mgmt_cluster.sh +++ b/deploy/metal3-vm/03_launch_mgmt_cluster.sh @@ -60,25 +60,9 @@ function launch_baremetal_operator { kubectl apply -f $BMODIR/operator/no_ironic/operator.yaml -n metal3 } -function cloud_init_scripts { - cat << 'EOF' -write_files: -- path: /var/lib/cloud/scripts/per-boot/run_dhclient.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 -EOF -} - # documentation for the values below may be found at # https://cloudinit.readthedocs.io/en/latest/topics/modules.html -create_userdata() { +function create_userdata { name="$1" COMPUTE_NODE_FQDN="$name.akraino.icn.org" printf "#cloud-config\n" > $name-userdata.yaml @@ -104,7 +88,28 @@ create_userdata() { 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,10 +124,32 @@ 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 IFS=',' read -r name address user password mac; do create_userdata $name apply_userdata_credential $name + create_networkdata $name + apply_networkdata_credential $name GO111MODULE=auto go run "${BMOPATH}"/cmd/make-bm-worker/main.go \ -address "$address" \ -password "$password" \ @@ -135,6 +162,9 @@ function make_bm_hosts { printf "\n userData:" >> $name-bm-node.yaml printf "\n name: ""%s" "$name""-user-data" >> $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