[英]Nginx Ingress Controller on Bare Metal expose problem
我嘗試在裸機上部署nginx-ingress-controller
,我有
4 節點
4 工人
2磅
10.0.76.208 - 磅 1
10.0.76.209 - 虛擬 IP (keepalave)
10.0.76.210 - 磅 10
一切都在BareMetal
上,負載均衡器位於集群外部。
這是簡單的 haproxy 配置,只需檢查 80 端口( Worker ip )
frontend kubernetes-frontends
bind *:80
mode tcp
option tcplog
default_backend kube
backend kube
mode http
balance roundrobin
cookie lsn insert indirect nocache
option http-server-close
option forwardfor
server node-1 10.0.76.205:80 maxconn 1000 check
server node-2 10.0.76.206:80 maxconn 1000 check
server node-3 10.0.76.207:80 maxconn 1000 check
server node-4 10.0.76.214:80 maxconn 1000 check
我使用 Helm 安裝 nginx-ingress-controller 並且一切正常
NAME READY STATUS RESTARTS AGE
pod/ingress-nginx-admission-create-xb5rw 0/1 Completed 0 18m
pod/ingress-nginx-admission-patch-skt7t 0/1 Completed 2 18m
pod/ingress-nginx-controller-6dc865cd86-htrhs 1/1 Running 0 18m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/ingress-nginx-controller NodePort 10.106.233.186 <none> 80:30659/TCP,443:32160/TCP 18m
service/ingress-nginx-controller-admission ClusterIP 10.102.132.131 <none> 443/TCP 18m
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/ingress-nginx-controller 1/1 1 1 18m
NAME DESIRED CURRENT READY AGE
replicaset.apps/ingress-nginx-controller-6dc865cd86 1 1 1 18m
NAME COMPLETIONS DURATION AGE
job.batch/ingress-nginx-admission-create 1/1 24s 18m
job.batch/ingress-nginx-admission-patch 1/1 34s 18m
部署 nginx 簡單的方法並且工作正常
kubectl create deploy nginx --image=nginx:1.18
kubectl scale deploy/nginx --replicas=6
kubectl expose deploy/nginx --type=NodePort --port=80
之后,我決定創建ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: tektutor-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: "tektutor.training.org"
http:
paths:
- pathType: Prefix
path: "/nginx"
backend:
service:
name: nginx
port:
number: 80
工作正常
kubectl describe ingress tektutor-ingress
Name: tektutor-ingress
Labels: <none>
Namespace: default
Address: 10.0.76.214
Ingress Class: <none>
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
tektutor.training.org
/nginx nginx:80 (192.168.133.241:80,192.168.226.104:80,192.168.226.105:80 + 3 more...)
Annotations: kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal AddedOrUpdated 18m nginx-ingress-controller Configuration for default/tektutor-ingress was added or updated
Normal Sync 18m (x2 over 18m) nginx-ingress-controller Scheduled for sync
everything work fine, when i try curl any ip works curl (192.168.133.241:80,192.168.226.104:80,192.168.226.105:80 + 3 more...)
現在我嘗試添加主機
10.0.76.201 tektutor.training.org
這是我的主ip,這里加主ip對嗎? 當我嘗試curl tektutor.training.org
不工作
你能解釋一下我在最后一步有什么問題嗎? 我把 IP 設置錯了? 或者是什么? 謝謝 !
我希望我已經詳盡地寫了所有內容
TL;博士
放入下面顯示的 haproxy 后端配置值,而不是您提供的值:
30659
而不是80
32160
而不是443
(如果需要)更多解釋:
NodePort
適用於某些端口集(默認值: 30000
- 32767
),在這種情況下它分配:
30659
為您的 ingress-nginx-controller 端口80
。32160
為您的 ingress-nginx-controller 端口443
。這意味着嘗試從外部訪問您的集群的每個請求都需要聯系此端口(30...)。
您可以通過以下官方文檔了解更多信息:
一個耗時 2 天的有趣故事:) 在 Ingress 中,我使用了路徑 /nginx,但沒有點擊它
像: http://tektutor.training.org/nginx
感謝@Dawid Kruk 試圖掌舵我:) !
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.