<p>I have several gcloud accounts and thus different kubernetes' contexts.  </p>

<p>I find myself frequently switching between these using:</p>

<pre><code>$ gcloud config configurations activate ACCOUNT
$ kubectl config set-context CONTEXT
</code></pre>

<p>or alternatively</p>

<pre><code>$ gcloud config configurations activate ACCOUNT
$ kubectx CONTEXT
</code></pre>

<p>(for kubectx see <a href="https://github.com/ahmetb/kubectx" rel="nofollow noreferrer">https://github.com/ahmetb/kubectx</a>)</p>

<p>This feels like a lot of typing.  Also it also seems like if you switch gcloud accounts, that it could intuitively switch the contexts (each k8s context maps to a gcloud account).  </p>

<p>I'm curious to see other people's workflows.  Or is there a more efficient 
or conventional workflow?  </p>

<hr>

<p>The reason I need to switch both account and context is because each gcloud account has a separate email address.  So I'll get this error if I don't switch both:</p>

<pre><code>$ kubectl get pods          
Error from server (Forbidden): pods is forbidden: User 
"myemail@email.com" cannot list resource "pods" in API group "" in 
the namespace "default": Required "container.pods.list" permission.
</code></pre>

<p>Maybe there's a way to setup gcloud to allow both users in each account? 
Otherwise I'd have to switch both account and contexts.</p>

<p>I suppose the quickest way to switch is creating aliases in your ~/.bashrc or ~/.zshrc file:</p>

<pre><code>alias k8s.acct1="gcloud config configurations activate acct1; kubectx context1"
alias k8s.acct2="gcloud config configurations activate acct2; kubectx context2"
</code></pre>

<p>Another really great alternative is to set the KUBECONFIG environment variable within each console window (and you could even build alias shortcuts to quickly set this up for each session).  </p>

<p>So in one console window you run:</p>

<pre><code>export KUBECONFIG=~/acct1-kubeconfig
</code></pre>

<p>and in another window you run:</p>

<pre><code>export KUBECONFIG=~/acct2-kubeconfig
</code></pre>

<p>And then suppose you have a OpenShift cluster, you do the same:</p>

<pre><code>export KUBECONFIG=~/os-kubeconfig
</code></pre>

<p>Each console session then has kubectl access to each respective account and cluster.  </p>
