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

21.7k views Asked by At

I have aws-eks cluster and below is my command to replace existing the configuration.

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

but when I run this command. it gives an error like

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

Will it do the same thing If I replace -dry-run to -dry-run=client?

1

There are 1 answers

1
Daniel Marques On BEST ANSWER

About dry-run=client we learn

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

And in the kubernetes API reference we read:

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.

Performing local tests I realized that when I try to replace an existing config object using dry-run=server, the following error occurs. The apiserver told us that already exist a configmap with the name flink-config.

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

However is I try with to use dry-run=client the object is not validated by the apiserver, that is, just by the client, so the yaml is printed to us:

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

So basically, yes, the dry-run=client it has the same effect than the deprecated dry-run. The equivalent flag for dry-run=server was --server-dry-run and became deprecated in v1.18.