OpenShift - Create a Project

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

Before creating a new project, you might want to use the oc get templates command to determine if there is a template in the openshift-config project / namespace. 

~]$ oc get templates --namespace openshift-config
project-request                 5 (5 blank)   3


If there is a template in the openshift-config namespace, use the oc describe command to determine if is configured to use the template. If so, the template in the openshift-config namespace is being used to define default settings when a project is created.

~]$ oc describe
  Project Request Template:
    Name:  project-request


The oc new-project command is used to create a project. In this example, a project named "foo" is created.

oc new-project foo


Or, a JSON or YAML file that contains key value pairs used to create an object, such as a config map, deployment, a project, a pod, a route, a secret, a service, et cetera. These files are known as templates. The oc explain command can be used to get the list of keys that can be used in the JSON or YAML template file.

oc explain namespace


And then more details on each key can be displayed.

oc explain namespace.spec


For example, let's say you have a YAML file named namespace.yml that contains the following markup. Notice "kind: Namespace", which means this template will be used to create a project / namespace.

In this example, the project / namespace named "foo" will be created.

apiVersion: v1
kind: Namespace
  name: foo


The oc apply or oc create command with the -f or --filename option can be used to create the project / namespace using the template JSON or YAML file.

The oc replace command can be used to replace a project / namespace using a new or updated template JSON or YAML file.

The oc edit command can be used to update a project / namespace template YAML file.

~]# oc create -f foo.yml
namespace/foo created


If the project is successfully created, the following should be displayed.

Now using project "foo" on server "".

You can add applications to this project with the 'new-app' command. For example, try:

    oc new-app centos/ruby-25-centos7~

to build a new example application in Ruby.


If you attempt to create a project that already exists, the following will be displayed.

Error from server (AlreadyExists): "foo" already exists


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 530a0 in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |