Kahibaro
Discord Login Register

6.4 Projects and namespaces

Understanding Projects and Namespaces in OpenShift

OpenShift builds on top of Kubernetes namespaces, but adds extra opinionated behavior and features. In practice, you almost never create “raw” namespaces in OpenShift; you work with Projects, which are an OpenShift extension around namespaces.

This chapter focuses on how Projects and namespaces behave in OpenShift, how they are used to organize and isolate workloads, and what is unique compared to plain Kubernetes.


Conceptual model: Project vs Namespace

In OpenShift:

You can think of it as:

You generally interact with Projects via:

The underlying Namespace is visible with oc get ns, but usually you don’t manipulate it directly.


Why Projects matter in daily work

Projects are the primary unit for:

Basic operations with Projects (CLI)

Listing and switching Projects

Use oc to view and switch your current working Project:

# List all Projects you can see
oc get projects
# Show the current Project
oc project
# Switch to another Project
oc project my-app-dev

The current Project is stored in your kubeconfig context, so subsequent oc commands (like oc get pods) run against that Project unless you override it with -n or --namespace.

Creating a Project

Creating a Project automatically creates the underlying Namespace and applies default policies:

# Create a new Project
oc new-project my-app-dev \
  --display-name="My App - Development" \
  --description="Development environment for My App team"

Key aspects:

Deleting a Project

Deleting a Project cascades and deletes everything in that Namespace:

oc delete project my-app-dev

This:

Deletion is irreversible, so it’s typically restricted to users with sufficient permissions.


Projects in the web console

From the OpenShift web console:

For everyday application work, you typically:

  1. Select the Project.
  2. Deploy applications, create Services, Routes, PVCs, etc., all scoped to that Project.
  3. Rarely think about the underlying Namespace directly.

Namespaces behind the scenes

Though you work with Projects, the underlying Kubernetes Namespace is what actually provides resource scoping:

You can see the underlying Namespace with:

oc get ns

You’ll notice that:

You generally should not modify system namespaces unless explicitly performing cluster administration tasks.


Access control within Projects

Role-Based Access Control (RBAC) in OpenShift is commonly applied per Project:

Examples (from an admin perspective):

# See who has access to a Project (roles and bindings)
oc get rolebindings -n my-app-dev
# Add a user as "edit" in a Project
oc adm policy add-role-to-user edit alice -n my-app-dev
# Add a group as "view" in a Project
oc adm policy add-role-to-group view dev-team -n my-app-dev

From a regular user view, the important part is:

Organizing Projects: patterns and conventions

How you structure Projects has a big impact on clarity, isolation, and governance.

Typical patterns:

Environment-based separation

Benefits:

Team- or domain-based separation

Each team might then organize their workloads within their team Project using naming conventions for resources.

Multi-tenant clusters

In larger organizations:

Naming conventions

Common recommendations:

Consistent naming makes it easier to:

Resource governance in Projects (high-level)

Projects are the unit where cluster administrators typically attach:

From a user’s perspective, this means:

You can inspect these:

# Show quotas in a Project
oc get resourcequota -n my-app-dev
# Show limit ranges in a Project
oc get limitrange -n my-app-dev

Details of configuring and tuning these are covered in other chapters; here, understand that they are scoped to and enforced per Project.


Cross-project interactions and isolation

By default:

Common scenarios:

If network policies are used, they are often defined per Project to control which other Projects can talk to it.


Working effectively with Projects as a developer

Practical tips:

Summary

Views: 122

Comments

Please login to add a comment.

Don't have an account? Register now!