Skip to content

Instantly share code, notes, and snippets.

@govindkailas
Last active July 29, 2021 11:14
Show Gist options
  • Save govindkailas/0adb0836e0abb94417ebc5c08ad28d8a to your computer and use it in GitHub Desktop.
Save govindkailas/0adb0836e0abb94417ebc5c08ad28d8a to your computer and use it in GitHub Desktop.
Get the yaml for the deployed kubernetes object/resource with out all the unwanted fields.
#yq is a pre-req
kubectl get deploy -o yaml |yq eval 'del(.metadata.resourceVersion, .metadata.uid, .metadata.annotations, .metadata.creationTimestamp, .metadata.selfLink, .metadata.managedFields, .status)' -
#if you want a more simple solution just add an alias like below to your .bashrc/.profile,
alias clean-yaml='yq eval "del(.metadata.resourceVersion, .metadata.uid, .metadata.annotations, .metadata.creationTimestamp, .metadata.selfLink, .metadata.managedFields, .status)" - '
kubectl get sts redis -o yaml | clean-yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment