How to view full details (like a token) of context

Multi tool use
How to view full details (like a token) of context
I created a context in Kubernetes with:
kubectl config set-context --token="<JWY_token>" myservice-context
When I run:
kubectl config get-contexts
I see all the contexts:
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* minikube minikube minikube
myservice-context
I want to see more details about myservice-context
. For example, I want to see the token I just pass it while creating it.
I tried to run get-context
with the name of my service but it doesn't provide the full details:
myservice-context
get-context
$ kubectl config get-contexts myservice-context
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
myservice-context
How can I see the full details of the context (such as the token) ?
1 Answer
1
kubectl config view
will show you, though it hides some fields (like the very long embedded TLS certificates).
kubectl config view
If that's not enough information, by default the data is stored in a single YAML file, on Linux/MacOS in ~/.kube/config
, and you can open that up in a text editor.
~/.kube/config
cat ~/.kube/config
--token=<JWY_token>
~/.kube/config
is the authoritative source of information, so if it's not there, it's not there. Looking at the official documentation, I think you might want kubectl config set-credentials instead.– David Maze
Jul 1 at 12:57
~/.kube/config
It also turn out that, according to @liggitt (Jordan Liggitt), that
set-context
doesn't do anything with --token
so I probably used in the wrong place.– E235
Jul 1 at 13:52
set-context
--token
to show
REDACTED
fields in kubectl config view
you can use --show-all
argument. To manipulate tokens you can use kubeadm token list
and kubeadm token create
respectively.– Const
Jul 1 at 16:21
REDACTED
kubectl config view
--show-all
kubeadm token list
kubeadm token create
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
It seems like the solution but when run it:
cat ~/.kube/config
I see the context but not the token I added with--token=<JWY_token>
...– E235
Jul 1 at 12:44