Kubernetes: Unable to create replicaSet: error: no objects passed to create

2/15/2018

I'm trying to create replicaSet in kubernetes by using below yaml file.

            apiVersion: apps/v1
            kind: ReplicaSet
            metadata:
                name: kubia
            spec:
                replicas: 2
                selector:
                    matchLabels:
                        app: kubia
                    template:
                        metadata:
                            labels:
                                app: kubia
                        spec:
                            containers: 
                            - name: kubia
                                image: luksa/kubia

Then I run the below command

$ kubectl create -f replicaSet/kubia-replicaset.yaml

This command gave me the below error

 error: no objects passed to create

Any idea why I'm getting this error. How to resolve this error and successfully create the replicaSet?

-- Rajkumar Natarajan
google-kubernetes-engine
kubernetes

2 Answers

2/15/2018

error: unable to recognize "kubia-replicaset.yaml": no matches for apps/, Kind=ReplicaSet

Means that GKE does not recognize ReplicaSet within apiVersion: apps/v1 I checked my cluster (I normally use deployments), pulled my replicaSet and it shows up as:

apiVersion: extensions/v1beta1
kind: ReplicaSet

The apiVersion will depend on the Kubernetes version you are using with your cluster. app/v1 is for 1.9.0 and up, anything earlier still uses v1beta1.

-- Patrick W
Source: StackOverflow

2/15/2018

This image should be parallel to name

containers: 
    - name: kubia
      image: luksa/kubia
-- Nitish Kumar
Source: StackOverflow