kubectl expose deployment not working with ingress-controller

5/21/2021

I'm currently following a course on udemy called Microservices with Node JS and React from Stephen Grider, and I've come to a part where I need to run a command:

kubectl expose deployment ingress-nginx-controller --target-port=80 --type=NodePort -n kube-system

And this command is producing this error:

Error from server (NotFound): deployments.apps "ingress-nginx-controller" not found

when I run the command kubectl get deployments I do not see an ingress-nginx-controller deployment so I tried kubectl get namespace and I saw then entry ingress-nginx from that so I then tried kubectl get deployments -n ingress-nginx and then I finally see ingress-nginx-controller from output of that command. So I now know where the ingress-nginx-controller is but I am still pretty clueless as to how i get the initial command of kubectl explose deployment ingress-nginx-controller --target-port=80 --type=NodePort -n kube-system to work i've been stuck on this for a long time now any help is appreciated, thanks.

Edit 1: this is probably not relevant but I also tried putting ingress-nginx after the -n instead of kube-system and it did not work

Also I am using minikube on ubuntu

Edit 2: this is a screenshot of what the course wants me to do because I'm running minikube

-- Skyler Brandt
kubernetes
kubernetes-ingress
nginx-ingress

1 Answer

5/21/2021

The first time you ran it (with the correct namespace) it worked and you probably didn't notice. Your tutorial seems to be fairly out of date, you might want to find a newer one. If you want to remove the previously created service and do it again, kubectl delete service -n ingress-nginx ingress-nginx-controller.

-- coderanger
Source: StackOverflow