Skip to content

Commit

Permalink
Set up the node -> machine mapping
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bcrochet committed Apr 3, 2019
1 parent 0fb6eb9 commit 0e20833
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions 08_deploy_bmo.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 --as system:admin apply -f $BMOPATH/deploy/service_account.yaml
oc --config ocp/auth/kubeconfig --as system:admin apply -f $BMOPATH/deploy/role.yaml
oc --config ocp/auth/kubeconfig --as system:admin apply -f $BMOPATH/deploy/role_binding.yaml
oc --config ocp/auth/kubeconfig --as system:admin apply -f $BMOPATH/deploy/crds/metalkube_v1alpha1_baremetalhost_crd.yaml
oc --config ocp/auth/kubeconfig --as system:admin apply -f $BMOPATH/deploy/operator.yaml

# Give the operator a chance to quiesce. Ideas to check instead of sleep?
sleep 10

oc --as system:admin --config ocp/auth/kubeconfig proxy &
proxy_pid=$!

for node in $(oc --as system:admin --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 --as system:admin --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

0 comments on commit 0e20833

Please sign in to comment.