Minikube networking

痴心易碎 提交于 2019-12-10 17:11:56

问题


I have a Linux build machine that I have installed minikube too. Within the minikube instance I have installed artifactory which I will be using for storing various build artifacts

I now want to be able to do some work on my dev machine (which is an unrelated laptop on the same network as the Linux build machine) and push some built artifacts into artifactory.

However I can't figure out how to get to artifactory. When I ssh to the Linux server and check the minikube service I can see that the artifactory instance is running on a 192.168 address.

Is there any way to expose artifactory ie access it on the windows machine? Or is this not possible and I should just install artifactory on the Linux machine rather than in minikube?


回答1:


Yes, we need an ingress controller (like nginx) to expose a kubernetes service for external access.

There are three ways to create the nginx ingress service using kubernetes per https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types and expose it for external access:

  1. LoadBalancer service type which sets the ExternalIP automatically. This is used when there is an external non-k8s, cloud-provider's load-balancer like CGE, AWS or Azure, and this external load-balancer would provide the ExternalIP for the nginx ingress service.
  2. ExternalIPs per https://kubernetes.io/docs/concepts/services-networking/service/#external-ips.
  3. NodePort. In this approach, the service can be accessed from outside the cluster using NodeIP:NodePort/url/of/the/service.

Along with the nginx ingress controller, you'll need an ingress resource too. Refer https://github.com/nginxinc/kubernetes-ingress/tree/master/examples/complete-example for examples.

Keep in mind that Minikube is a small VM with a small docker registry by default. So, it may not be possible to store a lot of build artifacts in Minikube.




回答2:


Expose you artifactory Service

$ minikube service <artifactory-service> -n <namespace>

Or get the URL

$ minikube service <artifactory-service> -n <namespace> --url

If you want to access from remote, you need to do something else.

Suppose, when you run minikube service <artifactory-service> -n <namespace> --url, you get following

http://192.168.99.100:30654

You can access artifactory in minikube using this URL. But can't access from remote.

Now do this, expose port 30654

ssh -i ~/.minikube/machines/minikube/id_rsa docker@$(minikube ip) -L \*:30654:0.0.0.0:30654

You will be able to access from other network.




回答3:


To get this to work in the end I setup ingress on minikube and then through entries in hosts file and nginx as a reverse proxy managed to get things working.



来源:https://stackoverflow.com/questions/48711704/minikube-networking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!