Skip to content

Commit 9b437f9

Browse files
authored
Merge pull request kubernetes#76909 from Huang-Wei/fix-iks-kubemark
kubemark: fix and enhance kubemark scripts for IKS
2 parents 74a7026 + fbec01d commit 9b437f9

File tree

3 files changed

+47
-34
lines changed

3 files changed

+47
-34
lines changed

cluster/kubemark/iks/config-default.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,16 @@ CLUSTER_LOCATION="${CLUSTER_LOCATION:-wdc06}"
2525
REGISTRY_LOGIN_URL="${REGISTRY_LOGIN_URL:-https://api.ng.bluemix.net}"
2626

2727
# User defined
28+
# number of real workers in spawnTester cluster
2829
NUM_NODES="${NUM_NODES:-2}"
30+
# spec of real workers in spawnTester cluster
31+
NODE_SIZE=${NODE_SIZE:-u2c.2x4}
2932
DESIRED_NODES="${DESIRED_NODES:-10}"
33+
# number of hollow nodes
34+
# TODO: once IKS supports `kubetest`, i.e. the base cluster provisioning implemented in `kubetest`
35+
# we can use NUM_NODES=${KUBEMARK_NUM_NODES:-10} to avoid usage of KUBEMARK_NUM_NODES
36+
# more context, see https://github.com/kubernetes/kubernetes/pull/76909#discussion_r277735942
37+
KUBEMARK_NUM_NODES="${KUBEMARK_NUM_NODES:-10}"
3038
ENABLE_KUBEMARK_CLUSTER_AUTOSCALER="${ENABLE_KUBEMARK_CLUSTER_AUTOSCALER:-true}"
3139
ENABLE_KUBEMARK_KUBE_DNS="${ENABLE_KUBEMARK_KUBE_DNS:-false}"
3240
KUBELET_TEST_LOG_LEVEL="${KUBELET_TEST_LOG_LEVEL:-"--v=2"}"

test/kubemark/iks/startup.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ EOF
227227

228228
# Create the replication controller for hollow-nodes.
229229
# We allow to override the NUM_REPLICAS when running Cluster Autoscaler.
230-
NUM_REPLICAS=${NUM_REPLICAS:-${NUM_NODES}}
230+
NUM_REPLICAS=${NUM_REPLICAS:-${KUBEMARK_NUM_NODES}}
231231
sed "s/{{numreplicas}}/${NUM_REPLICAS}/g" "${RESOURCE_DIRECTORY}/hollow-node_template.yaml" > "${RESOURCE_DIRECTORY}/hollow-node.yaml"
232232
proxy_cpu=20
233233
if [ "${NUM_NODES}" -gt 1000 ]; then
@@ -240,9 +240,8 @@ EOF
240240
sed -i'' -e "s'{{kubemark_image_registry}}'${KUBEMARK_IMAGE_REGISTRY}${KUBE_NAMESPACE}'g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
241241
sed -i'' -e "s/{{kubemark_image_tag}}/${KUBEMARK_IMAGE_TAG}/g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
242242
sed -i'' -e "s/{{master_ip}}/${MASTER_IP}/g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
243-
sed -i'' -e "s/{{kubelet_verbosity_level}}/${KUBELET_TEST_LOG_LEVEL}/g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
244-
sed -i'' -e "s/{{kubeproxy_verbosity_level}}/${KUBEPROXY_TEST_LOG_LEVEL}/g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
245-
sed -i'' -e "s/{{use_real_proxier}}/${USE_REAL_PROXIER}/g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
243+
sed -i'' -e "s/{{hollow_kubelet_params}}/${HOLLOW_KUBELET_TEST_ARGS:-}/g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
244+
sed -i'' -e "s/{{hollow_proxy_params}}/${HOLLOW_PROXY_TEST_ARGS:-}/g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
246245
sed -i'' -e "s'{{kubemark_mig_config}}'${KUBEMARK_MIG_CONFIG:-}'g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
247246
"${KUBECTL}" create -f "${RESOURCE_DIRECTORY}/hollow-node.yaml" --namespace="kubemark"
248247

