Bartosz Bierkowski - Low dose cloud

OpenShift: working with multiple accounts, projects and servers

I often find myself switching between projects or using a service account to test something. To work with multiple projects I usually create an alias per namespace to quickly execute commands.

To use multiple accounts similar aliases can be created

To work with other clusters, you will can add –server besides the token parameter.

The more contexts, the more fun to manage and store them. Instead of doing it in shell files it might be easier to learn about .kube/config  file.

Kubernetes config file

It contains information used during oc login . There are three main components: users, clusters and contexts. You can configure them individually and manage your access in .kube/config  instead of in aliases.


Stores credential information about users. Each of them is named and can be referenced in the context. You can set token, user and password, client certificate or auth provider.


This describes the server and allows the same settings as oc login . Besides specifying the server, you can provide --insecure-skip-tls-verify  flag, which is useful for working with minishift. Certificate authority can be provided instead of it.


Contexts bind together users, clusters and used project/namespace.

Working with multiple contexts

Having setup your config with the instructions above, the file looks like this:

Now the aliases can be used only for specific contexts and the details are managed in the config file.

You can update token for single user and all your contexts will use it. Also namespace changes will be preserved in the config. Working with one context does not affect others as seen below

When to use it?

Consider it if you deal with multiple projects, clusters or work using different users. Credentials and servers can be easily managed even on daily basis.


You can learn more about commands offered by oc config in:

OpenShift: Managing CLI Profiles

Authenticating Across Clusters with kubeconfig


The commands were executed using minishift and the following client/server versions of OpenShift.

oc v1.4.1+3f9807a
client kubernetes v1.4.0+776c994
openshift v1.4.1
server kubernetes v1.4.0+776c994


Thanks for reading about OpenShift. To get updates about new articles, you can sign up to the newsletter below.

As a thank you message, you will also get access to OpenShift CLI CheatSheet listing most commonly used commands together with a short explanation.

Did you like the article?
Join the newsletter to receive notifications about new articles.
I respect your privacy.