无法访问Kubernetes服务

时间:2017-02-06 12:19:58

标签: nginx kubernetes

我们无法从pod群集外部访问nginx。请帮助我们了解以下是否正确以及哪个端口将服务于nginx。在NodeIP上运行curl:NodePort抛出我们公司代理访问被拒绝的页面。我们在openstack上安装了VM,安全组已经开放。

[root@ip-10-0-0-3 pods]# kubectl get deployments NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE nginx-demo 2 2 2 2 4m

[root@ip-10-0-0-3 pods]# kubectl get pods NAME READY STATUS RESTARTS AGE nginx-demo-1947000120-6omcz 1/1 Running 0 5m nginx-demo-1947000120-exewa 1/1 Running 0 5m

以下是Kubernetes部署和服务文件。

apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx-demo spec: replicas: 2 selector: matchLabels: app: nginx-demo minReadySeconds: 20 template: metadata: labels: app: nginx-demo version: v0.1 spec: containers: - name: nginx-demo image: nginx imagePullPolicy: Always ports: - containerPort: 80 protocol: TCP env: - name: DEMO_ENV value: staging **---**(ignore stars) apiVersion: v1 kind: Service metadata: labels: app: nginx-demo name: nginx-demo-svc spec: ports: - port: 80 protocol: TCP name: www nodePort: 30089 selector: app: nginx-demo type: NodePort

[root@ip-10-0-0-3 pods]# kubectl describe svc Name: nginx-demo-svc Namespace: default Labels: app=nginx-demo Selector: app=nginx-demo Type: NodePort IP: 192.168.1.20 Port: www 80/TCP NodePort: www 30089/TCP Endpoints: 172.17.50.2:80,172.17.67.2:80 Session Affinity: None No events.

[root@ip-10-0-0-3 pods]# kubectl get svc NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes 10.254.0.1 <none> 443/TCP 2d nginx-demo-svc 192.168.1.20 <nodes> 80/TCP 9m

1 个答案:

答案 0 :(得分:0)

服务的选择器部分必须包含所有标签:

keyPathsForValuesAffectingPreview

它更好吗?