@@ -253,7 +252,8 @@ EOF
253252
function wait-for-hollow-nodes-to-run-or-timeout {
254253
echo -n "Waiting for all hollow-nodes to become Running"
255254
start=$(date +%s)
256-
nodes=$("${KUBECTL}" --kubeconfig="${KUBECONFIG}" get node 2> /dev/null) || true
255+
# IKS uses a real cluster for hollow master, so need to exclude the real worker nodes
256+
nodes=$("${KUBECTL}" --kubeconfig="${KUBECONFIG}" get node | grep hollow-node 2> /dev/null) || true
257257
ready=$(($(echo "${nodes}" | grep -vc "NotReady") - 1))
258258
until [[ "${ready}" -ge "${NUM_REPLICAS}" ]]; do
259259
echo -n "."

test/kubemark/iks/util.sh

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,44 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../../..
2020
function create-clusters {
2121
# shellcheck disable=SC2154 # Color defined in sourced script
2222
echo -e "${color_yellow}CHECKING CLUSTERS${color_norm}"
23-
if bx cs clusters | grep -Fq 'deleting'; then
23+
if ibmcloud ks clusters | grep -Fq 'deleting'; then
2424
echo -n "Deleting old clusters"
2525
fi
26-
while bx cs clusters | grep -Fq 'deleting'
26+
while ibmcloud ks clusters | grep -Fq 'deleting'
2727
do
2828
echo -n "."
2929
sleep 10
3030
done
3131
echo ""
32-
bx cs region-set us-east >/dev/null
33-
bx cs vlans wdc06 >/dev/null
34-
PRIVLAN=$(bx cs vlans wdc06 --json | jq '. | .[] | select(.type == "private") | .id' | sed -e "s/\"//g")
35-
PUBVLAN=$(bx cs vlans wdc06 --json | jq '. | .[] | select(.type == "public") | .id' | sed -e "s/\"//g")
36-
if ! bx cs clusters | grep -Fq 'kubeSpawnTester'; then
32+
ibmcloud ks region-set us-east >/dev/null
33+
ibmcloud ks vlans wdc06 >/dev/null
34+
PRIVLAN=$(ibmcloud ks vlans wdc06 --json | jq '. | .[] | select(.type == "private") | .id' | sed -e "s/\"//g")
35+
PUBVLAN=$(ibmcloud ks vlans wdc06 --json | jq '. | .[] | select(.type == "public") | .id' | sed -e "s/\"//g")
36+
if ! ibmcloud ks clusters | grep -Fq 'kubeSpawnTester'; then
3737
echo "Creating spawning cluster"
38-
bx cs cluster-create --location "${CLUSTER_LOCATION}" --public-vlan "${PUBVLAN}" --private-vlan "${PRIVLAN}" --workers 2 --machine-type u2c.2x4 --name kubeSpawnTester
38+
# make number and spec of node workers configurable
39+
# otherwise it can't afford tests like kubemark-5000
40+
# TODO: dynamically adjust the number and spec
41+
ibmcloud ks cluster-create --location "${CLUSTER_LOCATION}" --public-vlan "${PUBVLAN}" --private-vlan "${PRIVLAN}" --workers "${NUM_NODES:-2}" --machine-type "${NODE_SIZE}" --name kubeSpawnTester
3942
fi
40-
if ! bx cs clusters | grep -Fq 'kubeMasterTester'; then
43+
if ! ibmcloud ks clusters | grep -Fq 'kubeMasterTester'; then
4144
echo "Creating master cluster"
42-
bx cs cluster-create --location "${CLUSTER_LOCATION}" --public-vlan "${PUBVLAN}" --private-vlan "${PRIVLAN}" --workers 2 --machine-type u2c.2x4 --name kubeMasterTester
45+
# if we can't make it a bare master (workers = 0)
46+
# then make workers = 1 with the smallest machine spec
47+
ibmcloud ks cluster-create --location "${CLUSTER_LOCATION}" --public-vlan "${PUBVLAN}" --private-vlan "${PRIVLAN}" --workers 1 --machine-type u2c.2x4 --name kubeMasterTester
4348
fi
4449
push-image
45-
if ! bx cs clusters | grep 'kubeSpawnTester' | grep -Fq 'normal'; then
50+
if ! ibmcloud ks clusters | grep 'kubeSpawnTester' | grep -Fq 'normal'; then
4651
# shellcheck disable=SC2154 # Color defined in sourced script
4752
echo -e "${color_cyan}Warning: new clusters may take up to 60 minutes to be ready${color_norm}"
4853
echo -n "Clusters loading"
4954
fi
50-
while ! bx cs clusters | grep 'kubeSpawnTester' | grep -Fq 'normal'
55+
while ! ibmcloud ks clusters | grep 'kubeSpawnTester' | grep -Fq 'normal'
5156
do
5257
echo -n "."
5358
sleep 5
5459
done
55-
while ! bx cs clusters | grep 'kubeMasterTester' | grep -Fq 'normal'
60+
while ! ibmcloud ks clusters | grep 'kubeMasterTester' | grep -Fq 'normal'
5661
do
5762
echo -n "."
5863
sleep 5
@@ -63,17 +68,17 @@ function create-clusters {
6368
# Builds and pushes image to registry
6469
function push-image {
6570
if [[ "${ISBUILD}" = "y" ]]; then
66-
if ! bx cr namespaces | grep -Fq "${KUBE_NAMESPACE}"; then
71+
if ! ibmcloud cr namespaces | grep -Fq "${KUBE_NAMESPACE}"; then
6772
echo "Creating registry namespace"
68-
bx cr namespace-add "${KUBE_NAMESPACE}"
69-
echo "bx cr namespace-rm ${KUBE_NAMESPACE}" >> "${RESOURCE_DIRECTORY}/iks-namespacelist.sh"
73+
ibmcloud cr namespace-add "${KUBE_NAMESPACE}"
74+
echo "ibmcloud cr namespace-rm ${KUBE_NAMESPACE}" >> "${RESOURCE_DIRECTORY}/iks-namespacelist.sh"
7075
fi
7176
docker build -t "${KUBEMARK_INIT_TAG}" "${KUBEMARK_IMAGE_LOCATION}"
7277
docker tag "${KUBEMARK_INIT_TAG}" "${KUBEMARK_IMAGE_REGISTRY}${KUBE_NAMESPACE}/${PROJECT}:${KUBEMARK_IMAGE_TAG}"
7378
docker push "${KUBEMARK_IMAGE_REGISTRY}${KUBE_NAMESPACE}/${PROJECT}:${KUBEMARK_IMAGE_TAG}"
7479
echo "Image pushed"
7580
else
76-
KUBEMARK_IMAGE_REGISTRY="brandondr96"
81+
KUBEMARK_IMAGE_REGISTRY="${KUBEMARK_IMAGE_REGISTRY:-brandondr96}"
7782
KUBE_NAMESPACE=""
7883
fi
7984
}
@@ -122,7 +127,7 @@ function master-config {
122127
if [[ "${USE_EXISTING}" = "y" ]]; then
123128
export KUBECONFIG=${CUSTOM_MASTER_CONFIG}
124129
else
125-
eval "$(bx cs cluster-config kubeMasterTester --admin | grep export)"
130+
eval "$(ibmcloud ks cluster-config kubeMasterTester --admin | grep export)"
126131
fi
127132
}
128133

@@ -133,20 +138,20 @@ function spawn-config {
133138
if [[ "${USE_EXISTING}" = "y" ]]; then
134139
export KUBECONFIG=${CUSTOM_SPAWN_CONFIG}
135140
else
136-
eval "$(bx cs cluster-config kubeSpawnTester --admin | grep export)"
141+
eval "$(ibmcloud ks cluster-config kubeSpawnTester --admin | grep export)"
137142
fi
138143
}
139144

140145
# Deletes existing clusters
141146
function delete-clusters {
142147
echo "DELETING CLUSTERS"
143-
bx cs cluster-rm kubeSpawnTester
144-
bx cs cluster-rm kubeMasterTester
145-
while ! bx cs clusters | grep 'kubeSpawnTester' | grep -Fq 'deleting'
146-
do
147-
sleep 5
148-
done
149-
while ! bx cs clusters | grep 'kubeMasterTester' | grep -Fq 'deleting'
148+
ibmcloud ks cluster-rm kubeSpawnTester
149+
ibmcloud ks cluster-rm kubeMasterTester
150+
while ! ibmcloud ks clusters | grep 'kubeSpawnTester' | grep -Fq 'deleting'
151+
do
152+
sleep 5
153+
done
154+
while ! ibmcloud ks clusters | grep 'kubeMasterTester' | grep -Fq 'deleting'
150155
do
151156
sleep 5
152157
done
@@ -159,14 +164,14 @@ function complete-login {
159164
echo -n -e "Do you have a federated IBM cloud login? [y/N]${color_cyan}>${color_norm} "
160165
read -r ISFED
161166
if [[ "${ISFED}" = "y" ]]; then
162-
bx login --sso -a "${REGISTRY_LOGIN_URL}"
167+
ibmcloud login --sso -a "${REGISTRY_LOGIN_URL}"
163168
elif [[ "${ISFED}" = "N" ]]; then
164-
bx login -a "${REGISTRY_LOGIN_URL}"
169+
ibmcloud login -a "${REGISTRY_LOGIN_URL}"
165170
else
166171
echo -e "${color_red}Invalid response, please try again:${color_norm}"
167172
complete-login
168173
fi
169-
bx cr login
174+
ibmcloud cr login
170175
}
171176

172177
# Generate values to fill the hollow-node configuration templates.

0 commit comments

Comments
 (0)