Why I cant see all my kubernetes services using "kubectl get services"

4/14/2016

I have a repository with all my kubernetes pods folders, in each folder I have 2 files, let's say I have one folder name "MyApp", so in this folder I have:

controller.yaml that looks like this: (this is my 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 that looks like this:

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

Now, I run kubectl get services to list all my services, and I get:

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

Why do I not get all of the services I have?

-- JohnBigs
amazon-web-services
cluster-computing
kubernetes
kubernetes-health-check

1 Answer

4/15/2016

You have 1 Service, and 1 ReplicationController

You need first to create both:

kubectl create -f service.yaml

and

kubectl create -f controller.yaml

Then with:

kubectl get services shows the Service

kubectl get rc shows ReplicationControllers

kubectl get pods shows the Pods deployed by the ReplicationController.

-- MrE
Source: StackOverflow