Skip to content

Commit 0e60f7f

Browse files
authored
Add support for deploying test k8s cluster natively on arm64 architectures (#433)
* Add support for deploying test k8s cluster on arm64 architectures * Addressing comments from Brandon and David * Fix Typo * revert bumping operator version by accident * Addressing comment from Brandon, re-adding TNF_CONTAINER_CLIENT="docker"
1 parent ed797f5 commit 0e60f7f

File tree

7 files changed

+23
-13
lines changed

7 files changed

+23
-13
lines changed

scripts/deploy-cr-scale-operator.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ source "$SCRIPT_DIR"/logging.sh
1111
# Variables for deployment
1212
CR_SCALE_OPERATOR_GIT_REPO="https://github.com/test-network-function/cr-scale-operator.git"
1313
TAG="main"
14-
IMG="quay.io/testnetworkfunction/cr-scale-operator"
14+
IMG="quay.io/testnetworkfunction/cr-scale-operator:latest"
1515
CR_SCALE_OPERATOR_DIR=cr-scale-operator
1616

1717
# Clone the repo.

scripts/deploy-multus-network.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@ if $TNF_NON_OCP_CLUSTER; then
2424
# Install macvlan and other default plugins
2525
echo "## install CNIs"
2626
pushd temp/multus-cni/e2e || exit
27-
./get_tools.sh
27+
if [ "$CPU_ARCH" != arm64 ]; then
28+
./get_tools.sh
29+
fi
2830
./generate_yamls.sh
2931
popd || exit
3032

33+
if [ "$CPU_ARCH" == arm64 ]; then
34+
sed -i 's/amd64/arm64/g' temp/multus-cni/e2e/yamls/cni-install.yml
35+
fi
36+
3137
# Temporarily commenting this out as we are currently not running this in a non-allowlisted environment
3238
# sed 's/alpine/quay.io\/jitesoft\/alpine:latest/g' temp/multus-cni/e2e/yamls/cni-install.yml -i
3339
kubectl create -f temp/multus-cni/e2e/yamls/cni-install.yml

scripts/deploy-statefulset-test-pods.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ NUM_NODES="${NUM_NODES%"${NUM_NODES##*[![:space:]]}"}"
1515
if [[ $NUM_NODES == 1 ]]; then
1616
REPLICAS=1
1717
fi
18+
1819
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
1920
oc apply --filename ./temp/rendered-local-statefulset-pod-under-test-template.yaml
2021
rm ./temp/rendered-local-statefulset-pod-under-test-template.yaml

scripts/deploy-test-pods.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ if [[ $NUM_NODES == 1 ]]; then
1616
REPLICAS=1
1717
fi
1818
"$SCRIPT_DIR"/mo ./test-target/test-service-account.yaml >./temp/rendered-test-service-account-template.yaml
19+
1920
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
2021
oc apply --filename ./temp/rendered-test-service-account-template.yaml
2122
oc apply --filename ./temp/rendered-local-pod-under-test-template.yaml

scripts/init-env.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ oc version | grep Server >/dev/null || {
7373
# create Multus annotations
7474
create_multus_annotation() {
7575
for ((NUM = 0; NUM < MULTUS_IF_NUM; NUM++)); do
76-
MULTUS_ANNOTATION="${MULTUS_ANNOTATION}{ \"name\" : \"${NET_NAME}-$1-${NUM}\" },"
76+
MULTUS_ANNOTATION="${MULTUS_ANNOTATION}${NET_NAME}-$1-${NUM},"
7777
done
7878
}
7979

@@ -86,9 +86,12 @@ if $TNF_NON_OCP_CLUSTER; then
8686

8787
# IPv6
8888
create_multus_annotation ipv6
89-
if [ "$NUM" -ge 0 ]; then
90-
# Remove last comma. Works on bash 3.2.4 on OS X:
91-
# https://unix.stackexchange.com/questions/144298/delete-the-last-character-of-a-string-using-string-manipulation-in-shell-script
92-
export MULTUS_ANNOTATION="'[ ${MULTUS_ANNOTATION::-1} ]'"
93-
fi
89+
90+
# Remove the last character (comma)
91+
# https://unix.stackexchange.com/questions/144298/delete-the-last-character-of-a-string-using-string-manipulation-in-shell-script
92+
MULTUS_ANNOTATION="${MULTUS_ANNOTATION%?}"
9493
fi
94+
95+
CPU_ARCH="$(uname -m)"
96+
export CPU_ARCH
97+
echo "CPU_ARCH=$CPU_ARCH"

scripts/preload-images.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ set -e
1717

1818
# Create array for images to preload
1919
IMAGES_TO_PRELOAD=(
20-
httpd:2.4.58
20+
docker.io/library/httpd:2.4.58
2121
"$COMMUNITY_OPERATOR_IMAGEREPO"/"$COMMUNITY_OPERATOR_BASE":"$COMMUNITY_OPERATOR_IMAGEVERSION"
2222
quay.io/testnetworkfunction/cnf-test-partner:latest
2323
quay.io/testnetworkfunction/debug-partner:latest
@@ -26,7 +26,6 @@ IMAGES_TO_PRELOAD=(
2626
quay.io/calico/node:v3.28.0
2727
quay.io/testnetworkfunction/nginx-operator-bundle:v0.0.1
2828
ghcr.io/k8snetworkplumbingwg/multus-cni:snapshot
29-
ghcr.io/k8snetworkplumbingwg/multus-cni:snapshot-thick
3029
registry.access.redhat.com/ubi9/ubi:latest
3130
registry.access.redhat.com/ubi9/ubi-minimal:latest
3231
quay.io/operator-framework/configmap-operator-registry:latest
@@ -37,6 +36,6 @@ IMAGES_TO_PRELOAD=(
3736

3837
# Preload images
3938
for image in "${IMAGES_TO_PRELOAD[@]}"; do
40-
docker pull "$image"
41-
kind load docker-image "$image"
39+
${CONTAINER_CLIENT} pull "$image"
40+
${CONTAINER_CLIENT} save "$image" -o image.tar && kind load image-archive image.tar && rm image.tar
4241
done

test-target/local-pod-under-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ spec:
2020
annotations:
2121
test-network-function.com/container_tests: '["PRIVILEGED_POD","PRIVILEGED_ROLE"]' # optional
2222
test-network-function.com/defaultnetworkinterface: '"eth0"' # optional
23-
k8s.v1.cni.cncf.io/networks: {{ MULTUS_ANNOTATION }}
23+
k8s.v1.cni.cncf.io/networks: '{{ MULTUS_ANNOTATION }}'
2424
name: test
2525
spec:
2626
terminationGracePeriodSeconds: 30

0 commit comments

Comments
 (0)