Home > Blockchain >  How can i install deleted default api service in kubernetes?
How can i install deleted default api service in kubernetes?

Time:12-05

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.

CodePudding user response:

you have accidentally deleted the v1.networking.k8s.io API service, which is used by the Kubernetes networking APIs. To undo this operation, you will need to recreate the API service by running the following command:

kubectl create apiservices.apiregistration.k8s.io v1.networking.k8s.io --service-name=networking.k8s.io

This should recreate the v1.networking.k8s.io API service, allowing you to use the networking APIs again. However, if you still cannot use the networking APIs, you may need to restart the kube-apiserver and kube-controller-manager processes on your Kubernetes cluster.

CodePudding user response:

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
  • Related