Kubectl create "invalid object"

4/5/2019

I am creating namespace using kubectl with yaml. The following is my yaml configuration

apiVersion: v1
kind: Namespace
metadata:
    name: "slackishapp"
    labels:
        name: "slackishapp"

But, when I run kubectl create -f ./slackish-namespace-manifest.yaml, I got an error like the following

error: SchemaError(io.k8s.api.autoscaling.v2beta2.PodsMetricStatus): invalid object doesn't have additional properties.

What goes wrong on my yaml? I am reading about it on the documentation as well. I don't see any difference with my configuration.

-- Set Kyar Wa Lar
kubectl
kubernetes
minikube

3 Answers

4/5/2019

There is nothing wrong with your yaml but I suspect you have the wrong version of kubectl.

kubectl needs to be within 1 minor from the cluster you are using as described here.

You can check your versions with

kubectl version
-- Andreas Wederbrand
Source: StackOverflow

5/29/2019

Download the kubectl.exe on https://kubernetes.io/docs/tasks/tools/install-kubectl/#before-you-begin then replace it on Program Files\Docker\Docker\resources\bin if you have docker desktop

Like Andreas Wederbrand said, it is a version problem.

-- ibs4lif
Source: StackOverflow

4/5/2019

As a workaround, try to create your namespace within imperative mode

kubectl create ns slackishapp && kubectl label ns slackishapp name=slackishapp

And then compare existing yaml with one you have written in order to check what is missing

kubectl get ns slackishapp -o yaml --export
-- A_Suh
Source: StackOverflow