Last active
October 14, 2022 17:26
-
-
Save clux/06c4277e2b3b71c6369f749ae76e4e46 to your computer and use it in GitHub Desktop.
kubectl get yaml without managedFields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# kubectl < 1.21 | |
ky() { | |
local -r resource="${1:-$(kubectl api-resources --no-headers | choose 0 | fzf)}" | |
local -r name="${2:-$(kubectl get ${resource} --no-headers | choose 0 | fzf)}" | |
kubectl get "${resource}" "${name}" -oyaml \ | |
| yq 'del(.metadata.managedFields)' -y \ | |
| bat -l=yaml --plain --theme=DarkNeon | |
} | |
# kubectl >= 1.21 | |
ky() { | |
local -r resource="${1:-$(kubectl api-resources --no-headers | choose 0 | fzf)}" | |
local -r name="${2:-$(kubectl get ${resource} --no-headers | choose 0 | fzf)}" | |
kubectl get "${resource}" "${name}" -oyaml | bat -l=yaml --plain --theme=DarkNeon | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
uses:
kubectl
< 1.21)then put some aliases elsewhere:
to avoid the double fzf prompt if you know what resource you want.
NB: you don't actually need to strip yourself if you have
kubectl >= 1.21
due to kubernetes/kubernetes#96878