-
-
Save kokoye2007/90f3d4f8f07c7089be8d53b004ee88a7 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:
choose
bat
python-yq (for older kubectl < 1.21)
then put some aliases elsewhere:
alias kyp="ky pod"
alias kyc="ky cm"
alias kysec="ky secret"
alias kyd="ky deploy"
alias kyrs="ky rs"
alias kyj="ky job"
alias kycj="ky cj"
alias kysm="ky sm"
alias kys="ky service"
alias kysa="ky sa"
alias kyn="ky node"
alias kyh="ky hpa"
alias kyf="ky foo"
https://asciinema.org/a/441968