【问题标题】:Why I cant see all my kubernetes services using "kubectl get services"为什么我无法使用“kubectl get services”查看我所有的 kubernetes 服务
【发布时间】:2016-04-14 12:23:29
【问题描述】:

我有一个包含所有 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

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

【问题讨论】:

  • 只是检查一下,您确实运行了kubectl create -f service.yamlkubectl create -f controller.yaml,或者您是如何定义您的服务/复制控制器的?

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


【解决方案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。

【讨论】:

    猜你喜欢
    • 2021-01-29
    • 1970-01-01
    • 2015-12-13
    • 2020-12-12
    • 1970-01-01
    • 2018-12-28
    • 2015-01-29
    • 2022-01-23
    • 1970-01-01
    相关资源
    最近更新 更多