How do you access a pod inside a Kubernetes Cluster in Windows?

6/7/2019

I have MariaDB running inside a Kubernetes node in Minikube in a Virtual Box on Windows. I want to try and communicate with the MariaDB pod such that I can read a table and visualize the contents inside Tableau. In order to do this I need to expose the Pod outside of Minikube, and also be able to access it through The Virtual Box.

I have not exposed the pod, but if I understand it correctly I need to write a NodePort Service to expose it outside the Minikube.

 apiVersion v1
 kind Service
 metadata:
      name: mariadb
 spec: 
      type: NodePort
      ports:
      - targetPort: 80
        port: 80
        nodePort: 30008
 selector: 
     app: mariadb
     chart: mariadb-6.4.0
     component: master
     controller-revision-hash: my-release-mariadb-master-7b7cc7895
     release: my-release
     statefulset.kubernetes.io/pod-name: my-release-mariadb-master-0

If I did not have the minikube inside a VirtualBox I should now be able to connect to the pod through the service. But in my case, how would one "open up" the Virtual Box such that I can communicate with the minikube and then the NodePort?

Thank you for any help!

-- kkss
kubernetes
mariadb

1 Answer

6/7/2019

In order to open the exposed service, the minikube service command can be used:

$ kubectl expose deployment hello-minikube --type=NodePort
service "hello-minikube" exposed
$ kubectl get svc
NAME             CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE
hello-minikube   10.0.0.102   <nodes>       8080/TCP   7s
kubernetes       10.0.0.1     <none>        443/TCP    13m

$ minikube service hello-minikube
Opening kubernetes service default/hello-minikube in default browser...

This command will open the specified service in your default browser.

you can also get the url using :

$ minikube service hello-minikube --url
http://192.168.99.100:31167
-- Semah Mhamdi
Source: StackOverflow