how to configure an internal static ip for pod inside of minikube

8/9/2018

I want to deploy a nginx-server-pod that mounts a directory to serve the files of that directory to my consumer-pod, that also lives on minikube.

In order to start consumer-pod I need to pass the ip of this nginx-server-pod to the configuration files of my-pod before it is scheduled or deployed. I do not want to expose nginx-server-pod outside minikube, so I don't want a services that create an external port mapping of type minikube-ip:external-port . I know that internal Cluser-IPs change and cannot be discovered until after the pod is deployed.

Any ideas on how to set an unchanging internal ip for my nginx-server-pod before deployment so I can configure consumer-pod and they can be deployed together?

-- Aliisa Roe
docker
kubernetes
minikube
networking
nginx

1 Answer

8/9/2018

You should create a service for your nginx container. It can be a ClusterIP service if it doesn't need to be accessible outside the cluster (or minikube VM). Once the service exists, it will have a DNS name of something like nginx.default.svc.cluster.local. You can put that in your config file and it will be consistent regardless of what IP address(es) the nginx pod(s) (if any) has.

-- David Maze
Source: StackOverflow