kubectl :--dry-运行 已弃用,可以替换为 --dry-运行=client

kubectl : --dry-run is deprecated and can be replaced with --dry-run=client

我有 aws-eks 集群,下面是我替换现有配置的命令。

kubectl create configmap flink-config --from-file=./config -o yaml --dry-run | kubectl replace -

但是当我运行这个命令的时候。它给出了一个错误

W1009 17:00:14.998329  323115 helpers.go:553] --dry-run is deprecated and can be replaced with --dry-run=client.

如果我替换 -dry-运行 -dry-运行=client,它会做同样的事情吗?

关于dry-run=client我们学习

--dry-run=client flag to preview the object that would be sent to your cluster, without really submitting it.

在 kubernetes API 参考文献中我们读到:

Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource.

执行本地测试我意识到,当我尝试使用 dry-run=server 替换现有配置对象时,会发生以下错误。 apiserver 告诉我们已经存在一个名为 flink-config.

的 configmap
kubectl create configmap flink-config --from-file=./config -o yaml --dry-run=server
Error from server (AlreadyExists): configmaps "flink-config" already exists

但是我尝试使用 dry-run=client 对象没有被 apiserver 验证,也就是说,只有客户端验证,所以 yaml 被打印给我们:

kubectl create configmap flink-config --from-file=./config -o yaml --dry-run=client
apiVersion: v1
data:
  config: |
    FOO: foo
    MYVAR: hello
kind: ConfigMap
metadata:
  creationTimestamp: null
  name: flink-config

所以基本上,是的,dry-run=client 它与弃用的 dry-run 具有相同的效果。 dry-run=server 的等效标志是 --server-dry-run 并在 v1.18 中弃用。