Answers: <p>Alternatively run <code>grep current-context ~/.kube/config</code> to see the current context.</p>
  <p>If it's not set to the desired one, edit <code>~/.kube/config</code> and change that line.</p>
  
Answers: CC BY-SA 4.0
Answers: 2024-05-20T20:09:04.723Z
Answers: 2024-05-20T20:09:04.723Z
Answers: thiagowfx
Answers: <p><code>kubectl config use-context kubernetes-admin@kubernetes</code> should be the command you are lookin for.</p>
  <p>To check if it worked, use <code>kubectl config current-context</code>.</p>
  <p>If in doubt, check its help with <code>kubectl config set-context --help</code>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2023-08-21T21:25:34.010Z
Answers: 2023-08-21T21:25:34.010Z
Answers: eht16
Body: <p>When I do :</p>
  <pre><code>$ kubectl config get-contexts
  
  
  CURRENT   NAME                          CLUSTER                                                            AUTHINFO                                                           NAMESPACE
            kubernetes-admin@kubernetes   kubernetes                                                         kubernetes-admin
  *         qa-1                        arn:aws:eks:xxxxxx150:cluster/ocean-qa   xxx:xxx:cluster/xxxx-RH36mmA4   xx-xx-tulw
  </code></pre>
  <p>I have multiple contexts defined in the config file. I would like to set 'kubernetes-admin@kubernetes' cluster as the default each time I use kubectl.</p>
  <p>I can't find the command ..</p>
  
Tags: <kubernetes><kubectl>
Title: How to set context to be default in kubectl?
UserDisplayName: user63898
ThreadText: # How to set context to be default in kubectl?
  
  (Asked by: username_0 on 2023-08-19)
  
  When I do :
  
  ```
  $ kubectl config get-contexts
  
  CURRENT   NAME                          CLUSTER                                                            AUTHINFO                                                           NAMESPACE
            kubernetes-admin@kubernetes   kubernetes                                                         kubernetes-admin
  *         qa-1                        arn:aws:eks:xxxxxx150:cluster/ocean-qa   xxx:xxx:cluster/xxxx-RH36mmA4   xx-xx-tulw
  
  ```
  
  I have multiple contexts defined in the config file. I would like to set 'kubernetes-admin@kubernetes' cluster as the default each time I use kubectl.
  
  I can't find the command ..
  
  **Tags:** kubernetes, kubectl
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2024-05-20. Score: 0
  
  Alternatively run `grep current-context ~/.kube/config` to see the current context.
  
  If it's not set to the desired one, edit `~/.kube/config` and change that line.
  
  
  ---
  
  ### Answer by username_2 on 2023-08-21. Score: 0
  
  `kubectl config use-context kubernetes-admin@kubernetes` should be the command you are lookin for.
  
  To check if it worked, use `kubectl config current-context`.
  
  If in doubt, check its help with `kubectl config set-context --help`.
  
  
  ---
  
  