kubernetes - Kubectl GKE 持久卷声明

标签 kubernetes google-kubernetes-engine

各位,当运行以下 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 答案的补充,并且 我的目的是提供有关此问题的更多见解来帮助社区。

根据 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.

即使运行更新的客户端版本也可能会给您带来一些问题

  • 在 K8s 1.10 中 kubectl run有创建部署的默认行为:
❯ ./kubectl-110 run ubuntu --image=ubuntu          
deployment.apps "ubuntu" created
  • 从 1.12 开始,kubectl rundeprecated对于除 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/

相关文章:

kubernetes - 使用Kubernetes kubeadm和minikube在VM中创建节点

kubernetes - GKE 入口 : http status code 413 Request entity too large

kubernetes - 在 GKE 中安装 istio 时出错 = 服务器找不到请求的资源(发布 `gatewaies.networking.istio.io`)

java - kubernetes 中服务的 Java 应用程序中的服务器配置

kubernetes - 外部请求通过 Ingress 进入 k8s pod 的具体流程图是怎样的?

kubernetes - kubernetes efk:fluentd的 'filter'过滤什么?

.net - 如何从 kubernetes 部署配置文件中的 helm 获取运行时设置以覆盖 asp.net 中的 appsettings

kubernetes - GKE 是否需要 prometheus-to-sd?我可以删除它吗?

kubernetes - G8 v1.16.13-gke.401中不提供K8S api cloud.google.com

go - 使用 kubernetes 从不同的服务连接到 Redis 服务