为什么我无法使用“kubectl get services”看到我所有的kubernetes服务

时间:2016-04-14 12:23:29

标签: amazon-web-services cluster-computing kubernetes kubernetes-health-check

我有一个包含所有kubernetes pods文件夹的存储库,在每个文件夹中我有2个文件,假设我有一个文件夹名称“MyApp”,所以在这个文件夹中我有:

controller.yaml看起来像这样:(这是我的rc)

apiVersion: v1
kind: ReplicationController
metadata:
  name: MyApp
  labels:
    name: MyApp
spec:
  replicas: 1
  selector:
    name: MyApp
  template:
    metadata:
      labels:
        name: MyApp
        version: 0.1.4
    spec:
      containers:
      - name: MyApp
        #this is the image artifactory
        image: docker-docker-release.someartifactory.com/MyApp:0.1.4
        ports:
        - containerPort: 9000
      imagePullSecrets:
        - name: myCompany-artifactory

service.yaml看起来像这样:

apiVersion: v1
kind: Service
metadata:
  name: MyApp
  labels:
    name: MyApp
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: 9000
  selector:
    name: MyApp

现在,我运行kubectl get services列出我的所有服务,然后我得到:

NAME         LABELS                                    SELECTOR   IP(S)      PORT(S)
kubernetes   component=apiserver,provider=kubernetes   <none>     xxxxx

为什么我没有得到我的所有服务?

1 个答案:

答案 0 :(得分:1)

您有1个服务,1个 ReplicationController

首先需要同时创建:

kubectl create -f service.yaml

kubectl create -f controller.yaml

然后用:

kubectl get services显示服务

kubectl get rc显示了ReplicationControllers

kubectl get pods显示了由ReplicationController部署的Pod。