Skip to content
Tutorials Center
My learning

Topics

Lesson 9 of 37 ยท Projects and Workloads

Projects and Namespaces

Create OpenShift projects, grant roles to teammates, understand project templates, quotas and default network isolation, and plan a project layout for teams.

A project is the boundary inside which you deploy applications. It isolates names, permissions, quotas and (optionally) network traffic. In Kubernetes terms it is a namespace; OpenShift's Project object adds a display name, a description and a self-service creation flow.

Creating and switching

Terminal
oc new-project shop-dev --display-name="Shop (dev)" --description="Dev environment for the shop team"
oc projects
oc project shop-dev
oc get project shop-dev -o yaml

When you create a project, OpenShift makes the namespace, gives you the admin role in it, applies a project template (platform defaults) and sets up the service accounts the project needs. Projects whose names start with openshift- or kube- belong to the platform; do not deploy there.

On clusters where self-provisioning is disabled, an administrator creates projects for you with oc adm new-project or a request process.

Built-in service accounts and the project template

Every new project contains three service accounts: default (used by Pods that name no other account), builder (used by builds to push images) and deployer (used by deployment helpers). A project template is a cluster-wide object that decides what else a new project contains, such as a default ResourceQuota, a LimitRange or NetworkPolicy objects. Administrators customize it so every team starts from a safe baseline.

Roles: who can do what

Access is controlled with RBAC (role-based access control). A role is a set of allowed verbs on resource kinds; a role binding gives a role to a user, group or service account inside a project.

Role What it allows
admin Manage everything in the project, including roles
edit Create and change workloads, but not roles
view Read only
basic-user See basic project info
Terminal
oc adm policy add-role-to-user edit alice -n shop-dev
oc adm policy add-role-to-user view bob -n shop-dev
oc adm policy add-role-to-group edit shop-developers -n shop-dev
oc get rolebindings -n shop-dev
oc auth can-i delete deployments -n shop-dev --as=bob

Prefer groups to individual users once a team has more than a few people. Groups usually come from your identity provider (LDAP, OIDC and so on).

Isolation between projects

Projects separate names and permissions by default. Whether Pods can talk to each other across projects depends on the network configuration. Many clusters apply a NetworkPolicy baseline to new projects: allow traffic from the router and from the same project, deny the rest. The networking chapter shows how to write these policies. Never assume projects are isolated at network level until you have checked.

flowchart LR
  subgraph A["Project shop-dev"]
    A1["web Pods"] --> A2["db Pods"]
  end
  subgraph B["Project payments"]
    B1["api Pods"]
  end
  A1 -. blocked unless policy allows .-> B1

Figure: a project is a boundary for names, roles and (with policies) traffic.

Quotas and limits

Because many teams share a cluster, administrators cap what each project may consume with a ResourceQuota, and set defaults and maximums for single containers with a LimitRange. Both appear in Requests, limits and quotas. You can read your own limits any time:

Terminal
oc describe quota -n shop-dev
oc describe limitrange -n shop-dev

A project layout that works

Common patterns for a team:

  • One project per environment per application: shop-dev, shop-test, shop-prod. Easy permissions (developers edit dev, only a release group edits prod) and quotas.
  • One project per team with many apps: fewer projects, more shared fate. Fine for small teams.
  • Shared tooling projects such as cicd for pipelines.

A cluster-per-environment layout is also common for prod. Whatever you choose, keep the rule that production access is narrower than development access.

Deleting a project

Terminal
oc delete project shop-dev

Deleting a project deletes everything inside it, including Secrets and PersistentVolumeClaims (the data behind some volumes may go with them, depending on reclaim policy). It happens in the background; the project shows Terminating until finished. Confirm the name twice.

Stand-in: who can do what?

The stand-in below models the four built-in roles as verb sets so you can test a request. It is simplified: real RBAC works on API groups, resources and verbs with many more rules.

Python Stand-in: simplified project RBAC check

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Stand-in: planning environment projects

Python Stand-in: generate project names and bindings

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The printed lines are the commands you would run; the stand-in only prints them.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is a Project in OpenShift?

    A Project wraps a Kubernetes Namespace and adds a display name, description and a creation flow that sets you as admin.
  2. 2. Which role lets a user change workloads but not manage roles?

    edit can create and modify objects in the project. Only admin can manage role bindings.
  3. 3. What does oc delete project do to objects inside it?

    Deleting a project removes its namespace and all objects within it.
  4. 4. Why are groups preferred to individual users for role bindings?

    With groups, you change membership in the identity provider instead of editing many role bindings.

Summary

  • A project is a namespace with metadata and a self-service creation flow; the creator becomes admin.
  • Roles (admin, edit, view) are granted with oc adm policy add-role-to-user/group.
  • Projects separate names and permissions; network isolation depends on NetworkPolicy.
  • Quotas and LimitRanges protect shared clusters.
  • Deleting a project deletes everything inside it.

Next: Deployments and Rollouts