Expose existing deployment — Part 2

Jackie
1 min readApr 7, 2020

in addition to https://lwpro2.dev/2020/03/23/expose-existing-deployment/, if the cluster is from minikube, there are some more options to expose the deployment.

Similar to kubectl port-forward svc/local-files-12a341c023 8889:8889, which expose the service to localhost.

Minikube can do a similar expose with:

`minikube service local-test-ecd44fa2fe --url`

for example, for existing service

local-test-ecd44fa2fe ClusterIP 10.96.222.209 8501/TCP,1337/TCP 15d

we can patch it,

kubectl patch svc local-test-ecd44fa2fe -p '{"spec": {"type": "NodePort"}}'

then run the minikube service,

minikube service local-test-ecd44fa2fe --url

which would then give us the URL for accessing the svc:

http://192.168.64.9:31012
http://192.168.64.9:31458

the svc is now updated with the host port:

local-test-ecd44fa2fe NodePort 10.96.222.209 8501:31012/TCP,1337:31458/TCP 15d

alternatively, we could also do tunnelling with minikube

for exmaple, if we patch existing svc:

kubectl patch svc local-files-12a341c023 -p '{"spec": {"type": "LoadBalancer"}}'

it would update the svc with the the ports, at the same time, if we run the tunnel:

minikube tunnel

it will give us the external-IP, (otherwise would be pending)

local-new-0608a5336b LoadBalancer 10.96.117.204 10.96.117.204 8501:30556/TCP,1337:32335/TCP 10d

now we will be able to the svc using the external-ip:port

at the same time, we can still do the

minikube service local-new-0608a5336b --url

which would give us the 192.168.x:port .

note: 192.168.x is the cluster IP:

Kubernetes master is running at https://192.168.xx.x:8443

which from the host, we can access that IP to get into the cluster.

while the IP 10.96.xx is the within cluster-ip, which however, with the tunnel would expose the host.

--

--