Search code examples
kubernetesistio

How to assign an IP to istio-ingressgateway on localhost?


I am using kubespray to run a kubernetes cluster on my laptop. The cluster is running on 7 VMs and the roles of the VM's spread as follows:

NAME    STATUS   ROLES    AGE     VERSION
k8s-1   Ready    master   2d22h   v1.16.2
k8s-2   Ready    master   2d22h   v1.16.2
k8s-3   Ready    master   2d22h   v1.16.2
k8s-4   Ready    master   2d22h   v1.16.2
k8s-5   Ready    <none>   2d22h   v1.16.2
k8s-6   Ready    <none>   2d22h   v1.16.2
k8s-7   Ready    <none>   2d22h   v1.16.2

I've installed https://istio.io/ to build a microservices environment.

I have 2 services running and like to access from outside:

k get services
NAME              TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
greeter-service   ClusterIP   10.233.50.109   <none>        3000/TCP   47h
helloweb          ClusterIP   10.233.8.207    <none>        3000/TCP   47h

and the running pods:

NAMESPACE      NAME                                      READY   STATUS    RESTARTS   AGE     IP             NODE    NOMINATED NODE   READINESS GATES
default        greeter-service-v1-8d97f9bcd-2hf4x        2/2     Running   0          47h     10.233.69.7    k8s-6   <none>           <none>
default        greeter-service-v1-8d97f9bcd-gnsvp        2/2     Running   0          47h     10.233.65.3    k8s-2   <none>           <none>
default        greeter-service-v1-8d97f9bcd-lkt6p        2/2     Running   0          47h     10.233.68.9    k8s-7   <none>           <none>
default        helloweb-77c9476f6d-7f76v                 2/2     Running   0          47h     10.233.64.3    k8s-1   <none>           <none>
default        helloweb-77c9476f6d-pj494                 2/2     Running   0          47h     10.233.69.8    k8s-6   <none>           <none>
default        helloweb-77c9476f6d-tnqfb                 2/2     Running   0          47h     10.233.70.7    k8s-5   <none>           <none>

The problem is, I can not access the services from outside, because I do not have the EXTERNAL IP address(remember the cluster is running on my laptop).

k get svc istio-ingressgateway -n istio-system  
NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                                                                                                                      AGE
istio-ingressgateway   LoadBalancer   10.233.61.112   <pending>     15020:31311/TCP,80:30383/TCP,443:31494/TCP,15029:31383/TCP,15030:30784/TCP,15031:30322/TCP,15032:30823/TCP,15443:30401/TCP   47h

As you can see, the column EXTERNAL-IP the value is <pending>.

The question is, how to assign an EXTERNAL-IP to the istio-ingressgateway.


Solution

  • By default, there is no way Kubernetes can assign external IP to LoadBalancer service. This service type needs infrastructure support which works in cloud offerings like GKE, AKS, EKS etc.

    As you are running this cluster inside your laptop, deploy MetalLB Load Balancer to get EXTERNAL-IP