Answers: <p>it seems you’re trying to change the config by setting a context and you’re not providing the config to the change context command. So do this</p>
  <pre><code>kubectl config --kubeconfig=infra_k8/config.yaml use-context test-sim
  </code></pre>
  <p>The setters are used when you want to add more entries to the config file, so you don’t need that command when changing context.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-08-30T05:50:15.330Z
Answers: 2020-08-30T05:55:21.587Z
Answers: 2020-08-30T05:55:21.587Z
Answers: Edward Romero
Body: <p>I have a kubernetes Config file such as:</p>
  <pre><code>apiVersion: v1
  kind: Config
  preferences: {}
  contexts:
  - context:
      cluster: test-sim-development
      namespace: test-sim
      user: developer
    name: test-sim
  </code></pre>
  <p>When I issue a command such as:</p>
  <pre><code>kubectl config --kubeconfig infra_k8/config.yaml set-context test-sim &amp;&amp; kubectl config use-context test-sim
  </code></pre>
  <p>I get back the following error output:</p>
  <pre><code>Context &quot;test-sim&quot; modified.
  error: no context exists with the name: &quot;test-sim&quot;
  </code></pre>
  <p>Why is it not finding the &quot;test-sim&quot; name? It is clearly referenced according to the <a href="https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/" rel="nofollow noreferrer">kubernetes docs.</a></p>
  
Tags: <kubernetes><kubectl>
Title: config.yaml is not setting up a new context
UserDisplayName: Nona
ThreadText: # config.yaml is not setting up a new context
  
  (Asked by: username_0 on 2020-08-30)
  
  I have a kubernetes Config file such as:
  
  ```
  apiVersion: v1
  kind: Config
  preferences: {}
  contexts:
  - context:
      cluster: test-sim-development
      namespace: test-sim
      user: developer
    name: test-sim
  
  ```
  
  When I issue a command such as:
  
  ```
  kubectl config --kubeconfig infra_k8/config.yaml set-context test-sim && kubectl config use-context test-sim
  
  ```
  
  I get back the following error output:
  
  ```
  Context "test-sim" modified.
  error: no context exists with the name: "test-sim"
  
  ```
  
  Why is it not finding the "test-sim" name? It is clearly referenced according to the [kubernetes docs.](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/)
  
  **Tags:** kubernetes, kubectl
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-08-30. Score: 1
  
  it seems you’re trying to change the config by setting a context and you’re not providing the config to the change context command. So do this
  
  ```
  kubectl config --kubeconfig=infra_k8/config.yaml use-context test-sim
  
  ```
  
  The setters are used when you want to add more entries to the config file, so you don’t need that command when changing context.
  
  
  ---
  
  