如何为 Minikube 上的入口控制器指定自定义端口?
How do you specify a custom port for the ingress controller on Minikube?
它似乎默认监听 80 - 合理 - 但如果我想让它监听(例如)8000 上的请求,我该如何指定?
为清楚起见,这是通过 minikube addons enable ingress
)
启用的 nginx 控制器实现的
Ingress exposes HTTP and HTTPS routes from outside the cluster to
services
within the cluster.
这意味着它将使用默认端口作为 HTTP 和 HTTPS 端口。
从文档中我们可以读到:
An Ingress does not expose arbitrary ports or protocols. Exposing services other than HTTP and HTTPS to the internet typically uses a service of type Service.Type=NodePort or Service.Type=LoadBalancer.
nginx-ingress 控制器实际上允许更改 http
和 https
端口。
查看配置参数:
controller.service.ports.http
controller.service.ports.https
虽然通常情况下,Ingress 不允许您在随机端口上公开随机内容,但在 nginx-ingress 的情况下,您可以这样做。但是你必须使用额外的注释。
例如,如果您的 pod 公开了 443,但您希望它在端口 8081 上可用,您必须执行以下技巧:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: myservice
namespace: mynamespace
annotations:
kubernetes.io/ingress.class: nginx
nginx.org/listen-ports-ssl: "8081"
spec:
tls:
- hosts:
- host.org
secretName: my-host-tls-cert
rules:
- host: host.org
http:
paths:
- path: /
backend:
serviceName: my-service
servicePort: 443
它似乎默认监听 80 - 合理 - 但如果我想让它监听(例如)8000 上的请求,我该如何指定?
为清楚起见,这是通过 minikube addons enable ingress
)
Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.
这意味着它将使用默认端口作为 HTTP 和 HTTPS 端口。
从文档中我们可以读到:
An Ingress does not expose arbitrary ports or protocols. Exposing services other than HTTP and HTTPS to the internet typically uses a service of type Service.Type=NodePort or Service.Type=LoadBalancer.
nginx-ingress 控制器实际上允许更改 http
和 https
端口。
查看配置参数:
controller.service.ports.http
controller.service.ports.https
虽然通常情况下,Ingress 不允许您在随机端口上公开随机内容,但在 nginx-ingress 的情况下,您可以这样做。但是你必须使用额外的注释。
例如,如果您的 pod 公开了 443,但您希望它在端口 8081 上可用,您必须执行以下技巧:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: myservice
namespace: mynamespace
annotations:
kubernetes.io/ingress.class: nginx
nginx.org/listen-ports-ssl: "8081"
spec:
tls:
- hosts:
- host.org
secretName: my-host-tls-cert
rules:
- host: host.org
http:
paths:
- path: /
backend:
serviceName: my-service
servicePort: 443