From 3f47951b4e30e957c91abce18d5dd1202cd813a5 Mon Sep 17 00:00:00 2001 From: David Elie-Dit-Cosaque Date: Wed, 15 May 2024 09:14:13 -0500 Subject: [PATCH] Add support for deploying test k8s cluster on arm64 architectures --- scripts/deploy-cr-scale-operator.sh | 6 +++--- scripts/deploy-multus-network.sh | 4 ++++ scripts/deploy-statefulset-test-pods.sh | 4 ++++ scripts/deploy-test-pods.sh | 4 ++++ scripts/init-env.sh | 7 +++++-- scripts/preload-images.sh | 9 ++++----- test-target/local-pod-under-test.yaml | 2 +- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/scripts/deploy-cr-scale-operator.sh b/scripts/deploy-cr-scale-operator.sh index 9e094317..3aa3f50d 100755 --- a/scripts/deploy-cr-scale-operator.sh +++ b/scripts/deploy-cr-scale-operator.sh @@ -9,9 +9,9 @@ source "$SCRIPT_DIR"/init-env.sh source "$SCRIPT_DIR"/logging.sh # Variables for deployment -CR_SCALE_OPERATOR_GIT_REPO="https://github.com/test-network-function/cr-scale-operator.git" -TAG="main" -IMG="quay.io/testnetworkfunction/cr-scale-operator" +CR_SCALE_OPERATOR_GIT_REPO="git@github.com:edcdavid/cr-scale-operator.git" +TAG="add-arm64" +IMG="quay.io/testnetworkfunction/cr-scale-operator:v0.0.2" CR_SCALE_OPERATOR_DIR=cr-scale-operator # Clone the repo. diff --git a/scripts/deploy-multus-network.sh b/scripts/deploy-multus-network.sh index eaa80ccd..c01e6cbd 100755 --- a/scripts/deploy-multus-network.sh +++ b/scripts/deploy-multus-network.sh @@ -28,6 +28,10 @@ if $TNF_NON_OCP_CLUSTER; then ./generate_yamls.sh popd || exit + if [ "$CPU_ARCH" == "arm64" ]; then + sed -i 's/amd64/arm64/g' temp/multus-cni/e2e/yamls/cni-install.yml + fi + # Temporarily commenting this out as we are currently not running this in a non-allowlisted environment # sed 's/alpine/quay.io\/jitesoft\/alpine:latest/g' temp/multus-cni/e2e/yamls/cni-install.yml -i kubectl create -f temp/multus-cni/e2e/yamls/cni-install.yml diff --git a/scripts/deploy-statefulset-test-pods.sh b/scripts/deploy-statefulset-test-pods.sh index 69170cf4..dfef6eb7 100755 --- a/scripts/deploy-statefulset-test-pods.sh +++ b/scripts/deploy-statefulset-test-pods.sh @@ -15,6 +15,10 @@ NUM_NODES="${NUM_NODES%"${NUM_NODES##*[![:space:]]}"}" if [[ $NUM_NODES == 1 ]]; then REPLICAS=1 fi + +MULTUS_ANNOTATION="${MULTUS_ANNOTATION%?}" # Remove the last character +echo "MULTUS_ANNOTATION=$MULTUS_ANNOTATION" + APP="testss" RESOURCE_TYPE="StatefulSet" MULTUS_ANNOTATION=$MULTUS_ANNOTATION REPLICAS=$REPLICAS "$SCRIPT_DIR"/mo ./test-target/local-pod-under-test.yaml >./temp/rendered-local-statefulset-pod-under-test-template.yaml oc apply --filename ./temp/rendered-local-statefulset-pod-under-test-template.yaml rm ./temp/rendered-local-statefulset-pod-under-test-template.yaml diff --git a/scripts/deploy-test-pods.sh b/scripts/deploy-test-pods.sh index da86f34f..1b7ba11f 100755 --- a/scripts/deploy-test-pods.sh +++ b/scripts/deploy-test-pods.sh @@ -16,6 +16,10 @@ if [[ $NUM_NODES == 1 ]]; then REPLICAS=1 fi "$SCRIPT_DIR"/mo ./test-target/test-service-account.yaml >./temp/rendered-test-service-account-template.yaml + +MULTUS_ANNOTATION="${MULTUS_ANNOTATION%?}" # Remove the last character +echo "MULTUS_ANNOTATION=$MULTUS_ANNOTATION" + APP="testdp" RESOURCE_TYPE="Deployment" MULTUS_ANNOTATION=$MULTUS_ANNOTATION REPLICAS=$REPLICAS "$SCRIPT_DIR"/mo ./test-target/local-pod-under-test.yaml >./temp/rendered-local-pod-under-test-template.yaml oc apply --filename ./temp/rendered-test-service-account-template.yaml oc apply --filename ./temp/rendered-local-pod-under-test-template.yaml diff --git a/scripts/init-env.sh b/scripts/init-env.sh index e3e47141..20fe1eb5 100755 --- a/scripts/init-env.sh +++ b/scripts/init-env.sh @@ -31,7 +31,6 @@ else fi # Container executable -TNF_CONTAINER_CLIENT="docker" export CONTAINER_CLIENT="${CONTAINER_EXECUTABLE:-$TNF_CONTAINER_CLIENT}" # Test Namespace @@ -73,10 +72,11 @@ oc version | grep Server >/dev/null || { # create Multus annotations create_multus_annotation() { for ((NUM = 0; NUM < MULTUS_IF_NUM; NUM++)); do - MULTUS_ANNOTATION="${MULTUS_ANNOTATION}{ \"name\" : \"${NET_NAME}-$1-${NUM}\" }," + MULTUS_ANNOTATION="${MULTUS_ANNOTATION}${NET_NAME}-$1-${NUM}," done } + # Only add annotation in non OCP clusters if $TNF_NON_OCP_CLUSTER; then echo 'creating multus annotations' @@ -92,3 +92,6 @@ if $TNF_NON_OCP_CLUSTER; then export MULTUS_ANNOTATION="'[ ${MULTUS_ANNOTATION::-1} ]'" fi fi + +export CPU_ARCH="$(uname -m)" +echo "CPU_ARCH=$CPU_ARCH" diff --git a/scripts/preload-images.sh b/scripts/preload-images.sh index 5652a815..31057f12 100755 --- a/scripts/preload-images.sh +++ b/scripts/preload-images.sh @@ -17,16 +17,15 @@ set -e # Create array for images to preload IMAGES_TO_PRELOAD=( - httpd:2.4.58 + docker.io/library/httpd:2.4.58 "$COMMUNITY_OPERATOR_IMAGEREPO"/"$COMMUNITY_OPERATOR_BASE":"$COMMUNITY_OPERATOR_IMAGEVERSION" quay.io/testnetworkfunction/cnf-test-partner:latest quay.io/testnetworkfunction/debug-partner:latest - quay.io/testnetworkfunction/cr-scale-operator:latest + quay.io/testnetworkfunction/cr-scale-operator:v0.0.2 gcr.io/distroless/static:nonroot quay.io/calico/node:v3.28.0 quay.io/testnetworkfunction/nginx-operator-bundle:v0.0.1 ghcr.io/k8snetworkplumbingwg/multus-cni:snapshot - ghcr.io/k8snetworkplumbingwg/multus-cni:snapshot-thick registry.access.redhat.com/ubi9/ubi:latest registry.access.redhat.com/ubi9/ubi-minimal:latest quay.io/operator-framework/configmap-operator-registry:latest @@ -37,6 +36,6 @@ IMAGES_TO_PRELOAD=( # Preload images for image in "${IMAGES_TO_PRELOAD[@]}"; do - docker pull "$image" - kind load docker-image "$image" + ${CONTAINER_CLIENT} pull "$image" + ${CONTAINER_CLIENT} save "$image" -o image.tar && kind load image-archive image.tar && rm image.tar done diff --git a/test-target/local-pod-under-test.yaml b/test-target/local-pod-under-test.yaml index 309c7a54..04db22b1 100644 --- a/test-target/local-pod-under-test.yaml +++ b/test-target/local-pod-under-test.yaml @@ -20,7 +20,7 @@ spec: annotations: test-network-function.com/container_tests: '["PRIVILEGED_POD","PRIVILEGED_ROLE"]' # optional test-network-function.com/defaultnetworkinterface: '"eth0"' # optional - k8s.v1.cni.cncf.io/networks: {{ MULTUS_ANNOTATION }} + k8s.v1.cni.cncf.io/networks: '{{ MULTUS_ANNOTATION }}' name: test spec: terminationGracePeriodSeconds: 30