Error from server (NotFound): deployments.extensions "hello-node-64c578bdf8-jp7dt" not found

3/9/2019

I am trying to expose my pod

kubectl expose deployment hello-node-64c578bdf8-jp7dt --type=LoadBalancer --port=8080
Error from server (NotFound): deployments.extensions "hello-node-64c578bdf8-jp7dt" not found

These are my pods

kubectl get pods
NAME                              READY   STATUS             RESTARTS   AGE
hazelcast-76c4785db6-wnzsb        0/1     ImagePullBackOff   0          120m
hello-minikube-7bdc84f4b7-qfjv9   1/1     Running            0          113m
hello-node-64c578bdf8-jp7dt       1/1     Running            0          114m

My kubectl version

Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.4", GitCommit:"c27b913fddd1a6c480c229191a087698aa92f0b1", GitTreeState:"clean", BuildDate:"2019-02-28T13:37:52Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.4", GitCommit:"c27b913fddd1a6c480c229191a087698aa92f0b1", GitTreeState:"clean", BuildDate:"2019-02-28T13:30:26Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"}

What are these deployment extensions?

kubectl get deployments
NAME             READY   UP-TO-DATE   AVAILABLE   AGE
hazelcast        0/1     1            0           139m
hello-minikube   1/1     1            1           132m
hello-node       1/1     1            1           133m
-- Richard Rublev
kubernetes

2 Answers

3/9/2019

Get the deployment using:

kubectl get deployments

then use that name in expose command. maybe you are trying to expose the pod name

So the correct command is:

kubectl expose deployment hello-node --type=LoadBalancer --port=8080
-- Ijaz Ahmad Khan
Source: StackOverflow

4/8/2020

Get the deployment using :

kubectl get deployments --all-namespaces

NAMESPACE     NAME             READY   UP-TO-DATE   AVAILABLE   AGE
app           hello-node       1/1     1            1           22m

then use that name in expose command. maybe you are trying to expose the pod name

So the correct command is:

kubectl expose deployment hello-node --type=LoadBalancer --port=8080 -n app
-- Dali
Source: StackOverflow