kubectl: Kubectl edit: `--show-managed-fields` does nothing

What happened?

I edited an object like so kubectl edit svc my-server --show-managed-fields and epected to see managed fields but didn’t. When using kubectl get -oyaml --show-managed-fields they are shown

What did you expect to happen?

See managed fields

How can we reproduce it (as minimally and precisely as possible)?

kubectl edit some-type some-name --show-managed-fields

Anything else we need to know?

No response

Kubernetes version

$ kubectl version
$ k version --client --short
Flag --short has been deprecated, and will be removed in the future. The --short output will become the default.
Client Version: v1.25.3
Kustomize Version: v4.5.7
# paste output here

Cloud provider

AWS

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, …) and versions (if applicable)

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 18 (13 by maintainers)

Commits related to this issue

Most upvoted comments

I’m fine with that as long as users are warned or get an error if they do try to change them (rather than silently not doing what they asked for).

I think we should make edit use SSA in the future, then.

I guess I don’t object to showing the field as long as it prevents you from modifying it? If people get into the habit of modifying it we wouldn’t be able to use SSA in the future…

kubectl edit, contrary to say -o yaml uses an actual editor to open the manifest, so you get highlighting. Not showing it by default as for other commands makes total sense, but it would be nice to have the option to see it.

managedFields is read only and set by the apiserver. I would have assumed that kubectl knows this through openapi and refuses an edit that changes it already though?