入口 nginx 裸机连接被拒绝
Ingress nginx baremetal connexion refused
我正在尝试学习 kubernetes 和 ingress。我误解了什么?
我在 3vm 上使用 proxmox
kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8sm Ready control-plane,master 127d v1.22.4
k8sn1 Ready <none> 127d v1.22.4
k8sn2 Ready <none>
127d v1.22.4
我有 2 个 nginx pod 作为部署。
kubectl get pod
NAME READY STATUS RESTARTS AGE
curl-test 1/1 Running 0 5d11h
frontend-86968456b9-jnbqf 1/1 Running 0 5d11h
frontend-86968456b9-tj2w9 1/1 Running 0 5d11h
1 项服务与标签一起使用
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 127d
my-service-ingress ClusterIP 10.104.228.72 <none> 80/TCP 25h
svc.yaml
---
apiVersion: v1
kind: Service
metadata:
name: my-service-ingress
spec:
selector:
app: frontend
ports:
- port: 80
targetPort: 80
我已连接到 ssh 中的主节点
curl http://10.104.228.72
THIS IS CONTAINER : 1
这是我从官方 kubernetes 文档复制的入口文件
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /frontend
pathType: Prefix
backend:
service:
name: my-service-ingress
port:
number: 80
入口资源:
kubectl get ingress -o wide
NAME CLASS HOSTS ADDRESS PORTS AGE
test-ingress <none> * 80 39m
关于入口控制器的信息
kubectl get all -n ingress-nginx
NAME READY STATUS RESTARTS AGE
pod/ingress-nginx-admission-create--1-tnglj 0/1 Completed 0 24h
pod/ingress-nginx-admission-patch--1-97n79 0/1 Completed 1 24h
pod/ingress-nginx-controller-547f579dc-ssf5r 1/1 Running 0 24h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/ingress-nginx-controller NodePort 10.100.181.85 <none> 80:32412/TCP,443:32016/TCP 24h
service/ingress-nginx-controller-admission ClusterIP 10.98.29.50 <none> 443/TCP 24h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/ingress-nginx-controller 1/1 1 1 24h
NAME DESIRED CURRENT READY AGE
replicaset.apps/ingress-nginx-controller-547f579dc 1 1 1 24h
NAME COMPLETIONS DURATION AGE
job.batch/ingress-nginx-admission-create 1/1 4s 24h
job.batch/ingress-nginx-admission-patch 1/1 5s 24h
使用 IP 节点的 curl 测试不起作用:
kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
k8sm Ready control-plane,master 127d v1.22.4 192.168.1.38 <none> Debian GNU/Linux 10 (buster) 4.19.0-18-amd64 docker://20.10.11
k8sn1 Ready <none> 127d v1.22.4 192.168.1.39 <none> Debian GNU/Linux 10 (buster) 4.19.0-18-amd64 docker://20.10.11
k8sn2 Ready <none> 127d v1.22.4 192.168.1.40 <none> Debian GNU/Linux 10 (buster) 4.19.0-18-amd64 docker://20.10.11
rbo@K8sM:~/elearning/kubernestes_admin_course/Zeal_Vora/Ingress$ curl http://192.168.1.39
curl: (7) Failed to connect to 192.168.1.39 port 80: Connexion refusée
在 Ingress 中你使用了路径 /frontend
但你没有点击它而
此外,使用 Node Port
和 Node IP
您正在使用内部服务 IP。
类似于:
curl http://192.168.1.39:32412/frontend
我正在尝试学习 kubernetes 和 ingress。我误解了什么?
我在 3vm 上使用 proxmox
kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8sm Ready control-plane,master 127d v1.22.4
k8sn1 Ready <none> 127d v1.22.4
k8sn2 Ready <none>
127d v1.22.4
我有 2 个 nginx pod 作为部署。
kubectl get pod
NAME READY STATUS RESTARTS AGE
curl-test 1/1 Running 0 5d11h
frontend-86968456b9-jnbqf 1/1 Running 0 5d11h
frontend-86968456b9-tj2w9 1/1 Running 0 5d11h
1 项服务与标签一起使用
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 127d
my-service-ingress ClusterIP 10.104.228.72 <none> 80/TCP 25h
svc.yaml
---
apiVersion: v1
kind: Service
metadata:
name: my-service-ingress
spec:
selector:
app: frontend
ports:
- port: 80
targetPort: 80
我已连接到 ssh 中的主节点
curl http://10.104.228.72
THIS IS CONTAINER : 1
这是我从官方 kubernetes 文档复制的入口文件
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /frontend
pathType: Prefix
backend:
service:
name: my-service-ingress
port:
number: 80
入口资源:
kubectl get ingress -o wide
NAME CLASS HOSTS ADDRESS PORTS AGE
test-ingress <none> * 80 39m
关于入口控制器的信息
kubectl get all -n ingress-nginx
NAME READY STATUS RESTARTS AGE
pod/ingress-nginx-admission-create--1-tnglj 0/1 Completed 0 24h
pod/ingress-nginx-admission-patch--1-97n79 0/1 Completed 1 24h
pod/ingress-nginx-controller-547f579dc-ssf5r 1/1 Running 0 24h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/ingress-nginx-controller NodePort 10.100.181.85 <none> 80:32412/TCP,443:32016/TCP 24h
service/ingress-nginx-controller-admission ClusterIP 10.98.29.50 <none> 443/TCP 24h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/ingress-nginx-controller 1/1 1 1 24h
NAME DESIRED CURRENT READY AGE
replicaset.apps/ingress-nginx-controller-547f579dc 1 1 1 24h
NAME COMPLETIONS DURATION AGE
job.batch/ingress-nginx-admission-create 1/1 4s 24h
job.batch/ingress-nginx-admission-patch 1/1 5s 24h
使用 IP 节点的 curl 测试不起作用:
kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
k8sm Ready control-plane,master 127d v1.22.4 192.168.1.38 <none> Debian GNU/Linux 10 (buster) 4.19.0-18-amd64 docker://20.10.11
k8sn1 Ready <none> 127d v1.22.4 192.168.1.39 <none> Debian GNU/Linux 10 (buster) 4.19.0-18-amd64 docker://20.10.11
k8sn2 Ready <none> 127d v1.22.4 192.168.1.40 <none> Debian GNU/Linux 10 (buster) 4.19.0-18-amd64 docker://20.10.11
rbo@K8sM:~/elearning/kubernestes_admin_course/Zeal_Vora/Ingress$ curl http://192.168.1.39
curl: (7) Failed to connect to 192.168.1.39 port 80: Connexion refusée
在 Ingress 中你使用了路径 /frontend
但你没有点击它而
此外,使用 Node Port
和 Node IP
您正在使用内部服务 IP。
类似于:
curl http://192.168.1.39:32412/frontend