kubernetes服务返回拒绝

时间:2017-01-17 10:22:48

标签: kubernetes google-cloud-platform

我要变得疯狂。我尝试在Google Cloud上的kubernetes中公开我的服务。我的pod正在启动,没有错误,我的服务已创建。但是当我继续或卷曲时,我得到:

  

无法连接到130. 。***端口80:拒绝连接

apiVersion: v1
kind: Service
metadata:
  name: k8s-symfony-nginx
  labels:
    name: k8s-symfony-nginx
spec:
  type: LoadBalancer #expose
  ports:
  - port: 80
  selector:
    type: my-app

和复制:

apiVersion: v1
kind: ReplicationController
metadata:
  name: k8s-symfony-nginx
  labels:
    name: k8s-symfony-nginx
spec:
  replicas: 1
  selector:
    name: k8s-symfony-nginx
    type: my-app
  template:
    metadata:
      labels:
        name: k8s-symfony-nginx
        type: my-app
    spec:
      containers:
        - name: nginx
          image: phpdockerio/nginx:latest
          ports:
            - name: web
              containerPort: 80
        - name: php
          image: gcr.io/myproject-138623/newcom4u/k8s-symfony-php:latest
          ports:
            - name: php
              containerPort: 9000

kubectl获取svc的输出是:

  

k8s-symfony-nginx 10.3。 104.199。 80:30274 / TCP
  4米

我的服务中描述的kubectl的输出是:

Name:           k8s-symfony-nginx
Namespace:      default
Labels:         name=k8s-symfony-nginx
Selector:       name=k8s-symfony-nginx,type=my-app
Type:           LoadBalancer
IP:         10.******
LoadBalancer Ingress:   104.*****
Port:           <unset> 80/TCP
NodePort:       <unset> 30274/TCP
Endpoints:      10.0.0.9:80
Session Affinity:   None
Events:
  FirstSeen LastSeen    Count   From            SubObjectPath   Type        Reason          Message
  --------- --------    -----   ----            -------------   --------    ------          -------
  12m       12m     1   {service-controller }           Normal      CreatingLoadBalancer    Creating load balancer
  11m       11m     1   {service-controller }           Normal      CreatedLoadBalancer Created load balancer

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,我改变了

apiVersion: v1
kind: Service
metadata:
  name: k8s-symfony-nginx
  labels:
  name: k8s-symfony-nginx
spec:
type: LoadBalancer #expose
  ports:
  - port: 80
  selector:
    type: my-app

apiVersion: v1
kind: Service
metadata:
  name: k8s-symfony-nginx
  labels:
  name: k8s-symfony-nginx
spec:
type: LoadBalancer #expose
  ports:
  - port: 80
  selector:
    app: my-app

类型应在选择器中更改为应用