@@ -8,16 +8,30 @@ source "$SCRIPT_DIR"/init-env.sh
88
99mkdir -p ./temp
1010
11+ REPLICAS=2
12+ # adjust replicas for possible SNO clusters
13+ NUM_NODES=$( oc get nodes --no-headers | wc -l)
14+ if [[ $NUM_NODES == 1 ]]; then
15+ REPLICAS=1
16+ fi
17+
1118# shellcheck disable=SC2002 # Useless cat.
12- cat ./test-target/local-pod-under-test.yaml | APP=" testss" RESOURCE_TYPE=" StatefulSet" MULTUS_ANNOTATION=$MULTUS_ANNOTATION " $SCRIPT_DIR " /mo > ./temp/rendered-local-statefulset-pod-under-test-template.yaml
19+ cat ./test-target/local-pod-under-test.yaml | APP=" testss" RESOURCE_TYPE=" StatefulSet" MULTUS_ANNOTATION=$MULTUS_ANNOTATION REPLICAS= $REPLICAS " $SCRIPT_DIR " /mo > ./temp/rendered-local-statefulset-pod-under-test-template.yaml
1320oc apply --filename ./temp/rendered-local-statefulset-pod-under-test-template.yaml
1421rm ./temp/rendered-local-statefulset-pod-under-test-template.yaml
1522sleep 3
1623
1724oc wait -l statefulset.kubernetes.io/pod-name=test-0 -n " $TNF_EXAMPLE_CNF_NAMESPACE " --for=condition=ready pod --timeout=" $TNF_DEPLOYMENT_TIMEOUT "
18- oc wait -l statefulset.kubernetes.io/pod-name=test-1 -n " $TNF_EXAMPLE_CNF_NAMESPACE " --for=condition=ready pod --timeout=" $TNF_DEPLOYMENT_TIMEOUT "
1925
20- # Check for existing HPA first
21- if ! oc get hpa test -n " $TNF_EXAMPLE_CNF_NAMESPACE " ; then
22- oc autoscale statefulset test -n " $TNF_EXAMPLE_CNF_NAMESPACE " --cpu-percent=50 --min=2 --max=3
26+ # Wait if there is more than one replica
27+ if [[ $REPLICAS -gt 1 ]]; then
28+ oc wait -l statefulset.kubernetes.io/pod-name=test-1 -n " $TNF_EXAMPLE_CNF_NAMESPACE " --for=condition=ready pod --timeout=" $TNF_DEPLOYMENT_TIMEOUT "
29+ fi
30+
31+ # Only autoscale if there is more than one replica
32+ if [[ $REPLICAS -gt 1 ]]; then
33+ # Check for existing HPA first
34+ if ! oc get hpa test -n " $TNF_EXAMPLE_CNF_NAMESPACE " ; then
35+ oc autoscale statefulset test -n " $TNF_EXAMPLE_CNF_NAMESPACE " --cpu-percent=50 --min=2 --max=3
36+ fi
2337fi
0 commit comments