-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use cluster scripts Get rid of kubevirtci included in the project and ugly Makefile scripts. Scripts introduced in this PR are abstracting interaction with the cluster and are used with other kubevirtci projects as well. Signed-off-by: Petr Horacek <[email protected]> * fix kubevirtci.sh Signed-off-by: Quique Llorente <[email protected]> * Use k8s-1.17 provider by default Signed-off-by: Quique Llorente <[email protected]> * Fix docs Signed-off-by: Quique Llorente <[email protected]> * Cleanup Makefile Signed-off-by: Quique Llorente <[email protected]> * Use cluster/ tools instead of kubevirtci/cluster-up/ ones Signed-off-by: Quique Llorente <[email protected]> Co-authored-by: Félix Enrique Llorente Pastora <[email protected]>
- Loading branch information
Showing
22 changed files
with
221 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ build/_output | |
build/_test | ||
|
||
# Cloned kubevirtci | ||
kubevirtci | ||
_kubevirtci | ||
|
||
# Junit | ||
*junit*.xml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
echo 'Cleaning up ...' | ||
|
||
./cluster/kubectl.sh delete --ignore-not-found -f deploy/ | ||
./cluster/kubectl.sh delete --ignore-not-found -f deploy/crds/nmstate.io_nodenetworkconfigurationenactments_crd.yaml | ||
./cluster/kubectl.sh delete --ignore-not-found -f deploy/crds/nmstate.io_nodenetworkconfigurationpolicies_crd.yaml | ||
./cluster/kubectl.sh delete --ignore-not-found -f deploy/crds/nmstate.io_nodenetworkstates_crd.yaml | ||
|
||
if [[ "$KUBEVIRT_PROVIDER" =~ ^(okd|ocp)-.*$ ]]; then | ||
./cluster/kubectl.sh delete --ignore-not-found -f deploy/openshift/ | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
source ./cluster/kubevirtci.sh | ||
kubevirtci::install | ||
|
||
$(kubevirtci::path)/cluster-up/cli.sh "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
source ./cluster/kubevirtci.sh | ||
kubevirtci::install | ||
|
||
$(kubevirtci::path)/cluster-up/down.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
source ./cluster/kubevirtci.sh | ||
kubevirtci::kubeconfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
source ./cluster/kubevirtci.sh | ||
kubevirtci::install | ||
|
||
$(kubevirtci::path)/cluster-up/kubectl.sh "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
export KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER:-'k8s-1.17'} | ||
|
||
KUBEVIRTCI_VERSION='95096c8189c8b620ddc1310e12388df2190e1cc8' | ||
KUBEVIRTCI_REPO='https://github.com/kubevirt/kubevirtci.git' | ||
KUBEVIRTCI_PATH="${PWD}/_kubevirtci" | ||
|
||
function kubevirtci::_get_repo() { | ||
git --git-dir ${KUBEVIRTCI_PATH}/.git remote get-url origin | ||
} | ||
|
||
function kubevirtci::_get_version() { | ||
git --git-dir ${KUBEVIRTCI_PATH}/.git log --format="%H" -n 1 | ||
} | ||
|
||
function kubevirtci::install() { | ||
# Remove cloned kubevirtci repository if it does not match the requested one | ||
if [ -d ${KUBEVIRTCI_PATH} ]; then | ||
if [ $(kubevirtci::_get_repo) != ${KUBEVIRTCI_REPO} -o $(kubevirtci::_get_version) != ${KUBEVIRTCI_VERSION} ]; then | ||
rm -rf ${KUBEVIRTCI_PATH} | ||
fi | ||
fi | ||
|
||
if [ ! -d ${KUBEVIRTCI_PATH} ]; then | ||
git clone ${KUBEVIRTCI_REPO} ${KUBEVIRTCI_PATH} | ||
( | ||
cd ${KUBEVIRTCI_PATH} | ||
git checkout ${KUBEVIRTCI_VERSION} | ||
) | ||
fi | ||
} | ||
|
||
function kubevirtci::path() { | ||
echo -n ${KUBEVIRTCI_PATH} | ||
} | ||
|
||
function kubevirtci::kubeconfig() { | ||
echo -n ${KUBEVIRTCI_PATH}/_ci-configs/${KUBEVIRT_PROVIDER}/.kubeconfig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
function getDesiredNumberScheduled { | ||
echo $(./cluster/kubectl.sh get daemonset -n nmstate $1 -o=jsonpath='{.status.desiredNumberScheduled}') | ||
} | ||
|
||
function getNumberAvailable { | ||
numberAvailable=$(./cluster/kubectl.sh get daemonset -n nmstate $1 -o=jsonpath='{.status.numberAvailable}') | ||
echo ${numberAvailable:-0} | ||
} | ||
|
||
function consistently { | ||
cmd=$@ | ||
retries=3 | ||
interval=1 | ||
cnt=1 | ||
while [[ $cnt -le $retries ]]; do | ||
$cmd | ||
sleep $interval | ||
cnt=$(($cnt + 1)) | ||
done | ||
} | ||
|
||
function isOk { | ||
desiredNumberScheduled=$(getDesiredNumberScheduled $1) | ||
numberAvailable=$(getNumberAvailable $1) | ||
|
||
if [ "$desiredNumberScheduled" == "$numberAvailable" ]; then | ||
echo "$1 DS is ready" | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
} | ||
|
||
# Cleanup previous deployment, if there is any | ||
make cluster-clean | ||
|
||
# Fetch registry port that can be used to upload images to the local kubevirtci cluster | ||
registry_port=$(./cluster/cli.sh ports registry | tr -d '\r') | ||
if [[ "${KUBEVIRT_PROVIDER}" =~ ^(okd|ocp)-.*$ ]]; then \ | ||
registry=localhost:$(./cluster/cli.sh ports --container-name=cluster registry | tr -d '\r') | ||
else | ||
registry=localhost:$(./cluster/cli.sh ports registry | tr -d '\r') | ||
fi | ||
|
||
# Build new handler image from local sources and push it to the kubevirtci cluster | ||
IMAGE_REGISTRY=${registry} make push-handler | ||
|
||
# Deploy all needed manifests | ||
./cluster/kubectl.sh apply -f deploy/namespace.yaml | ||
./cluster/kubectl.sh apply -f deploy/service_account.yaml | ||
./cluster/kubectl.sh apply -f deploy/role.yaml | ||
./cluster/kubectl.sh apply -f deploy/role_binding.yaml | ||
./cluster/kubectl.sh apply -f deploy/crds/nmstate.io_nodenetworkstates_crd.yaml | ||
./cluster/kubectl.sh apply -f deploy/crds/nmstate.io_nodenetworkconfigurationpolicies_crd.yaml | ||
./cluster/kubectl.sh apply -f deploy/crds/nmstate.io_nodenetworkconfigurationenactments_crd.yaml | ||
if [[ "$KUBEVIRT_PROVIDER" =~ ^(okd|ocp)-.*$ ]]; then | ||
./cluster/kubectl.sh apply -f deploy/openshift/ | ||
fi | ||
sed \ | ||
-e "s#--v=production#--v=debug#" \ | ||
-e "s#REPLACE_IMAGE#registry:5000/nmstate/kubernetes-nmstate-handler#" \ | ||
deploy/operator.yaml | ./cluster/kubectl.sh create -f - | ||
|
||
# Wait until the handler becomes ready on all nodes | ||
for i in {300..0}; do | ||
# We have to re-check desired number, sometimes takes some time to be filled in | ||
if consistently isOk nmstate-handler && consistently isOk nmstate-handler-worker; then | ||
break | ||
fi | ||
|
||
if [ $i -eq 0 ]; then | ||
echo "nmstate-handler or nmstate-handler-worker DS haven't turned ready within the given timeout" | ||
exit 1 | ||
fi | ||
|
||
sleep 1 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
source ./cluster/kubevirtci.sh | ||
kubevirtci::install | ||
|
||
$(kubevirtci::path)/cluster-up/up.sh | ||
|
||
if [[ "$KUBEVIRT_PROVIDER" =~ ^(okd|ocp)-.*$$ ]]; then \ | ||
while ! $(KUBECTL) get securitycontextconstraints; do sleep 1; done; \ | ||
fi | ||
|
||
if [[ "$KUBEVIRT_PROVIDER" =~ k8s- ]]; then | ||
echo 'Install NetworkManager on nodes' | ||
for node in $(./cluster/kubectl.sh get nodes --no-headers | awk '{print $1}'); do | ||
./cluster/cli.sh ssh ${node} sudo -- yum install -y yum-plugin-copr | ||
./cluster/cli.sh ssh ${node} sudo -- yum copr enable -y networkmanager/NetworkManager-1.22 | ||
./cluster/cli.sh ssh ${node} sudo -- yum install -y NetworkManager | ||
./cluster/cli.sh ssh ${node} sudo -- systemctl daemon-reload | ||
./cluster/cli.sh ssh ${node} sudo -- systemctl restart NetworkManager | ||
echo "Check NetworkManager is working fine on node $node" | ||
./cluster/cli.sh ssh ${node} -- nmcli device show > /dev/null | ||
done | ||
fi | ||
|
||
for node in $(./cluster/kubectl.sh get nodes --no-headers | awk '{print $1}'); do | ||
for nic in $FIRST_SECONDARY_NIC $SECOND_SECONDARY_NIC; do | ||
uuid=$(./cluster/cli.sh ssh $node -- nmcli --fields=device,uuid c show |grep $nic|awk '{print $2}') | ||
if [ ! -z "$uuid" ]; then | ||
echo "$node: Flushing nic $nic" | ||
./cluster/cli.sh ssh $node -- sudo nmcli con del $uuid | ||
fi | ||
done | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.