Chris Stryczynski
Chris Stryczynski

Reputation: 33921

How can I export a single kubectl context?

How can I export a single kubectl context?

My current kubectl config file has multiple contexts defined, and it would be tedious manual process to try isolate the single context from the rest.

Is this supported?

Upvotes: 6

Views: 5321

Answers (2)

SeB.Fr
SeB.Fr

Reputation: 1344

I find the previous answer incomplete. To extract a context fron the current configuration file you may use the following command and flags.

kubectl config view --minify --flatten --context=mycontext > mycontext.ctx

Upvotes: 6

Suresh Vishnoi
Suresh Vishnoi

Reputation: 18373

kubectl config view --minify will remove all information not used by current-context from the output

Upvotes: 19

Related Questions