Base OS : CentOS (1 master 2 minions)
K8S version : 1.9.5 (deployed using KubeSpray)
我是 Kubernetes Ingress 的新手,正在设置 2 个不同的服务,每个服务都有自己的路径。
我创建了 2 个部署:
kubectl run nginx --image=nginx --port=80
kubectl run echoserver --image=gcr.io/google_containers/echoserver:1.4 --port=8080
我还创建了相应的服务:
kubectl expose deployment nginx --target-port=80 --type=NodePort
kubectl expose deployment echoserver --target-port=8080 --type=NodePort
我svc
的是:
[root@node1 kubernetes]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
echoserver NodePort 10.233.48.121 <none> 8080:31250/TCP 47m
nginx NodePort 10.233.44.54 <none> 80:32018/TCP 1h
我的 NodeIP 地址是172.16.16.2
,我可以使用
http://172.16.16.2:31250 &
http://172.16.16.2:32018
现在最重要的是,我想部署一个 Ingress,这样我就可以访问两个 pod,而不使用 2 个 IP 和 2 个不同的端口,但 1 个 IP 地址具有不同的路径。
所以我的入口文件是:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: fanout-nginx-ingress
spec:
rules:
- http:
paths:
- path: /nginx
backend:
serviceName: nginx
servicePort: 80
- path: /echo
backend:
serviceName: echoserver
servicePort: 8080
这产生:
[root@node1 kubernetes]# kubectl describe ing fanout-nginx-ingress
Name: fanout-nginx-ingress
Namespace: development
Address:
Default backend: default-http-backend:80 (<none>)
Rules:
Host Path Backends
---- ---- --------
*
/nginx nginx:80 (<none>)
/echo echoserver:8080 (<none>)
Annotations:
Events: <none>
现在,当我尝试使用 NodeIP 地址 (172.16.16.2) 访问 Pod 时,我什么也得不到。
http://172.16.16.2/echo
http://172.16.16.2/nginx
我的配置中有什么遗漏吗?