Skip to content

Kourier installation fails on Kind with "no matching resources found" — kubectl wait doesn't wait for pods to appear #668

Description

@kekhuai

Bug description

kn quickstart kind --registry fails intermittently during Kourier installation:

🕸️ Installing Kourier networking layer v1.22.0 ...
error: no matching resources found

Error: failed to install kourier to kind cluster knative: kourier: exit status 1

Root cause

The waitForPodsReady function in pkg/install/install.go uses kubectl wait which fails immediately when no pods match the selector — even with --timeout set:

func waitForPodsReady(ns string) error {
    return runCommand(exec.Command("kubectl", "wait", "pod",
        "--timeout=10m", "--for=condition=Ready",
        "-l", "!job-name", "-n", ns))
}

kubectl wait only waits for existing resources to meet a condition. When no pods exist yet (deployment controller still reconciling), it exits immediately with exit code 1.

Sequence

  1. retryingApply applies kourier.yaml → deployments created
  2. waitForPodsReady("kourier-system") called immediately
  3. 3scale-kourier-gateway pod hasn't been created yet
  4. kubectl wait exits instantly: error: no matching resources found
  5. Installation fails

Reproducibility

This is a race condition — reproduces when pod creation is slower than code execution. Confirmed with:

kubectl wait pod --timeout=5s --for=condition=Ready -l '!job-name' -n kourier-system
# error: no matching resources found (exit 1)

Environment

  • kn-quickstart: v1.22.0
  • Kind: 0.32.0
  • Kubernetes: v1.36.1 (kindest/node:v1.36.1)
  • kubectl: v1.36.2
  • OS: macOS

Suggested fix

Add a retry loop to waitForPodsReady that handles the "no matching resources found" case:

func waitForPodsReady(ns string) error {
    cmd := exec.Command("kubectl", "wait", "pod",
        "--timeout=10m", "--for=condition=Ready",
        "-l", "!job-name", "-n", ns)
    for i := 0; i < 6; i++ {
        if err := runCommand(cmd); err == nil {
            return nil
        }
        time.Sleep(10 * time.Second)
    }
    return fmt.Errorf("timeout waiting for pods in %s", ns)
}

Or alternatively, use kubectl wait --for=condition=Available deployment/<name> first, which properly handles the deployment lifecycle.

Note

The same latent bug exists in the waitForPodsReady("knative-serving") call in Kourier() and all three calls in Eventing(), but those are less likely to trigger because pods in those namespaces are typically already created by earlier steps.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions