Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop kubectl proxy

Tags:

I executed below command:

kubectl proxy --port=8081 & kubectl proxy --port=8082 & 

and of course I have 2 accessible endpoints:

curl http://localhost:8081/api/ curl http://localhost:8082/api/ 

But in the same time two running processes serving the same content. How to stop one of these processes in "kubectl" manner? Of course, I can kill the process but it seems to be a less elegant way...

like image 253
itiic Avatar asked Sep 19 '17 13:09

itiic


People also ask

How do I stop Kubernetes proxy?

There is no way to stop it other than kill or ^C (if not in background).

What is kubectl proxy command?

kubectl proxy –www=/my/files –www-prefix=/static/ –api-prefix=/api/ The above lets you 'curl localhost:8001/api/v1/pods'. To proxy the entire kubernetes api at a different root, use: kubectl proxy –api-prefix=/custom/ The above lets you 'curl localhost:8001/custom/api/v1/pods'


2 Answers

I believe the "kubectl way" is to not background the proxy at all as it is intended to be a short running process to access the API on your local machine without further authentication.

There is no way to stop it other than kill or ^C (if not in background).

You can use standard shell tricks though, so executing fg then ^C will work or kill %1

like image 84
Janos Lenart Avatar answered Sep 20 '22 20:09

Janos Lenart


Run this command to figure out the process id (pid):

netstat -tulp | grep kubectl  

Then run sudo kill -9 <pid> to kill the process.

like image 33
Iyus Dedi Putra Avatar answered Sep 16 '22 20:09

Iyus Dedi Putra