各位,当运行以下 kubectl 命令时:
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版本
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 答案的补充,并且 我的目的是提供有关此问题的更多见解来帮助社区。li>
根据 Kubernetes Version Skew Policy :
kubectl
is supported within one minor version (older or newer) ofkube-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.
- kubernetes 的每次更新都会添加、更改、移动、弃用或删除许多组件。这是Kubernetes Changelog of version 1.15 .
即使运行更新的客户端版本也可能会给您带来一些问题
- 在 K8s 1.10 中
kubectl run
有创建部署的默认行为:
❯ ./kubectl-110 run ubuntu --image=ubuntu
deployment.apps "ubuntu" created
- 从 1.12 开始,
kubectl run
是deprecated对于除 Pod 之外的所有生成器,以下是 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)
- 除了警告之外,它仍然按预期工作,但 changed在 K8s 1.18 客户端中:
❯ ./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)
它忽略了该标志并仅创建了一个 Pod。正如我们在测试中看到的,kubernetes 1.15 支持该标志,但 kubectl 1.18 进行了重大更改,不允许运行它。
- 这是一个简单的示例,旨在说明在 Kubernetes 上遵循倾斜策略的重要性,它可以在将来节省大量故障排除时间!
关于kubernetes - Kubectl GKE 持久卷声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61450535/