if you have access to the etcd server, you can use the following steps to try etcd v3 API to fetch Kubernetes cluster data
- set environment to use v3 API
# set ETCDCTL_API
export ETCDCTL_API=3- use
etcdctltool to fetch all the namespaces
# fetch all the namespaces
etcd get /registry/namespaces --prefix -w json | jq .
# as the key and value stored in etcd have been base64-encoded, you need to decode it if you want to know what exactly they are.
etcd get /registry/namespaces --prefix -w json | jq . 'kvs[] | .value' | tr -d \" | base64 -d-
use
etcdctltool to fetch all the events -
use
etcdctltoo to fetch all the metadata structure
keys=`etcdctl get /registry --prefix -w json|python -m json.tool|grep key|cut -d ":" -f2|tr -d '"'|tr -d ","`
for x in $keys;do
echo $x|base64 -d|sort
done- get all keys via v3 api
etcdctl get "" --prefix --keys-only # u will get blank lines
etcdctl get "" --prefix --keys-only | sed '/^\s*$/d' # u will get keys without blanklines