diff --git a/exam b/exam index 7ae0513..b7c32a6 100755 --- a/exam +++ b/exam @@ -127,6 +127,15 @@ ensure_etcd_tools() { nx "$CP" 'command -v etcdctl >/dev/null 2>&1 && command -v etcdutl >/dev/null 2>&1' the Gateway API CRDs (standard channel), which kind does not ship. Q56 and +# Q74 need them at seed time; a cluster rebuilt by ./setup.sh has none until one of them installs it. +ensure_gateway_crds() { + $K get crd gateways.gateway.networking.k8s.io >/dev/null 2>&1 && return 0 + curl -sfL --max-time 60 https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.1/standard-install.yaml -o /tmp/gwapi.yaml \ + && $K apply -f /tmp/gwapi.yaml >/dev/null 2>&1 \ + && $K wait --for=condition=Established --timeout=60s crd/gatewayclasses.gateway.networking.k8s.io \ + crd/gateways.gateway.networking.k8s.io crd/httproutes.gateway.networking.k8s.io >/dev/null 2>&1 +} """ def _pick_track_arg(argv): diff --git a/tracks/cka/bank_hard.py b/tracks/cka/bank_hard.py index 611f325..12a6420 100644 --- a/tracks/cka/bank_hard.py +++ b/tracks/cka/bank_hard.py @@ -531,7 +531,7 @@ Create in `%{ns}`: "params_post": None, "setup": NS + r""" mkns %{ns} -$K get crd gateways.gateway.networking.k8s.io >/dev/null 2>&1 || { curl -sfL --max-time 60 https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.1/standard-install.yaml -o /tmp/gwapi.yaml && $K apply -f /tmp/gwapi.yaml >/dev/null 2>&1; } || echo "warn: could not install Gateway API CRDs" +ensure_gateway_crds || echo "warn: could not install the Gateway API CRDs (no network?) - the task needs them" for v in v1 v2; do $K -n %{ns} create deploy $v --image=nginx:1.25 --port=80 --dry-run=client -o yaml | $K apply -f - >/dev/null; $K -n %{ns} expose deploy $v --port=80 --dry-run=client -o yaml | $K apply -f - >/dev/null; done $K delete gatewayclass %{host}-gc --ignore-not-found >/dev/null 2>&1; $K -n %{ns} delete gateway %{host}-gw --ignore-not-found >/dev/null 2>&1; $K -n %{ns} delete httproute %{host}-route --ignore-not-found >/dev/null 2>&1 """, diff --git a/tracks/cka/bank_sim_c.py b/tracks/cka/bank_sim_c.py index 221e2bc..2e62cfc 100644 --- a/tracks/cka/bank_sim_c.py +++ b/tracks/cka/bank_sim_c.py @@ -480,6 +480,7 @@ for v in v1 v2; do $K -n fleet-ops create deploy fleet-dashboard-$v --image=nginx:1.27 --port=80 --dry-run=client -o yaml | $K apply -f - >/dev/null $K -n fleet-ops expose deploy fleet-dashboard-$v --port=80 --target-port=80 --dry-run=client -o yaml | $K apply -f - >/dev/null done +ensure_gateway_crds || { echo "no Gateway API CRDs and could not download them (no network?) - install them, then re-seed"; exit 1; } $K apply -f - >/dev/null <<'EOF' apiVersion: gateway.networking.k8s.io/v1 kind: GatewayClass