From b4d9d266a0cfd54c58504b5e19945dff41339f21 Mon Sep 17 00:00:00 2001 From: "Brad P. Crochet" Date: Wed, 3 Apr 2019 16:54:40 -0400 Subject: [PATCH] Set up the node -> machine mapping This manually updates the status of the Machine objects to contains: 1) nodeRef pointing back to the Node 2) addresses of the Node, copied to the Machine --- 08_deploy_bmo.sh | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/08_deploy_bmo.sh b/08_deploy_bmo.sh index 629a56d6a..4ea7cccb0 100755 --- a/08_deploy_bmo.sh +++ b/08_deploy_bmo.sh @@ -1,9 +1,9 @@ #!/usr/bin/bash -set -ex - -#source common.sh -eval "$(go env)" +set -eux +source utils.sh +source common.sh +source ocp_install_env.sh # Get the latest bits for baremetal-operator export BMOPATH="$GOPATH/src/github.com/metalkube/baremetal-operator" @@ -13,8 +13,23 @@ cp -r $BMOPATH/deploy ocp/. sed -i 's/namespace: .*/namespace: openshift-machine-api/g' ocp/deploy/role_binding.yaml # Start deploying on the new cluster -oc --config ocp/auth/kubeconfig apply -f ocp/deploy/service_account.yaml --namespace=openshift-machine-api -oc --config ocp/auth/kubeconfig apply -f ocp/deploy/role.yaml --namespace=openshift-machine-api -oc --config ocp/auth/kubeconfig apply -f ocp/deploy/role_binding.yaml -oc --config ocp/auth/kubeconfig apply -f ocp/deploy/operator.yaml --namespace=openshift-machine-api -oc --config ocp/auth/kubeconfig apply -f ocp/deploy/crds/metalkube_v1alpha1_baremetalhost_crd.yaml +oc --config ocp/auth/kubeconfig apply -f $BMOPATH/deploy/service_account.yaml +oc --config ocp/auth/kubeconfig apply -f $BMOPATH/deploy/role.yaml +oc --config ocp/auth/kubeconfig apply -f $BMOPATH/deploy/role_binding.yaml +oc --config ocp/auth/kubeconfig apply -f $BMOPATH/deploy/crds/metalkube_v1alpha1_baremetalhost_crd.yaml +oc --config ocp/auth/kubeconfig apply -f $BMOPATH/deploy/operator.yaml + +# Give the operator a chance to quiesce. Ideas to check instead of sleep? +sleep 10 + +oc --config ocp/auth/kubeconfig proxy & +proxy_pid=$! + +for node in $(oc --config ocp/auth/kubeconfig get nodes -o template --template='{{range .items}}{{.metadata.uid}}:{{.metadata.name}}{{"\n"}}{{end}}'); do + name=$(echo $node | cut -f2 -d':') + uid=$(echo $node | cut -f1 -d':') + addresses=$(oc --config ocp/auth/kubeconfig get node $name -o json | jq -c '.status.addresses') + curl -X PATCH http://localhost:8001/apis/machine.openshift.io/v1beta1/namespaces/openshift-machine-api/machines/$CLUSTER_NAME-$name/status -H "Content-type: application/merge-patch+json" -d '{"status":{"addresses":'"${addresses}"',"nodeRef":{"kind":"Node","name":"'"${name}"'","uid":"'"${uid}"'"}}}' +done + +kill $proxy_pid