Skip to content

Commit

Permalink
Add support for deploying test k8s cluster on arm64 architectures
Browse files Browse the repository at this point in the history
  • Loading branch information
edcdavid committed May 15, 2024
1 parent 3c029e5 commit 3f47951
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
6 changes: 3 additions & 3 deletions scripts/deploy-cr-scale-operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions scripts/deploy-multus-network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions scripts/deploy-statefulset-test-pods.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions scripts/deploy-test-pods.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions scripts/init-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ else
fi

# Container executable
TNF_CONTAINER_CLIENT="docker"
export CONTAINER_CLIENT="${CONTAINER_EXECUTABLE:-$TNF_CONTAINER_CLIENT}"

# Test Namespace
Expand Down Expand Up @@ -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'
Expand All @@ -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"
9 changes: 4 additions & 5 deletions scripts/preload-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion test-target/local-pod-under-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3f47951

Please sign in to comment.