Difference between revisions of "Yq"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
+ | ## Install | ||
+ | ``` | ||
+ | curl -LO https://github.com/mikefarah/yq/releases/download/v4.34.1/yq_linux_amd64.tar.gz | ||
+ | tar xf yq_linux_amd64.tar.gz | ||
+ | sudo cp yq_linux_amd64 /usr/local/bin/yq | ||
+ | ``` | ||
+ | |||
https://mikefarah.gitbook.io/yq/usage/tips-and-tricks | https://mikefarah.gitbook.io/yq/usage/tips-and-tricks | ||
Revision as of 00:57, 5 June 2023
Install
curl -LO https://github.com/mikefarah/yq/releases/download/v4.34.1/yq_linux_amd64.tar.gz tar xf yq_linux_amd64.tar.gz sudo cp yq_linux_amd64 /usr/local/bin/yq
https://mikefarah.gitbook.io/yq/usage/tips-and-tricks
kubectl get configMap zabbix-server -oyaml | yq eval 'del(.metadata.resourceVersion, .metadata.uid, .metadata.annotations, .metadata.creationTimestamp, .metadata.selfLink, .metadata.managedFields)' -
https://github.com/mikefarah/yq
Dump all
mkdir -p tmp cd tmp for OBJ in $(kubectl api-resources --verbs=list --namespaced -o name) do for DEF in $(kubectl get --show-kind --ignore-not-found $OBJ -o name) do mkdir -p $(dirname $DEF) echo $DEF kubectl get $DEF -o yaml \ | yq eval 'del(.metadata.resourceVersion, .metadata.uid, .metadata.annotations, .metadata.creationTimestamp, .metadata.selfLink, .metadata.managedFields)' - > $DEF.yaml done
env vars
https://mikefarah.gitbook.io/yq/operators/env-variable-operators
yq '(.. | select(tag == "!!str")) |= envsubst(nu, ff)' text.yqenv
Ref: