Skip to content

Commit

Permalink
refactor!: Modify cluster up to use the gocli
Browse files Browse the repository at this point in the history
Delete old bash code and up clusters using the gocli instead.

Signed-off-by: aerosouund <[email protected]>
  • Loading branch information
aerosouund committed Aug 25, 2024
1 parent 4ebe4d9 commit 3ccedec
Show file tree
Hide file tree
Showing 21 changed files with 38 additions and 1,315 deletions.
9 changes: 0 additions & 9 deletions cluster-up/cluster/external/provider.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ manifest_docker_prefix=\${DOCKER_PREFIX}
image_pull_policy=\${IMAGE_PULL_POLICY:-Always}
EOF

if [ -n "$KUBECTL" ]; then
echo "kubectl=${KUBECTL}" >> "$PROVIDER_CONFIG_FILE_PATH"
else
if which kubectl; then
echo "kubectl=$(which kubectl)" >> "$PROVIDER_CONFIG_FILE_PATH"
fi
fi


if which oc; then
echo "oc=$(which oc)" >> "$PROVIDER_CONFIG_FILE_PATH"
fi
Expand Down
52 changes: 8 additions & 44 deletions cluster-up/cluster/kind-1.28/provider.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,16 @@

set -e

DEFAULT_CLUSTER_NAME="kind-1.28"
DEFAULT_HOST_PORT=5000
ALTERNATE_HOST_PORT=5001
export CLUSTER_NAME=${CLUSTER_NAME:-$DEFAULT_CLUSTER_NAME}
export CLUSTER_NAME="k8s-1.28"

if [ $CLUSTER_NAME == $DEFAULT_CLUSTER_NAME ]; then
export HOST_PORT=$DEFAULT_HOST_PORT
else
export HOST_PORT=$ALTERNATE_HOST_PORT
fi

function set_kind_params() {
version=$(cat cluster-up/cluster/$KUBEVIRT_PROVIDER/version)
export KIND_VERSION="${KIND_VERSION:-$version}"

image=$(cat cluster-up/cluster/$KUBEVIRT_PROVIDER/image)
export KIND_NODE_IMAGE="${KIND_NODE_IMAGE:-$image}"
}

function configure_registry_proxy() {
[ "$CI" != "true" ] && return

echo "Configuring cluster nodes to work with CI mirror-proxy..."

local -r ci_proxy_hostname="docker-mirror-proxy.kubevirt-prow.svc"
local -r kind_binary_path="${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kind"
local -r configure_registry_proxy_script="${KUBEVIRTCI_PATH}/cluster/kind/configure-registry-proxy.sh"

KIND_BIN="$kind_binary_path" PROXY_HOSTNAME="$ci_proxy_hostname" $configure_registry_proxy_script
}
make -C cluster-provision/gocli cli

