簡體   English   中英

將Nginx入口綁定到靜態IP地址

[英]Bind nginx-ingress to static IP Address

我想在AWS EKS上為從外部系統訪問的多個微服務設置一個入口控制器。

通過虛擬主機名(例如svc1.acme.comsvc2.acme.com ,...)訪問微服務。

我用頭盔圖設置了Nginx入口控制器: https : //github.com/helm/charts/tree/master/stable/nginx-ingress

我的想法是保留一個彈性IP地址,並通過設置變量externalIP將nginx-controller綁定到該IP。

這樣,我應該能夠使用穩定的通配符DNS條目*.acme.com --> 54.72.43.19訪問服務

我可以看到入口控制器服務獲得了externalIP,但是該IP無法訪問。

NAME                                    TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
ingress-nginx-ingress-controller        LoadBalancer   10.100.45.119    54.72.43.19   80:32104/TCP,443:31771/TCP   1m

知道為什么嗎?

更新:

我使用以下命令安裝了入口控制器:

helm install --name ingress -f values.yaml stable/nginx-ingress

這是值的要點,與默認值相比唯一更改的是

externalIPs: ["54.72.43.19"]

https://gist.github.com/christianwoehrle/3b136023b1e0085b028a67ca6a0959b7

也許您可以通過使用支持固定IP的網絡負載平衡器( https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html )來實現,以作為Nginx入口的支持,例如( https://aws.amazon.com/blogs/opensource/network-load-balancer-support-in-kubernetes-1-9/ ):

apiVersion: v1
kind: Service
metadata:
  name: nginx
  namespace: default
  labels:
    app: nginx
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
spec:
  externalTrafficPolicy: Local
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: nginx
type: LoadBalancer

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM