Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions build/kubernetes/k8s_setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -v

# Install kubectl
Expand All @@ -11,9 +11,12 @@ curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND
kind create cluster --image kindest/node:${K8S_VERSION}

# Wait for cluster to be ready
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}';
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do
sleep 1;
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'
out=''
until [[ "${out}" =~ 'Ready=True' ]]; do
sleep 1
out=$(kubectl get nodes -o jsonpath="$JSONPATH")
Comment on lines +14 to +18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw here a better alternative for this logic?

echo "Waiting for cluster to be ready"
kubectl wait --for=condition=Ready nodes --all --timeout=60s >/dev/null 2>&1

AFAIK that is performing the same query? There script likewise calls kind create cluster just prior to this, but inlines a custom config:

echo "Creating Kind Cluster"
cat <<EOF | kind create cluster --config=- || exit 1
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  image: kindest/node:v${VERSION}
  extraPortMappings:
  - containerPort: 80
    hostPort: 80
    protocol: TCP
  - containerPort: 443
    hostPort: 443
    protocol: TCP
EOF

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that is better, thanks for the tip.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I already raised a PR for that change alone given the age of this PR 😅 (which doesn't inspire much hope for the PRs I raised for the CI to get merged)

echo "${out}"
Comment on lines +18 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably would have made it clear why this failure occurred (kubectl was XML instead of a binary which caused a 10m timeout failure)

done

# Scale the CoreDNS replicas to simplify testing
Expand Down