mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Fix shellcheck lint errors in test/kubemark/iks/startup.sh
This commit is contained in:
parent
6310305d3b
commit
e3e2a96521
@ -145,7 +145,6 @@
|
|||||||
./test/images/volume/rbd/create_block.sh
|
./test/images/volume/rbd/create_block.sh
|
||||||
./test/images/volume/rbd/mon.sh
|
./test/images/volume/rbd/mon.sh
|
||||||
./test/images/volume/rbd/osd.sh
|
./test/images/volume/rbd/osd.sh
|
||||||
./test/kubemark/iks/startup.sh
|
|
||||||
./test/kubemark/iks/util.sh
|
./test/kubemark/iks/util.sh
|
||||||
./test/kubemark/master-log-dump.sh
|
./test/kubemark/master-log-dump.sh
|
||||||
./test/kubemark/resources/start-kubemark-master.sh
|
./test/kubemark/resources/start-kubemark-master.sh
|
||||||
|
@ -25,7 +25,8 @@ RESOURCE_DIRECTORY="${KUBEMARK_DIRECTORY}/resources"
|
|||||||
# templates, and finally create these resources through kubectl.
|
# templates, and finally create these resources through kubectl.
|
||||||
function create-kube-hollow-node-resources {
|
function create-kube-hollow-node-resources {
|
||||||
# Create kubeconfig for Kubelet.
|
# Create kubeconfig for Kubelet.
|
||||||
KUBELET_KUBECONFIG_CONTENTS=$(echo "apiVersion: v1
|
KUBELET_KUBECONFIG_CONTENTS="$(cat <<EOF
|
||||||
|
apiVersion: v1
|
||||||
kind: Config
|
kind: Config
|
||||||
users:
|
users:
|
||||||
- name: kubelet
|
- name: kubelet
|
||||||
@ -42,10 +43,13 @@ contexts:
|
|||||||
cluster: kubemark
|
cluster: kubemark
|
||||||
user: kubelet
|
user: kubelet
|
||||||
name: kubemark-context
|
name: kubemark-context
|
||||||
current-context: kubemark-context")
|
current-context: kubemark-context
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
|
||||||
# Create kubeconfig for Kubeproxy.
|
# Create kubeconfig for Kubeproxy.
|
||||||
KUBEPROXY_KUBECONFIG_CONTENTS=$(echo "apiVersion: v1
|
KUBEPROXY_KUBECONFIG_CONTENTS="$(cat <<EOF
|
||||||
|
apiVersion: v1
|
||||||
kind: Config
|
kind: Config
|
||||||
users:
|
users:
|
||||||
- name: kube-proxy
|
- name: kube-proxy
|
||||||
@ -62,10 +66,13 @@ contexts:
|
|||||||
cluster: kubemark
|
cluster: kubemark
|
||||||
user: kube-proxy
|
user: kube-proxy
|
||||||
name: kubemark-context
|
name: kubemark-context
|
||||||
current-context: kubemark-context")
|
current-context: kubemark-context
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
|
||||||
# Create kubeconfig for Heapster.
|
# Create kubeconfig for Heapster.
|
||||||
HEAPSTER_KUBECONFIG_CONTENTS=$(echo "apiVersion: v1
|
HEAPSTER_KUBECONFIG_CONTENTS="$(cat <<EOF
|
||||||
|
apiVersion: v1
|
||||||
kind: Config
|
kind: Config
|
||||||
users:
|
users:
|
||||||
- name: heapster
|
- name: heapster
|
||||||
@ -82,10 +89,13 @@ contexts:
|
|||||||
cluster: kubemark
|
cluster: kubemark
|
||||||
user: heapster
|
user: heapster
|
||||||
name: kubemark-context
|
name: kubemark-context
|
||||||
current-context: kubemark-context")
|
current-context: kubemark-context
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
|
||||||
# Create kubeconfig for Cluster Autoscaler.
|
# Create kubeconfig for Cluster Autoscaler.
|
||||||
CLUSTER_AUTOSCALER_KUBECONFIG_CONTENTS=$(echo "apiVersion: v1
|
CLUSTER_AUTOSCALER_KUBECONFIG_CONTENTS="$(cat <<EOF
|
||||||
|
apiVersion: v1
|
||||||
kind: Config
|
kind: Config
|
||||||
users:
|
users:
|
||||||
- name: cluster-autoscaler
|
- name: cluster-autoscaler
|
||||||
@ -102,10 +112,13 @@ contexts:
|
|||||||
cluster: kubemark
|
cluster: kubemark
|
||||||
user: cluster-autoscaler
|
user: cluster-autoscaler
|
||||||
name: kubemark-context
|
name: kubemark-context
|
||||||
current-context: kubemark-context")
|
current-context: kubemark-context
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
|
||||||
# Create kubeconfig for NodeProblemDetector.
|
# Create kubeconfig for NodeProblemDetector.
|
||||||
NPD_KUBECONFIG_CONTENTS=$(echo "apiVersion: v1
|
NPD_KUBECONFIG_CONTENTS="$(cat <<EOF
|
||||||
|
apiVersion: v1
|
||||||
kind: Config
|
kind: Config
|
||||||
users:
|
users:
|
||||||
- name: node-problem-detector
|
- name: node-problem-detector
|
||||||
@ -122,10 +135,13 @@ contexts:
|
|||||||
cluster: kubemark
|
cluster: kubemark
|
||||||
user: node-problem-detector
|
user: node-problem-detector
|
||||||
name: kubemark-context
|
name: kubemark-context
|
||||||
current-context: kubemark-context")
|
current-context: kubemark-context
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
|
||||||
# Create kubeconfig for Kube DNS.
|
# Create kubeconfig for Kube DNS.
|
||||||
KUBE_DNS_KUBECONFIG_CONTENTS=$(echo "apiVersion: v1
|
KUBE_DNS_KUBECONFIG_CONTENTS="$(cat <<EOF
|
||||||
|
apiVersion: v1
|
||||||
kind: Config
|
kind: Config
|
||||||
users:
|
users:
|
||||||
- name: kube-dns
|
- name: kube-dns
|
||||||
@ -142,7 +158,9 @@ contexts:
|
|||||||
cluster: kubemark
|
cluster: kubemark
|
||||||
user: kube-dns
|
user: kube-dns
|
||||||
name: kubemark-context
|
name: kubemark-context
|
||||||
current-context: kubemark-context")
|
current-context: kubemark-context
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
|
||||||
# Create kubemark namespace.
|
# Create kubemark namespace.
|
||||||
spawn-config
|
spawn-config
|
||||||
@ -173,14 +191,14 @@ current-context: kubemark-context")
|
|||||||
mkdir -p "${RESOURCE_DIRECTORY}/addons"
|
mkdir -p "${RESOURCE_DIRECTORY}/addons"
|
||||||
sed "s/{{MASTER_IP}}/${MASTER_IP}/g" "${RESOURCE_DIRECTORY}/heapster_template.json" > "${RESOURCE_DIRECTORY}/addons/heapster.json"
|
sed "s/{{MASTER_IP}}/${MASTER_IP}/g" "${RESOURCE_DIRECTORY}/heapster_template.json" > "${RESOURCE_DIRECTORY}/addons/heapster.json"
|
||||||
metrics_mem_per_node=4
|
metrics_mem_per_node=4
|
||||||
metrics_mem=$((200 + ${metrics_mem_per_node}*${NUM_NODES}))
|
metrics_mem=$((200 + metrics_mem_per_node*NUM_NODES))
|
||||||
sed -i'' -e "s/{{METRICS_MEM}}/${metrics_mem}/g" "${RESOURCE_DIRECTORY}/addons/heapster.json"
|
sed -i'' -e "s/{{METRICS_MEM}}/${metrics_mem}/g" "${RESOURCE_DIRECTORY}/addons/heapster.json"
|
||||||
metrics_cpu_per_node_numerator=${NUM_NODES}
|
metrics_cpu_per_node_numerator=${NUM_NODES}
|
||||||
metrics_cpu_per_node_denominator=2
|
metrics_cpu_per_node_denominator=2
|
||||||
metrics_cpu=$((80 + metrics_cpu_per_node_numerator / metrics_cpu_per_node_denominator))
|
metrics_cpu=$((80 + metrics_cpu_per_node_numerator / metrics_cpu_per_node_denominator))
|
||||||
sed -i'' -e "s/{{METRICS_CPU}}/${metrics_cpu}/g" "${RESOURCE_DIRECTORY}/addons/heapster.json"
|
sed -i'' -e "s/{{METRICS_CPU}}/${metrics_cpu}/g" "${RESOURCE_DIRECTORY}/addons/heapster.json"
|
||||||
eventer_mem_per_node=500
|
eventer_mem_per_node=500
|
||||||
eventer_mem=$((200 * 1024 + ${eventer_mem_per_node}*${NUM_NODES}))
|
eventer_mem=$((200 * 1024 + eventer_mem_per_node*NUM_NODES))
|
||||||
sed -i'' -e "s/{{EVENTER_MEM}}/${eventer_mem}/g" "${RESOURCE_DIRECTORY}/addons/heapster.json"
|
sed -i'' -e "s/{{EVENTER_MEM}}/${eventer_mem}/g" "${RESOURCE_DIRECTORY}/addons/heapster.json"
|
||||||
|
|
||||||
# Cluster Autoscaler.
|
# Cluster Autoscaler.
|
||||||
@ -216,7 +234,7 @@ current-context: kubemark-context")
|
|||||||
proxy_cpu=50
|
proxy_cpu=50
|
||||||
fi
|
fi
|
||||||
proxy_mem_per_node=50
|
proxy_mem_per_node=50
|
||||||
proxy_mem=$((100 * 1024 + ${proxy_mem_per_node}*${NUM_NODES}))
|
proxy_mem=$((100 * 1024 + proxy_mem_per_node*NUM_NODES))
|
||||||
sed -i'' -e "s/{{HOLLOW_PROXY_CPU}}/${proxy_cpu}/g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
|
sed -i'' -e "s/{{HOLLOW_PROXY_CPU}}/${proxy_cpu}/g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
|
||||||
sed -i'' -e "s/{{HOLLOW_PROXY_MEM}}/${proxy_mem}/g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
|
sed -i'' -e "s/{{HOLLOW_PROXY_MEM}}/${proxy_mem}/g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
|
||||||
sed -i'' -e "s'{{kubemark_image_registry}}'${KUBEMARK_IMAGE_REGISTRY}${KUBE_NAMESPACE}'g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
|
sed -i'' -e "s'{{kubemark_image_registry}}'${KUBEMARK_IMAGE_REGISTRY}${KUBE_NAMESPACE}'g" "${RESOURCE_DIRECTORY}/hollow-node.yaml"
|
||||||
@ -236,8 +254,7 @@ function wait-for-hollow-nodes-to-run-or-timeout {
|
|||||||
echo -n "Waiting for all hollow-nodes to become Running"
|
echo -n "Waiting for all hollow-nodes to become Running"
|
||||||
start=$(date +%s)
|
start=$(date +%s)
|
||||||
nodes=$("${KUBECTL}" --kubeconfig="${KUBECONFIG}" get node 2> /dev/null) || true
|
nodes=$("${KUBECTL}" --kubeconfig="${KUBECONFIG}" get node 2> /dev/null) || true
|
||||||
ready=$(($(echo "${nodes}" | grep -v "NotReady" | wc -l) - 1))
|
ready=$(($(echo "${nodes}" | grep -vc "NotReady") - 1))
|
||||||
|
|
||||||
until [[ "${ready}" -ge "${NUM_REPLICAS}" ]]; do
|
until [[ "${ready}" -ge "${NUM_REPLICAS}" ]]; do
|
||||||
echo -n "."
|
echo -n "."
|
||||||
sleep 1
|
sleep 1
|
||||||
@ -245,6 +262,7 @@ function wait-for-hollow-nodes-to-run-or-timeout {
|
|||||||
# Fail it if it already took more than 30 minutes.
|
# Fail it if it already took more than 30 minutes.
|
||||||
if [ $((now - start)) -gt 1800 ]; then
|
if [ $((now - start)) -gt 1800 ]; then
|
||||||
echo ""
|
echo ""
|
||||||
|
# shellcheck disable=SC2154 # Color defined in sourced script
|
||||||
echo -e "${color_red} Timeout waiting for all hollow-nodes to become Running. ${color_norm}"
|
echo -e "${color_red} Timeout waiting for all hollow-nodes to become Running. ${color_norm}"
|
||||||
# Try listing nodes again - if it fails it means that API server is not responding
|
# Try listing nodes again - if it fails it means that API server is not responding
|
||||||
if "${KUBECTL}" --kubeconfig="${KUBECONFIG}" get node &> /dev/null; then
|
if "${KUBECTL}" --kubeconfig="${KUBECONFIG}" get node &> /dev/null; then
|
||||||
@ -254,16 +272,17 @@ function wait-for-hollow-nodes-to-run-or-timeout {
|
|||||||
fi
|
fi
|
||||||
spawn-config
|
spawn-config
|
||||||
pods=$("${KUBECTL}" get pods -l name=hollow-node --namespace=kubemark) || true
|
pods=$("${KUBECTL}" get pods -l name=hollow-node --namespace=kubemark) || true
|
||||||
running=$(($(echo "${pods}" | grep "Running" | wc -l)))
|
running=$(($(echo "${pods}" | grep -c "Running")))
|
||||||
echo "${running} hollow-nodes are reported as 'Running'"
|
echo "${running} hollow-nodes are reported as 'Running'"
|
||||||
not_running=$(($(echo "${pods}" | grep -v "Running" | wc -l) - 1))
|
not_running=$(($(echo "${pods}" | grep -vc "Running") - 1))
|
||||||
echo "${not_running} hollow-nodes are reported as NOT 'Running'"
|
echo "${not_running} hollow-nodes are reported as NOT 'Running'"
|
||||||
echo $(echo "${pods}" | grep -v "Running")
|
echo "${pods}" | grep -v "Running"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
nodes=$("${KUBECTL}" --kubeconfig="${KUBECONFIG}" get node 2> /dev/null) || true
|
nodes=$("${KUBECTL}" --kubeconfig="${KUBECONFIG}" get node 2> /dev/null) || true
|
||||||
ready=$(($(echo "${nodes}" | grep -v "NotReady" | wc -l) - 1))
|
ready=$(($(echo "${nodes}" | grep -vc "NotReady") - 1))
|
||||||
done
|
done
|
||||||
|
# shellcheck disable=SC2154 # Color defined in sourced script
|
||||||
echo -e "${color_green} Done!${color_norm}"
|
echo -e "${color_green} Done!${color_norm}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,14 +300,17 @@ set-hollow-master
|
|||||||
echo "Creating kube hollow node resources"
|
echo "Creating kube hollow node resources"
|
||||||
create-kube-hollow-node-resources
|
create-kube-hollow-node-resources
|
||||||
master-config
|
master-config
|
||||||
|
# shellcheck disable=SC2154 # Color defined in sourced script
|
||||||
echo -e "${color_blue}EXECUTION COMPLETE${color_norm}"
|
echo -e "${color_blue}EXECUTION COMPLETE${color_norm}"
|
||||||
|
|
||||||
# Check status of Kubemark
|
# Check status of Kubemark
|
||||||
|
# shellcheck disable=SC2154 # Color defined in sourced script
|
||||||
echo -e "${color_yellow}CHECKING STATUS${color_norm}"
|
echo -e "${color_yellow}CHECKING STATUS${color_norm}"
|
||||||
wait-for-hollow-nodes-to-run-or-timeout
|
wait-for-hollow-nodes-to-run-or-timeout
|
||||||
|
|
||||||
# Celebrate
|
# Celebrate
|
||||||
echo ""
|
echo ""
|
||||||
|
# shellcheck disable=SC2154 # Color defined in sourced script
|
||||||
echo -e "${color_blue}SUCCESS${color_norm}"
|
echo -e "${color_blue}SUCCESS${color_norm}"
|
||||||
clean-repo
|
clean-repo
|
||||||
exit 0
|
exit 0
|
Loading…
Reference in New Issue
Block a user