Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 568
softshipper Avatar asked Oct 14 '25 12:10

softshipper


2 Answers

First of all, you can't make k8s to assign you an external IP address, as LoadBalancer service is Cloud Provider specific. You could push your router external IP address to be mapped to it, I guess, but it is not trivial.

To reach the service, you can do this:

  1. kubectl edit svc istio-ingressgateway -n istio-system
  2. Change the type of the service from LoadBalancer to ClusterIp. You can also do NodePort. Actually you can skip this step, as LoadBalancer service already contains NodePort and ClusterIp. It is just to get rid of that pending status.
  3. kubectl port-forward svc/istio-ingressgateway YOUR_LAPTOP_PORT:INGRESS_CLUSTER_IP_PORT -n istio-system

I don't know to which port you want to access from your localhost. Say 8080, you can do:

kubectl port-forward svc/istio-ingressgateway 8080:80 -n istio-system

Now port 8080 of your laptop (localhost:8080) will be mapped to the port 80 of istio-ingressgateway service.

like image 142
suren Avatar answered Oct 17 '25 07:10

suren


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

like image 44
Ansil Avatar answered Oct 17 '25 06:10

Ansil