Kubectl GKE PersistentVolumeClaim

4/27/2020

Folks, when running the following kubectl command:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: openvpn-data-claim
  namespace: openvpn
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
error: SchemaError(io.k8s.api.autoscaling.v1.Scale): invalid object doesn't have additional properties

kubectl version

Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"15+", GitVersion:"v1.15.9-gke.24", GitCommit:"39e41a8d6b7221b901a95d3af358dea6994b4a40", GitTreeState:"clean", BuildDate:"2020-02-29T01:24:35Z", GoVersion:"go1.12.12b4", Compiler:"gc", Platform:"linux/amd64"}
-- Cmag
google-kubernetes-engine
kubernetes

2 Answers

4/27/2020
  • This answer is is an addition to @Cmag answer and my intention is to provide more insights about this issue to help the community.

According to Kubernetes Version Skew Policy:

kubectl is supported within one minor version (older or newer) of kube-apiserver.

IF kube-apiserver is at 1.15: kubectl is supported at 1.16, 1.15, and 1.14.

Note: If version skew exists between kube-apiserver instances in an HA cluster, for example kube-apiserver instances are at 1.15 and 1.14, kubectl will support only 1.15 and 1.14 since any other versions would be more than one minor version skewed.

Even running a much newer client versions may give you some issues

  • In K8s 1.10 the kubectl run had a default behavior of creating deployments:
❯ ./kubectl-110 run ubuntu --image=ubuntu          
deployment.apps "ubuntu" created
  • Starting on 1.12 the kubectl run was deprecated to all generators except pods, here is an example with kubectl 1.16:
❯ ./kubectl-116 run ubuntu --image=ubuntu --dry-run
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
deployment.apps/ubuntu created (dry run)
  • Besides the warning, it still work as intended, but it changed in K8s 1.18 client:
❯ ./kubectl-118 version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:56:40Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15+", GitVersion:"v1.15.9-gke.24", GitCommit:"39e41a8d6b7221b901a95d3af358dea6994b4a40", GitTreeState:"clean", BuildDate:"2020-02-29T01:24:35Z", GoVersion:"go1.12.12b4", Compiler:"gc", Platform:"linux/amd64"}

$ kubectl run --generator=deployment/apps.v1 ubuntu --image=ubuntu --dry-run=client
Flag --generator has been deprecated, has no effect and will be removed in the future.
pod/ubuntu created (dry run)

It ignored the flag and created only a pod. That flag is supported by kubernetes 1.15 as we saw in the test, but the kubectl 1.18 had significant changes that did not allowed running it.

  • This is a simple example to illustrate the importance to follow the skew policy on Kubernetes, it can save a lot of troubleshooting time in the future!
-- willrof
Source: StackOverflow

4/27/2020

Easily fixed by upgrading local kubectl with asdf.

asdf install kubectl 1.15.9
-- Cmag
Source: StackOverflow