Skip to content

Commit fadea32

Browse files
authored
chore: k8s_setup.sh should use kubectl wait
It's been over 5 years since the current logic to wait on clusters was contributed. Better to use `kubectl wait` now. This will also better convey failure when `kubectl` is not a valid binary. Signed-off-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
1 parent c05e817 commit fadea32

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

build/kubernetes/k8s_setup.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,17 @@ curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND
1111
kind create cluster --image kindest/node:${K8S_VERSION}
1212

1313
# Wait for cluster to be ready
14-
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}';
15-
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do
16-
sleep 1;
17-
done
14+
kubectl wait --for=condition=Ready nodes --all --timeout=60s >/dev/null 2>&1
1815

1916
# Scale the CoreDNS replicas to simplify testing
2017
kubectl scale -n kube-system deployment/coredns --replicas=1
2118

2219
# Patch CoreDNS deployment to use local coredns image
23-
kubectl patch deployment coredns -n kube-system -p "$(cat ~/go/src/${CIRCLE_PROJECT_USERNAME}/ci/build/kubernetes/coredns_deployment_patch.yaml)"
20+
kubectl patch deployment coredns -n kube-system -p "$(cat "~/go/src/${CIRCLE_PROJECT_USERNAME}/ci/build/kubernetes/coredns_deployment_patch.yaml")"
2421

2522
# Patch CoreDNS clusterRoles to allow list/watch of EndpointSlice.
2623
# Remove this once EndpointSlice is part of the default CoreDNS clusterRoles.
27-
kubectl patch clusterroles system:coredns -n kube-system -p "$(cat ~/go/src/${CIRCLE_PROJECT_USERNAME}/ci/build/kubernetes/coredns_clusterroles_patch.yaml)"
24+
kubectl patch clusterroles system:coredns -n kube-system -p "$(cat "~/go/src/${CIRCLE_PROJECT_USERNAME}/ci/build/kubernetes/coredns_clusterroles_patch.yaml")"
2825

2926
# Deploy test objects
30-
kubectl create -f ~/go/src/${CIRCLE_PROJECT_USERNAME}/ci/build/kubernetes/dns-test.yaml
27+
kubectl create -f "~/go/src/${CIRCLE_PROJECT_USERNAME}/ci/build/kubernetes/dns-test.yaml"

0 commit comments

Comments
 (0)