Access k8 Cluster on Windows from another machine

My setup is as follows

I have a Windows 10 Server. I’ve installed the MiniKube and got the Yugabyte cluster running on the Windows server. I want to be able to access the cluster, and in particular the Postgres Proxy from a second windows machine. This is my first time using k8 and I’m stuck on how to do this. It looks like I need to do something similar to this

http://alesnosek.com/blog/2017/02/14/accessing-kubernetes-pods-from-outside-of-the-cluster/

I’m looking into this and will have an answer for you on Monday.

Thanks.
–Alan

Mark,
You need to add a LoadBalancer for the yb-tservers service as well as starting up the minikube tunnel service on Windows 10 Server.

Add this to your yugabyte-statefulset.yaml:

apiVersion: v1
kind: Service
metadata:
  name: yb-tservers-service
  labels:
    app: yb-tserver
spec:
  clusterIP:
  ports:
  - name: ui
    port: 9000
  - name: rpc-port
    port: 9100
  - name: postgres
    port: 5433
  - name: cassandra
    port: 9042
  - name: redis
    port: 6379
  selector:
    app: yb-tserver
  type: LoadBalancer

Remember to uncomment the two lines for enabling Postgres support in YugaByte CE as noted here: https://docs.yugabyte.com/latest/quick-start/test-postgresql/#kubernetes

After you create the new statefulset you will see the new service:

    PS C:\Users\acald\yugabyte> kubectl get svc
    NAME                  TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)                                                                      AGE
    kubernetes            ClusterIP      10.96.0.1        <none>           443/TCP                                                                      27m
    yb-master-ui          LoadBalancer   10.101.100.103   10.101.100.103   7000:31598/TCP                                                               26m
    yb-masters            ClusterIP      None             <none>           7000/TCP,7100/TCP                                                            26m
    yb-tservers           ClusterIP      None             <none>           9000/TCP,9100/TCP,9042/TCP,6379/TCP,5433/TCP                                 26m
    yb-tservers-service   LoadBalancer   10.99.91.107     10.99.91.107     9000:30478/TCP,9100:30923/TCP,5433:31730/TCP,9042:31119/TCP,6379:30304/TCP   26m

It may show the EXTERNAL-IP as . In that case, execute minikube tunnel from your PowerShell prompt to activate the tunnel service.

Finally, you can see a list of the endpoints with the following:
minikube service yb-tservers-service --url

It looks like the following:

PS C:\Users\acald\yugabyte> minikube service yb-tservers-service --url
http://192.168.1.159:30478
http://192.168.1.159:30923
http://192.168.1.159:31730
http://192.168.1.159:31119
http://192.168.1.159:30304

Since you are looking to connect to Postgres you can connect on port 31730 and the IP address noted in the output above.

Hope this helps. Let us know if you encounter further issues or have additional questions.

Alan

1 Like

Alan

Thanks for this. Giving it a shot now…

Alan

Here’s what I get…

C:\Users\Mark D Drake\VirtualBox VMs\Yugabyte>kubectl get svc
NAME                  TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                                                                      AGE
kubernetes            ClusterIP      10.96.0.1       <none>        443/TCP                                                                      7d5h
yb-master-ui          LoadBalancer   10.101.157.88   <pending>     7000:32107/TCP                                                               2m21s
yb-masters            ClusterIP      None            <none>        7000/TCP,7100/TCP                                                            2m21s
yb-tservers           ClusterIP      None            <none>        9000/TCP,9100/TCP,9042/TCP,6379/TCP                                          2m21s
yb-tservers-service   LoadBalancer   10.100.254.49   <pending>     9000:32634/TCP,9100:31856/TCP,5433:32458/TCP,9042:30016/TCP,6379:30459/TCP   2m21s

C:\Users\Mark D Drake\VirtualBox VMs\Yugabyte>minikube service yb-tservers-service --url
http://192.168.99.100:32634
http://192.168.99.100:31856
http://192.168.99.100:32458
http://192.168.99.100:30016
http://192.168.99.100:30459

Sanity check connection to my local postgres instance…

C:\Users\Mark D Drake\VirtualBox VMs\Yugabyte>"c:\Program Files\PostgreSQL\11\bin\psql.exe" -U postgres -h 192.168.1.250 -p 5432
psql (11beta2)
WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.

postgres=# exit

Attempt connection to Yugabyte cluster

C:\Users\Mark D Drake\VirtualBox VMs\Yugabyte>"c:\Program Files\PostgreSQL\11\bin\psql.exe" -U postgres -h 192.168.99.100 -p 32458
psql: could not connect to server: Connection timed out (0x0000274C/10060)
        Is the server running on host "192.168.99.100" and accepting
        TCP/IP connections on port 32458?

C:\Users\Mark D Drake\VirtualBox VMs\Yugabyte>

The connection to the cluster seems to time out.

Some thoughts…

Why is the external IP shown as <Pending> in the “kubectl get svc” output ?
Where does it get the IP address from…

The Hosts IP address is hard wired to 192.168.1.250.
My DHCP server allocated addresses on 192.168.1…

Why does the miniube service --url show the ipaddress 192.168.99.100, do I need to force it on to 192.168.1 somehow ?

Mark,
If you execute minikube ip that will give you the IP address of the minikube cluster. The fact that it is not on the same network as your host suggests that your VirtualBox networking configuration is not set up to share the host’s network and is using a “private” address instead. It may be set to something like Internal or DockerNAT currently. You want it get an address on the “External” network. See this link for a discussion on how to set this up with HyperV – and you will need to find the equivalent in VirtualBox: https://blogs.msdn.microsoft.com/wasimbloch/2017/01/23/setting-up-kubernetes-on-windows10-laptop-with-minikube/

Alan