Kubernetes Service not being assigned an (external) IP address

3/3/2018

There are various answers for very similar questions around SO that all show what I expect my deployment to look like, however mine does not.

  • I am running Minikube 0.25, with Kubernetes 1.9 on Windows 10.
  • I have successfully created a node, a replication controller, and a single pod template has been replicated 10 times.
  • The node is Minikube, and is assigned the IP address 10.49.106.251
  • The dashboard is available at 10.49.106.251:30000

I am deploying a service with a YAML file, but the service is never assigned an external IP - the result is the same if I happen to use kubectl expose.

The YAML file that I am using:

kind: Service
apiVersion: v1
metadata:
  name: hello-service
spec:
  type: NodePort
  selector:
    app: hello-world
  ports:
  - protocol: TCP
    port: 8080

I can also use the YAML file to assign an external IP - I assign it the same value as the node IP address. Either way results in no possible connection to the service. I should also point out that the 10 replicated pods all match the selector.

The result of running kubectl get svc for the default, and after updating the external IP are below:

NAME            TYPE        CLUSTER-IP      EXTERNAL-IP     PORT(S)          AGE
hello-service   NodePort    10.108.61.233   <none>          8080:32406/TCP   1m
hello-service   NodePort    10.108.61.233   10.49.106.251   8080:32406/TCP   1m

The tutorial I have been following, and the other answers on SO show a result similar to:

hello-service   NodePort    10.108.61.233   <nodes>   8080:32406/TCP   1m

Where the difference is that the external IP is set to <nodes>

I have encountered a number of issues when running locally - is this just another case of doing so, or has someone else identified a way to get around the external IP assignment issue?

-- Jono Stewart
kubectl
kubernetes
minikube

2 Answers

5/14/2020

same problem when trying to deploy a simple helloworld image locally with Kubernetes v1.9.2
After two weeks of attempts , It seems that Kubernetes expose all nginx web server applications internally in port 80 not 8080
So this should work kubectl expose deployment hello-service --type=NodePort --port=80

-- barsawi13
Source: StackOverflow

3/3/2018

Using NodePort means it will open a port on all nodes of your cluster. In your example above, the port exposed to the outside world is 32406. In order to access hello-service (if it is http) it will be http://[ the node ip]:32406/. This will hit your minikube and the the request will be routed to your pod in roundrobin fashion.

-- Baltazar Chua
Source: StackOverflow