function up() {
cp $KIND_MANIFESTS_DIR/kind.yaml ${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/kind.yaml
_add_kubeadm_cpu_manager_config_patch
_add_extra_mounts
export CONFIG_WORKER_CPU_MANAGER=true
kind_up

configure_registry_proxy

# remove the rancher.io kind default storageClass
_kubectl delete sc standard

echo "$KUBEVIRT_PROVIDER cluster '$CLUSTER_NAME' is ready"
if [ "$CI" == "true" ]; then export REGISTRY_PROXY="docker-mirror-proxy.kubevirt-prow.svc"; fi
./cluster-provision/gocli/build/cli run-kind k8s-1.28 \
--with-extra-mounts=true \
--nodes=$KUBEVIRT_NUM_NODES \
--registry-proxy=$REGISTRY_PROXY
}

set_kind_params

source ${KUBEVIRTCI_PATH}/cluster/kind/common.sh
source ${KUBEVIRTCI_PATH}/cluster/kind/common.sh
19 changes: 0 additions & 19 deletions cluster-up/cluster/kind-1.30-vgpu/config_vgpu_cluster.sh

This file was deleted.

53 changes: 12 additions & 41 deletions cluster-up/cluster/kind-1.30-vgpu/provider.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,28 @@

set -e

DEFAULT_CLUSTER_NAME="vgpu"
DEFAULT_HOST_PORT=5000
ALTERNATE_HOST_PORT=5001
export CLUSTER_NAME=${CLUSTER_NAME:-$DEFAULT_CLUSTER_NAME}

if [ $CLUSTER_NAME == $DEFAULT_CLUSTER_NAME ]; then
export HOST_PORT=$DEFAULT_HOST_PORT
else
export HOST_PORT=$ALTERNATE_HOST_PORT
fi

function set_kind_params() {
version=$(cat cluster-up/cluster/$KUBEVIRT_PROVIDER/version)
export KIND_VERSION="${KIND_VERSION:-$version}"

image=$(cat cluster-up/cluster/$KUBEVIRT_PROVIDER/image)
export KIND_NODE_IMAGE="${KIND_NODE_IMAGE:-$image}"
}
export CLUSTER_NAME="vgpu"

function configure_registry_proxy() {
[ "$CI" != "true" ] && return

echo "Configuring cluster nodes to work with CI mirror-proxy..."
function detect_cri() {
if podman ps >/dev/null 2>&1; then echo podman; elif docker ps >/dev/null 2>&1; then echo docker; fi
}

local -r ci_proxy_hostname="docker-mirror-proxy.kubevirt-prow.svc"
local -r kind_binary_path="${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kind"
local -r configure_registry_proxy_script="${KUBEVIRTCI_PATH}/cluster/kind/configure-registry-proxy.sh"
make -C cluster-provision/gocli cli

KIND_BIN="$kind_binary_path" PROXY_HOSTNAME="$ci_proxy_hostname" $configure_registry_proxy_script
}
export CRI_BIN=${CRI_BIN:-$(detect_cri)}

function up() {
# print hardware info for easier debugging based on logs
echo 'Available cards'
${CRI_BIN} run --rm --cap-add=SYS_RAWIO quay.io/phoracek/lspci@sha256:0f3cacf7098202ef284308c64e3fc0ba441871a846022bb87d65ff130c79adb1 sh -c "lspci -k | grep -EA2 'VGA|3D'"
echo ""

cp $KIND_MANIFESTS_DIR/kind.yaml ${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/kind.yaml
_add_extra_mounts
kind_up

configure_registry_proxy

# remove the rancher.io kind default storageClass
_kubectl delete sc standard

${KUBEVIRTCI_PATH}/cluster/$KUBEVIRT_PROVIDER/config_vgpu_cluster.sh

echo "$KUBEVIRT_PROVIDER cluster '$CLUSTER_NAME' is ready"
if [ "$CI" == "true" ]; then export REGISTRY_PROXY="docker-mirror-proxy.kubevirt-prow.svc"; fi
./cluster-provision/gocli/build/cli run-kind vgpu \
--with-extra-mounts=true \
--nodes=$KUBEVIRT_NUM_NODES \
--registry-proxy=$REGISTRY_PROXY
}

set_kind_params

source ${KUBEVIRTCI_PATH}/cluster/kind/common.sh
source ${KUBEVIRTCI_PATH}/cluster/kind/common.sh
32 changes: 0 additions & 32 deletions cluster-up/cluster/kind-1.30-vgpu/vgpu-node/node.sh

This file was deleted.

73 changes: 0 additions & 73 deletions cluster-up/cluster/kind-sriov/config_sriov_cluster.sh

This file was deleted.

82 changes: 18 additions & 64 deletions cluster-up/cluster/kind-sriov/provider.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,31 @@

set -e

DEFAULT_CLUSTER_NAME="sriov"
DEFAULT_HOST_PORT=5000
ALTERNATE_HOST_PORT=5001
export CLUSTER_NAME=${CLUSTER_NAME:-$DEFAULT_CLUSTER_NAME}
export CLUSTER_NAME="sriov"
PF_COUNT_PER_NODE=${PF_COUNT_PER_NODE:-1}
VF_COUNT_PER_NODE=${VF_COUNT_PER_NODE:-6}

if [ $CLUSTER_NAME == $DEFAULT_CLUSTER_NAME ]; then
export HOST_PORT=$DEFAULT_HOST_PORT
else
export HOST_PORT=$ALTERNATE_HOST_PORT
fi

function print_available_nics() {
# print hardware info for easier debugging based on logs
echo 'Available NICs'
${CRI_BIN} run --rm --cap-add=SYS_RAWIO quay.io/phoracek/lspci@sha256:0f3cacf7098202ef284308c64e3fc0ba441871a846022bb87d65ff130c79adb1 sh -c "lspci | egrep -i 'network|ethernet'"
echo ""
}

function set_kind_params() {
version=$(cat cluster-up/cluster/$KUBEVIRT_PROVIDER/version)
export KIND_VERSION="${KIND_VERSION:-$version}"

image=$(cat cluster-up/cluster/$KUBEVIRT_PROVIDER/image)
export KIND_NODE_IMAGE="${KIND_NODE_IMAGE:-$image}"
function detect_cri() {
if podman ps >/dev/null 2>&1; then echo podman; elif docker ps >/dev/null 2>&1; then echo docker; fi
}

function print_sriov_data() {
nodes=$(_kubectl get nodes -o=custom-columns=:.metadata.name | awk NF)
for node in $nodes; do
if [[ ! "$node" =~ .*"control-plane".* ]]; then
echo "Node: $node"
echo "VFs:"
${CRI_BIN} exec $node bash -c "ls -l /sys/class/net/*/device/virtfn*"
echo "PFs PCI Addresses:"
${CRI_BIN} exec $node bash -c "grep PCI_SLOT_NAME /sys/class/net/*/device/uevent"
fi
done
}
make -C cluster-provision/gocli cli

function configure_registry_proxy() {
[ "$CI" != "true" ] && return
export CRI_BIN=${CRI_BIN:-$(detect_cri)}

echo "Configuring cluster nodes to work with CI mirror-proxy..."

local -r ci_proxy_hostname="docker-mirror-proxy.kubevirt-prow.svc"
local -r kind_binary_path="${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kind"
local -r configure_registry_proxy_script="${KUBEVIRTCI_PATH}/cluster/kind/configure-registry-proxy.sh"

KIND_BIN="$kind_binary_path" PROXY_HOSTNAME="$ci_proxy_hostname" $configure_registry_proxy_script
}

function deploy_sriov() {
print_available_nics
${KUBEVIRTCI_PATH}/cluster/$KUBEVIRT_PROVIDER/config_sriov_cluster.sh
print_sriov_data
}

function up() {
cp $KIND_MANIFESTS_DIR/kind.yaml ${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/kind.yaml
export CONFIG_WORKER_CPU_MANAGER=true
kind_up

configure_registry_proxy

# remove the rancher.io kind default storageClass
_kubectl delete sc standard
echo 'Available NICs'
${CRI_BIN} run --rm --cap-add=SYS_RAWIO quay.io/phoracek/lspci@sha256:0f3cacf7098202ef284308c64e3fc0ba441871a846022bb87d65ff130c79adb1 sh -c "lspci | egrep -i 'network|ethernet'"
echo ""

deploy_sriov
echo "$KUBEVIRT_PROVIDER cluster '$CLUSTER_NAME' is ready"
if [ "$CI" == "true" ]; then export REGISTRY_PROXY="docker-mirror-proxy.kubevirt-prow.svc"; fi
./cluster-provision/gocli/build/cli run-kind sriov \
--with-extra-mounts=true \
--nodes=$KUBEVIRT_NUM_NODES \
--registry-proxy=$REGISTRY_PROXY \
--pf-count-per-node=$PF_COUNT_PER_NODE
--vf-count-per-node=$VF_COUNT_PER_NODE
}

set_kind_params

source ${KUBEVIRTCI_PATH}/cluster/kind/common.sh
source ${KUBEVIRTCI_PATH}/cluster/kind/common.sh
Loading

0 comments on commit 3ccedec

Please sign in to comment.