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

1

12

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?

Primrose answered 9/10, 2020 at 11:40 Comment(0)
P
32

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.

Pintsize answered 9/10, 2020 at 12:39 Comment(1)
@NIrav Modi if the answer was sufficient to answer your question, please mark it as a correct answer to helping others who may have the same doubt. Here you can read about the importance of accepting questions.Pintsize

© 2022 - 2024 — McMap. All rights reserved.