“kubectl get services”未显示“ExternalIP”列

时间:2015-12-16 01:20:46

标签: docker kubernetes

Hello Kubernetes Gurus,

我刚刚在Centos7上设置了我自己的BareBone cluser,有1个主/ 2个节点。我目前正在阅读GuestBook教程,当我认为一切运行顺利时,我遇到了阻止程序...我无法访问GuestBook网页,因为“kubectl get services”或“kubectl describe services / frontend”isn'给我一个“ExternalIP”。事实上,它根本没有向我显示“ExternalIP”栏目。

我是否错误地设置了它?如何从外部访问我的留言簿?

提前感谢您的知识匮乏。

-Ricky

以下是我的配置/获取:

frontend-service.yaml:

apiVersion: v1
kind: Service
metadata:
  name: frontend
  labels:
    name: frontend
spec:
  # if your cluster supports it, uncomment the following to automatically create
  # an external load-balanced IP for the frontend service.
  type: LoadBalancer
  ports:
    # the port that this service should serve on
    - port: 80
  selector:
    name: frontend
kubectl version:
    Client Version: version.Info{Major:"1", Minor:"1+", GitVersion:"v1.1.0-alpha.0.1464+2bfa9a1f98147c",         GitCommit:"2bfa9a1f98147cfdc2e9f4cf50e2c430518d91eb", GitTreeState:"clean"}
    Server Version: version.Info{Major:"1", Minor:"1+", GitVersion:"v1.1.0-alpha.0.1464+2bfa9a1f98147c", GitCommit:"2bfa9a1f98147cfdc2e9f4cf50e2c430518d91eb", GitTreeState:"clean"}
kubectl get services

    NAME           LABELS                                    SELECTOR            IP(S)            PORT(S)    AGE
    frontend       name=frontend                             name=frontend       10.254.42.196    80/TCP     48m
    kubernetes     component=apiserver,provider=kubernetes   <none>              10.254.0.1       443/TCP    12h
    my-nginx       run=my-nginx                              run=my-nginx        10.254.169.92    80/TCP     2h
    redis-master   name=redis-master                         name=redis-master   10.254.212.151   6379/TCP   1h
    redis-slave    name=redis-slave                          name=redis-slave    10.254.251.175   6379/TCP   1h
kubectl get rc

    CONTROLLER     CONTAINER(S)   IMAGE(S)                                 SELECTOR            REPLICAS   AGE
    frontend       php-redis      gcr.io/google_samples/gb-frontend:v3     name=frontend       3          1h
    redis-master   master         redis                                    name=redis-master   1          1h
    redis-slave    worker         gcr.io/google_samples/gb-redisslave:v1   name=redis-slave    2          1h


kubectl get pods:

    NAME                 READY     STATUS    RESTARTS   AGE
    frontend-d4tns       1/1       Running   0          1h
    frontend-t9p2t       1/1       Running   0          1h
    frontend-y9k5o       1/1       Running   0          1h
    redis-master-3mflp   1/1       Running   0          1h
    redis-slave-rhgex    1/1       Running   0          1h
    redis-slave-rs4mp    1/1       Running   0          1h

1 个答案:

答案 0 :(得分:0)

Kubernetes通过与云提供商API集成来分配外部IP。如果您运行的是“裸机”群集或任何不是集成云提供商的群集,则需要手动分配外部IP,如services documentation中所述。