Kubernetes minikube, cannot expose service on public ip range

10/7/2017

So I've been playing around with Minkube.

I've managed to deploy a simple python flask container:

PS C:\Users\Will> kubectl run test-flask-deploy --image 
192.168.1.201:5000/test_flask:1 
deployment "test-flask-deploy" created

I've also then managed to expose the deployment as a service:

PS C:\Users\Will> kubectl expose deployment/test-flask-deploy --
type="NodePort" --port 8080
service "test-flask-deploy" exposed

In the dashboard I can see that the service has a Cluster IP: 10.0.0.132.

I access the dashboard on a 192.168.xxx.xxx address, so I'm hoping I can expose the service on that external IP.

Any idea how I go about this?

A separate and slightly less important question: I've got minikube talking to a docker registry on my network. If i deploy an image (which has not yet been pulled local to the minikube) the deployment fails, yet when I run the docker pull command on minikube locally, the deployment then succeeds. So minikube is able to pull docker images, but when I deploy an image which is accessible via the registry, yet not pulled locally, it fails. Any thoughts?

EDIT: More detail in response to comment:

PS C:\Users\Will> kubectl describe pod test-flask-deploy
Name:           test-flask-deploy-1049547027-rgf7d
Namespace:      default
Node:           minikube/192.168.99.100
Start Time:     Sat, 07 Oct 2017 10:19:58 +0100
Labels:         pod-template-hash=1049547027
                run=test-flask-deploy
Annotations:    kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"default","name":"test-flask-deploy-1049547027","uid":"b06a14b8-ab40-11e7-9714-080...
Status:         Running
IP:             172.17.0.4
Created By:     ReplicaSet/test-flask-deploy-1049547027
Controlled By:  ReplicaSet/test-flask-deploy-1049547027
Containers:
  test-flask-deploy:
    Container ID:       docker://577e339ce680bc5dd9388293f1f1ea62be59a6acc25be22889310761222c760f
    Image:              192.168.1.201:5000/test_flask:1
    Image ID:           docker-pullable://192.168.1.201:5000/test_flask@sha256:d303ed635888394f69223cc0a66c5778444fd3636dfcde42295fd512be948898
    Port:               <none>
    State:              Running
      Started:          Sat, 07 Oct 2017 10:19:59 +0100
    Ready:              True
    Restart Count:      0
    Environment:        <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-5rrpm (ro)
Conditions:
  Type          Status
  Initialized   True
  Ready         True
  PodScheduled  True
Volumes:
  default-token-5rrpm:
    Type:       Secret (a volume populated by a Secret)
    SecretName: default-token-5rrpm
    Optional:   false
QoS Class:      BestEffort
Node-Selectors: <none>
Tolerations:    <none>
Events:         <none>
-- Xerphiel
kubernetes
minikube

1 Answer

10/7/2017

First, check the nodeport that is assigned to your service:

$ kubectl get svc test-flask-deploy
NAME                CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE
test-flask-deploy   10.0.0.76    <nodes>       8080:30341/TCP   4m

Now you should be able to access it on 192.168.xxxx:30341 or whatever your minikubeIP:nodeport is.

-- iamnat
Source: StackOverflow