0

我有一个包含所有 kubernetes pod 文件夹的存储库,在每个文件夹中我有 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

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

4

1 回答 1

1

您有 1 个Service和 1 个ReplicationController

您需要首先创建两个:

kubectl create -f service.yaml

kubectl create -f controller.yaml

然后:

kubectl get services显示服务

kubectl get rc显示 ReplicationControllers

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

于 2016-04-15T01:13:42.693 回答