首先获取 secret:
kubectl get secrets
Output:
NAME TYPE DATA AGE
default-token-skm7e kubernetes.io/service-account-token 3 16d
kubectl describe secret default-token-skm7e
token=$(kubectl describe secret $(kubectl get secrets | grep default-token | gawk '{ print $1 }') | grep token: | gawk '{ print $2 }')
echo $token
获取 token 字段的值,将 ${token}
替换为实际值,-k
为跳过 TLS 验证:
curl -k https://localhost:6443/api/v1/watch/pods?watch=yes -H "Authorization: Bearer ${token}"
网友评论