kubernetesnginx-ingresskubernetes-apiserver

How can i install deleted default api service in kubernetes?


I am on Kubernetes v1.22.13. When i was trying to delete a namespace that's stuck in status terminating, i deleted api-service v1.networking.k8s.io by mistake with:

kubectl delete apiservices.apiregistration.k8s.io v1.networking.k8s.io

And now i don't have crds related to v1.networking.k8s.io such as Ingress. When i try to install ingress-controller it gives the error:

error: resource mapping not found for name: "nginx" namespace: "" from "https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.4.0/deploy/static/provider/cloud/deploy.yaml": no matches for kind "IngressClass" in version "networking.k8s.io/v1"

How can i undo that operation? Or how can i bring back api-resource v1.networking.k8s.io?

Tried to find a way to undo it and install it manually but i couldn't find the manifest related to that.


Solution

  • You can recreate it via the following:

    cat <<EOF | kubectl apply -f -
    apiVersion: apiregistration.k8s.io/v1
    kind: APIService
    metadata:
      labels:
        kube-aggregator.kubernetes.io/automanaged: onstart
      name: v1.networking.k8s.io
    spec:
      group: networking.k8s.io
      groupPriorityMinimum: 17200
      version: v1
      versionPriority: 15
    EOF