Chris G.
Chris G.

Reputation: 25974

kubectl wait - error: no matching resources found

I am installing metallb, but need to wait for resources to be created.

kubectl wait --for=condition=ready --timeout=60s -n metallb-system --all pods

But I get:

error: no matching resources found

If I dont wait I get:

Error from server (InternalError): error when creating "STDIN": Internal error occurred: failed calling webhook "ipaddresspoolvalidationwebhook.metallb.io": failed to call webhook: Post "https://webhook-service.metallb-system.svc:443/validate-metallb-io-v1beta1-ipaddresspool?timeout=10s": dial tcp 10.106.91.126:443: connect: connection refused

Do you know how to wait for resources to be created before actually be able to wait for condition.

Info:

kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.4", GitCommit:"872a965c6c6526caa949f0c6ac028ef7aff3fb78", GitTreeState:"clean", BuildDate:"2022-11-09T13:36:36Z", GoVersion:"go1.19.3", Compiler:"gc", Platform:"linux/arm64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.4", GitCommit:"872a965c6c6526caa949f0c6ac028ef7aff3fb78", GitTreeState:"clean", BuildDate:"2022-11-09T13:29:58Z", GoVersion:"go1.19.3", Compiler:"gc", Platform:"linux/arm64"}

Upvotes: 1

Views: 1350

Answers (2)

Davy Machado
Davy Machado

Reputation: 11

In my case, I got this error because I was trying to install metallb in the control-plane before worker nodes joining.

The metallb speaker component (daemonset) has tolerations for master and control-plane that avoid the schedule.

...
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    app: metallb
    component: speaker
  name: speaker
  namespace: metallb-system
spec:
...
      tolerations:
      - effect: NoSchedule
        key: node-role.kubernetes.io/master
        operator: Exists
      - effect: NoSchedule
        key: node-role.kubernetes.io/control-plane
        operator: Exists

So, I move the metallb install commands to the worker nodes provisioner script and the problem was solved.

echo "[INFO] Installing MetalLB..."
if ! (sudo kubectl get namespace metallb-system &>/dev/null); then
    sudo kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.7/config/manifests/metallb-native.yaml
    sudo kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"

    echo "[INFO] Waiting for MetalLB pods to be ready..."
    sudo kubectl wait --namespace metallb-system \
    --for=condition=ready pod \
    --selector=app=metallb \
    --timeout=120s

    echo "[INFO] Configuring MetalLB..."
    cat <<EOF | sudo kubectl apply -f -
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: metallb-ip-adress-pool
  namespace: metallb-system
spec:
  addresses:
  - 192.168.56.100-192.168.56.110
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: metallb-l2-advertisement
  namespace: metallb-system
EOF
else
    echo "[INFO] MetalLB already configured"
fi

Upvotes: 0

Veera Nagireddy
Veera Nagireddy

Reputation: 1894

For the error “no matching resources found”:

Wait for a minute and try again, It will be resolved.

You can find the explanation about that error in the following link Setting up Config Connector

For the error STDIN:

Follow the steps mentioned below:

You are getting this error because API server is NOT able to connect to the webhook

1)Check your Firewall Rules allowing TCP port 443 or not.

2)Temporarily disable the operator

  kubectl -n config-management-system scale deployment config-management-operator --replicas=0
    deployment.apps/config-management-operator scaled

Delete the deployment

kubectl delete deployments.apps  -n <namespace> -system <namespace>-controller-manager
deployment.apps "namespace-controller-manager" deleted

3)create a configmap in the default namespace

kubectl create configmap foo
configmap/foo created

4)Check that configmap does not work with the label on the object

cat <<EOF | kubectl create -f -
apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    configmanagement.gke.io/debug-force-validation-webhook: "true"
  name: foo
EOF

Error from server (InternalError): error when creating "STDIN": Internal error occurred: failed calling webhook "debug-validation.namespace.sh": failed to call webhook: Post "https://namespace-webhook-service.namespace-system.svc:443/v1/admit?timeout=3s": no endpoints available for service "namespace-webhook-service"

5)And finally do clean up by using the below commands :

kubectl delete configmap foo
configmap "foo" deleted

kubectl -n config-management-system scale deployment config-management-operator --replicas=1
deployment.apps/config-management-operator scaled

Upvotes: 1

Related Questions