Kubernetes GKE入口-简单的nginx示例,但仍有错误“;找不到后端的节点端口“;
我试图在GKE上创建一个简单的nginx服务,但遇到了一些奇怪的问题 Nginx在Pod内的端口80上运行。该服务可在端口8080上访问。(这是可行的,我可以在pod内部执行Kubernetes GKE入口-简单的nginx示例,但仍有错误“;找不到后端的节点端口“;,kubernetes,google-kubernetes-engine,Kubernetes,Google Kubernetes Engine,我试图在GKE上创建一个简单的nginx服务,但遇到了一些奇怪的问题 Nginx在Pod内的端口80上运行。该服务可在端口8080上访问。(这是可行的,我可以在pod内部执行curl myservice:8080并查看nginx主屏幕) 但是,当我试图使用入口将其公开时,我遇到了麻烦。这是我的部署、服务和入口文件 apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: n
curl myservice:8080
并查看nginx主屏幕)
但是,当我试图使用入口将其公开时,我遇到了麻烦。这是我的部署、服务和入口文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
kind: Service
apiVersion: v1
metadata:
name: my-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 8080
nodePort: 32111
targetPort: 80
type: NodePort
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
spec:
rules:
- http:
paths:
# The * is needed so that all traffic gets redirected to nginx
- path: /*
backend:
serviceName: my-service
servicePort: 80
一段时间后,我的入口状态是这样的:
$ k describe ingress test-ingress
Name: test-ingress
Namespace: default
Address: 35.186.255.184
Default backend: default-http-backend:80 (10.44.1.3:8080)
Rules:
Host Path Backends
---- ---- --------
*
/* my-service:32111 (<none>)
Annotations:
backends: {"k8s-be-30030--ecc76c47732c7f90":"HEALTHY"}
forwarding-rule: k8s-fw-default-test-ingress--ecc76c47732c7f90
target-proxy: k8s-tp-default-test-ingress--ecc76c47732c7f90
url-map: k8s-um-default-test-ingress--ecc76c47732c7f90
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ADD 18m loadbalancer-controller default/test-ingress
Normal CREATE 17m loadbalancer-controller ip: 35.186.255.184
Warning Service 1m (x5 over 17m) loadbalancer-controller Could not find nodeport for backend {ServiceName:my-service ServicePort:{Type:0 IntVal:32111 StrVal:}}: could not find matching nodeport from service
Normal Service 1m (x5 over 17m) loadbalancer-controller no user specified default backend, using system default
$k描述入口测试入口
名称:测试入口
名称空间:默认值
地址:35.186.255.184
默认后端:默认http后端:80(10.44.1.3:8080)
规则:
主机路径后端
---- ---- --------
*
/*我的服务:32111()
注释:
后端:{“k8s-be-30030--ecc76c47732c7f90:“正常”}
转发规则:k8s fw默认测试入口——ecc76c47732c7f90
目标代理:k8s tp默认测试入口——ecc76c47732c7f90
url映射:k8s um默认测试入口——ecc76c47732c7f90
活动:
从消息中键入原因年龄
---- ------ ---- ---- -------
正常添加18m负载平衡器控制器默认/测试入口
普通创建17m负载平衡器控制器ip:35.186.255.184
警告服务1m(x5超过17m)loadbalancer控制器找不到后端的节点端口{ServiceName:my Service ServicePort:{Type:0 IntVal:32111 StrVal:}}:无法从服务中找到匹配的节点端口
正常服务1m(x5/17m)负载平衡器控制器无用户指定的默认后端,使用系统默认值
我不明白为什么它会说它找不到nodeport——该服务定义了nodeport,并且也是nodeport类型。转到实际IP将导致默认后端-404
知道为什么吗?配置缺少运行状况检查端点,以便GKE loadbalancer了解后端是否正常。
nginx
的containers
部分还应指定:
livenessProbe:
httpGet:
path: /
port: 80
端口80上的
GET/
是默认配置,可以更改。您现在使用的是哪个“Kubernetes版本”?@Digil应该是1.9.7-gke.6服务中的端口和目标端口。yaml是反向的。它应该是端口:80和目标端口:8080。此外,您还应该将唯一的后端服务指定为默认后端,而不是将主机路径通配符配置为默认值。我希望这有帮助。