我在VMWAre虚拟机上运行的Kubernetes群集上设置了入口,遵循类似于此处的规范。所有端口都是开放的,可以访问。
https://github.com/nginxinc/kubernetes-ingress/tree/master/examples/complete-example
我的主人是x.x.x.10,节点是x.x.x.12和x.x.x.13。
创建入口/控制器之后,我需要获取nginx-controller运行的IP
nginx-ingress-rc-kgfmd 1/1 Running 0 21h 172.16.5.5 x.x.x.12
所以,它通常在x.x.x.12或x.x.x.13上运行,然后在我执行此操作时它会访问我的Web服务
curl --resolve master.federated.fds:80:x.x.x.12 https://master.federated.fds/coffee
其中master.federated.fds是Master的DNS可解析名称。
我需要在没有IP地址帮助的情况下使用它,并且只能使用DNS可解析名称,或者至少使用任何节点ip
例如:http://node2.federated.fds/coffee,当我卷曲这个时,我得到连接拒绝错误
按规格更新
apiVersion: v1
kind: Service
metadata:
name: coffee-svc
labels:
app: coffee
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
# nodePort: 30080
type: NodePort
selector:
app: coffee
入节点
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: cafe-ingress
spec:
rules:
- host: jciamaster.federated.fds
http:
paths:
- path: /tea
backend:
serviceName: tea-svc
servicePort: 80
- path: /coffee
backend:
serviceName: coffee-svc
servicePort: 80
nginx ing controller
apiVersion: v1
kind: ReplicationController
metadata:
name: nginx-ingress-rc
labels:
app: nginx-ingress
spec:
replicas: 1
selector:
app: nginx-ingress
template:
metadata:
labels:
app: nginx-ingress
spec:
containers:
- image: nginxdemos/nginx-ingress:0.8.1
imagePullPolicy: Always
name: nginx-ingress
ports:
- containerPort: 80
hostPort: 80
我看到端口80只在nginx pod运行的节点上侦听,而不是在任何其他节点上侦听。有人请让我知道如何通过所有节点ip访问应用程序,或者通过jciamaster.federated.fds等网址访问该应用程序?
谢谢,
更新
尝试按照Marc
的建议使用nginx控制器作为svc运行apiVersion: v1
kind: ReplicationController
metadata:
name: nginx-ingress-rc
labels:
app: nginx-ingress
spec:
replicas: 1
selector:
app: nginx-ingress
template:
metadata:
labels:
app: nginx-ingress
spec:
containers:
- image: nginxdemos/nginx-ingress:0.8.1
imagePullPolicy: Always
name: nginx-ingress
ports:
- containerPort: 80
# Uncomment the lines below to enable extensive logging and/or customization of
# NGINX configuration with configmaps
#args:
#- -v=3
#- -nginx-configmaps=default/nginx-config
---
apiVersion: v1
kind: Service
metadata:
labels:
name: nginx-ingress-label
name: nginx-ing-svc
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
nodePort: 30000
type: NodePort
selector:
name: nginx-ingress
当我点击http://x.x.x.:30000/coffee时,它只是挂起并且什么都不做。我做错了什么?
答案 0 :(得分:0)
您可以使用NodePort服务公开nginx控制器Pod,然后就可以在所有节点上访问它。