Skip to content

Instantly share code, notes, and snippets.

@frgomes

frgomes/kubectl_helpers.sh

Last active Aug 18, 2019
Embed
What would you like to do?
k8s: find cluster names in kubectl configuration
#!/bin/bash
// one-liner which converts YAML to JSON
function yaml2json {
python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print(json.dumps(y))'
}
function kubectl_clusters {
cat ~/.kube/config | yaml2json | jq '.clusters[].name' | sed 's/"//g'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment