Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes Service not being assigned an (external) IP address

Tags:

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?

like image 884
Jono Stewart Avatar asked Mar 03 '18 20:03

Jono Stewart


1 Answers

For local development purpose, I have also met with the problem of exposing a 'public IP' for my local development cluster. Fortunately, I have found one of the kubectl command which can help:

kubectl port-forward service/service-name 9092

Where 9092 is the container port to expose, so that I can access applications inside the cluster, on my local development environment.

The important note is that it is not a 'production' grade solution. Works well as a temporary hack to get to the cluster insides.

like image 93
Dastin Sandura Avatar answered Oct 11 '22 14:10

Dastin Sandura