我正在尝试在GKE上创建一个简单的nginx服务,但遇到了一些奇怪的问题。
Nginx在Pod内部的端口80上运行。可以在端口8080上访问该服务。(这可以正常工作,我可以在pod内进行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
我不明白为什么这么说它找不到节点端口-该服务已定义了nodePort并且它也是NodePort类型。转到实际IP,结果为default backend - 404
。
有什么想法吗?
答案 0 :(得分:0)
该配置缺少运行状况检查终结点,以便GKE负载平衡器知道后端是否正常。 containers
的{{1}}部分还应指定:
nginx
端口80上的 livenessProbe:
httpGet:
path: /
port: 80
是默认配置,可以更改。