问题原文
原帖链接 · horcle_buzz · CC BY-SA 4.0
My end goal is to be able to access exposed Kubernetes services running on on my host from another host.
I am doing development in minikube and have tried using an Ingress controller. I am able to get this working on the device itself, as per the directions here Setting up ingress on minikube. However, I want to be able to access my exposed services from a different computer, as in
curl http://host.ip:8000, where host.ip is the actual public IP address of the device, not that of the minikube VM or that of an internal network created on the device; and port 8000 is that of the exposed Kubernetes service.
This does not seem like such an odd edge case, so I am surprised I not been able to find any useful information out there on how ****EASILY**** do this.
Here is my local functioning ingress controller, for completeness's sake:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nlp-adapt
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
backend:
serviceName: default-http-backend
servicePort: 8000
rules:
- host: myminikube.info
http:
paths:
- path: /
backend:
serviceName: echoserver
servicePort: 8080
- host: test.nlp
http:
paths:
- path: /nlptab
backend:
serviceName: nlptab
servicePort: 8000
已采纳解答
原帖链接 · Artem Golenyaev · CC BY-SA 4.0
Usually, Minikube runs inside a virtual machine. And it is necessary to expose port outside of the virtual machine additionally to exposing it outside of Kubernetes to make an application available on the host IP.
Here is the example:
Expose Ingress outside of Kubernetes:
kind: Service apiVersion: v1 metadata: name: ingress-nginx spec: type: NodePort selector: app: ingress-nginx ports: - port: 80 nodePort: 31080 name: httpExpose the
31080port outside the Virtual machine:ssh -i ~/.minikube/machines/minikube/id_rsa docker@$(minikube ip) -L 31080:0.0.0.0:8000
After that, the application shared by Ingress will be available on http://host.ip:8000
It is not the only way to expose an application. For example, when using VirtualBox as a hypervisor, you can also use the VirtualBox NAT port forwarding feature to allow access to services exposed through NodePorts from outside. As mentioned in link provided by @horcle_buzz
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
