KAHIBARO Bookshelves
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:

  • A Namespace is the Kubernetes primitive used for logical isolation of resources.
  • A Project is an OpenShift resource that:
    • wraps a Namespace,
    • adds metadata and defaults (like Security Context Constraints, quotas, and roles),
    • is the main user-facing unit for working with applications.

You can think of it as:

  • Every Project corresponds to exactly one Namespace.
  • When you create a Project, OpenShift:
    • creates a Namespace with the same name,
    • sets up RBAC roles and bindings,
    • may assign default ResourceQuotas and LimitRanges,
    • labels/annotates it for OpenShift-specific behavior.

You generally interact with Projects via:

  • Web console “Projects” view
  • CLI oc new-project, oc project, oc get projects

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:

  • Multi-tenancy and isolation
    Each team, app, or environment (dev/test/prod) typically gets its own Project.
  • Access control
    All RBAC rules are mostly scoped to a Project:
    • “Developers can manage resources in team-a”
    • “Ops can view but not modify in prod-app”
  • Resource governance
    Quotas, limits, and security constraints are attached per Project.
  • Organization
    Logical grouping of resources (Deployments, Services, Routes, PVCs, etc.) that belong to one application or team.

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:

  • my-app-dev is both the Project name and the Namespace name.
  • display-name and description are user-friendly metadata shown in the web console.
  • OpenShift may apply default:
    • roles (e.g., making you an admin of the Project),
    • quotas/limits (if configured cluster-wide),
    • annotations/labels for policy.

Deleting a Project

Deleting a Project cascades and deletes everything in that Namespace:

oc delete project my-app-dev

This:

  • removes Deployments, Pods, Services, Routes, PVCs, and most other namespaced resources,
  • marks the Namespace for deletion; it might remain in Terminating state if some resources block it.

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


Projects in the web console

From the OpenShift web console:

  • Project selection: The project selector at the top allows switching context. All views (Workloads, Networking, Storage) are filtered by the currently selected Project.
  • Creating Projects:
    • Use “Create Project” or “Create” → “Project”.
    • Provide name, display name, and description.
  • Viewing Project details:
    • See quotas, limits, role bindings, labels, and annotations.
    • Some settings may be read-only for non-admins.

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:

  • Most Kubernetes/OpenShift resources are namespaced:
    • Deployment, Pod, Service, Route, ConfigMap, Secret, PVC, etc.
  • Some resources are cluster-scoped (not tied to a Namespace):
    • Node, ClusterRole, ClusterOperator, StorageClass, etc.

You can see the underlying Namespace with:

oc get ns

You’ll notice that:

  • User-facing Projects appear as namespaces.
  • Many system namespaces exist, for example:
    • openshift-* (OpenShift platform components),
    • kube-* (core Kubernetes components).

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:

  • Users and groups are granted roles within a Project:
    • e.g., edit, view, admin.
  • These determine what operations a user can perform on namespaced resources in that 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:

  • If you can’t see or modify a resource, you may not have appropriate role in that Project.
  • Permissions are per Project, so you might be an admin in my-app-dev but read-only in my-app-prod.

Organizing Projects: patterns and conventions

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

Typical patterns:

Environment-based separation

  • my-app-dev
  • my-app-test
  • my-app-prod

Benefits:

  • Clear separation of environments.
  • Different teams or permissions per environment.
  • Different quotas/limits and policies per environment.

Team- or domain-based separation

  • team-a
  • team-b
  • data-platform
  • analytics

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

Multi-tenant clusters

In larger organizations:

  • Projects map to tenants (teams, business units, customers).
  • Per-Project quotas and network policies help enforce strong isolation.
  • Central platform team manages policy; app teams work inside their Projects.

Naming conventions

Common recommendations:

  • Use lowercase alphanumeric and -.
  • Prefer meaningful, consistent patterns:
    • team-app-env (e.g., payments-api-dev)
    • org-domain-env (e.g., acme-billing-prod)

Consistent naming makes it easier to:

  • Filter in the UI/CLI.
  • Apply policies or automation that match on naming or labels.

Resource governance in Projects (high-level)

Projects are the unit where cluster administrators typically attach:

  • ResourceQuotas (overall caps on CPU, memory, number of objects, etc.).
  • LimitRanges (default and maximum container resource requests/limits).
  • Security Context Constraints (SCCs) usage (what security settings pods can use).

From a user’s perspective, this means:

  • If you exceed quota in a Project, new Pods or PVCs may fail to create.
  • If you don’t specify CPU/memory for Pods, defaults from LimitRanges may be applied.
  • Some security-sensitive configurations (e.g., running as root) might be blocked depending on Project policies.

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:

  • Resources in one Project are logically isolated from another.
  • Pods in one Project can’t directly reference objects in another Project.
  • Network communication between Projects may be allowed or restricted depending on cluster network policies.

Common scenarios:

  • Shared services (e.g., a central logging or database Project):
    • Access via Routes, external Services, or (with proper permissions) by referencing cluster-scoped constructs like StorageClass.
  • CI/CD:
    • Pipelines may deploy to multiple Projects (e.g., dev → test → prod),
    • but each environment is still isolated by its own Project.

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:

  • Always know your current Project before running commands:
    • oc project or check the context in the web console.
  • Use namespaces explicitly when scripting:
    • Prefer -n my-app-dev in scripts and automation to avoid mistakes.
  • Request appropriate roles:
    • If you can’t create Deployments or Routes, you may need edit or admin in that Project.
  • Treat Projects as boundaries:
    • Don’t rely on cross-project assumptions.
    • Keep configs, Secrets, and PVCs within the Project that owns the application.

Summary

  • A Project in OpenShift is a higher-level construct that wraps a Kubernetes Namespace and adds OpenShift-specific metadata and defaults.
  • Projects are the central unit for:
    • isolating workloads,
    • applying RBAC,
    • attaching quotas, limits, and security policies.
  • You normally create and manage Projects, not raw Namespaces, via:
    • oc new-project, oc project, and the web console.
  • Project design (naming, environment separation, team mapping) strongly influences how manageable and secure your OpenShift usage becomes.

Views: 0

Comments

Please login to add a comment.

Don't have an account? Register now!

Where to Move

Move chapter:

  • ☰ 1. Course Overview
    • ☰ 1.1. What is OpenShift
      • ☰ 1.2. Why OpenShift is used in modern IT and cloud environments
        • ☰ 1.3. OpenShift vs Kubernetes
          • ☰ 1.4. Typical OpenShift use cases
            • ☰ 1.5. Structure and goals of the course
            • ☰ 2. Containers and Cloud-Native Fundamentals
              • ☰ 2.1. What is a container
                • ☰ 2.2. Containers vs virtual machines
                  • ☰ 2.3. Introduction to Docker and container images
                    • ☰ 2.4. Container registries
                      • ☰ 2.5. Basics of cloud-native applications
                      • ☰ 3. Kubernetes Fundamentals
                        • ☰ 3.1. What is Kubernetes
                          • ☰ 3.2. Kubernetes architecture
                            • ☰ 3.3. Control plane components
                              • ☰ 3.4. Worker node components
                                • ☰ 3.5. Kubernetes objects and resources
                                  • ☰ 3.6. Declarative configuration model
                                  • ☰ 4. OpenShift Architecture
                                    • ☰ 4.1. Overview of OpenShift architecture
                                      • ☰ 4.2. Control plane in OpenShift
                                        • ☰ 4.3. Nodes and machine roles
                                          • ☰ 4.4. OpenShift Operators
                                            • ☰ 4.5. OpenShift networking model
                                              • ☰ 4.6. OpenShift storage model
                                              • ☰ 5. OpenShift Installation and Deployment Models
                                                • ☰ 5.1. OpenShift deployment options
                                                  • ☰ 5.2. Installer-Provisioned Infrastructure
                                                    • ☰ 5.3. User-Provisioned Infrastructure
                                                      • ☰ 5.4. Managed OpenShift services
                                                        • ☰ 5.5. Single-node OpenShift
                                                          • ☰ 5.6. Cluster lifecycle management
                                                          • ☰ 6. Accessing and Using OpenShift
                                                            • ☰ 6.1. OpenShift web console
                                                              • ☰ 6.2. OpenShift CLI (oc)
                                                                • ☰ 6.3. Authentication and authorization
                                                                  • ☰ 6.4. Projects and namespaces
                                                                    • ☰ 6.5. Resource quotas and limits
                                                                    • ☰ 7. Building and Deploying Applications
                                                                      • ☰ 7.1. Application deployment concepts
                                                                        • ☰ 7.2. Source-to-Image (S2I)
                                                                          • ☰ 7.3. Container-based deployments
                                                                            • ☰ 7.4. DeploymentConfigs and Deployments
                                                                              • ☰ 7.5. Rolling updates and rollbacks
                                                                              • ☰ 8. Networking in OpenShift
                                                                                • ☰ 8.1. Services and service discovery
                                                                                  • ☰ 8.2. Routes and ingress
                                                                                    • ☰ 8.3. Network policies
                                                                                      • ☰ 8.4. Load balancing
                                                                                        • ☰ 8.5. External access to applications
                                                                                        • ☰ 9. Storage in OpenShift
                                                                                          • ☰ 9.1. Persistent storage concepts
                                                                                            • ☰ 9.2. Persistent Volumes
                                                                                              • ☰ 9.3. Persistent Volume Claims
                                                                                                • ☰ 9.4. StorageClasses
                                                                                                  • ☰ 9.5. Dynamic provisioning
                                                                                                    • ☰ 9.6. Stateful applications
                                                                                                    • ☰ 10. Configuration and Secrets Management
                                                                                                      • ☰ 10.1. ConfigMaps
                                                                                                        • ☰ 10.2. Secrets
                                                                                                          • ☰ 10.3. Environment variables
                                                                                                            • ☰ 10.4. Managing sensitive data
                                                                                                              • ☰ 10.5. Best practices for configuration
                                                                                                              • ☰ 11. Scaling and High Availability
                                                                                                                • ☰ 11.1. Horizontal pod autoscaling
                                                                                                                  • ☰ 11.2. Vertical scaling
                                                                                                                    • ☰ 11.3. Self-healing and pod restarts
                                                                                                                      • ☰ 11.4. High availability concepts
                                                                                                                        • ☰ 11.5. Multi-zone and multi-region clusters
                                                                                                                        • ☰ 12. Monitoring, Logging, and Observability
                                                                                                                          • ☰ 12.1. Built-in monitoring stack
                                                                                                                            • ☰ 12.2. Metrics and alerts
                                                                                                                              • ☰ 12.3. Logging architecture
                                                                                                                                • ☰ 12.4. Distributed tracing
                                                                                                                                  • ☰ 12.5. Troubleshooting applications
                                                                                                                                  • ☰ 13. Security in OpenShift
                                                                                                                                    • ☰ 13.1. Security model overview
                                                                                                                                      • ☰ 13.2. Role-Based Access Control
                                                                                                                                        • ☰ 13.3. Security Context Constraints
                                                                                                                                          • ☰ 13.4. Image security and scanning
                                                                                                                                            • ☰ 13.5. Network security
                                                                                                                                              • ☰ 13.6. Compliance and auditing
                                                                                                                                              • ☰ 14. CI/CD and DevOps with OpenShift
                                                                                                                                                • ☰ 14.1. DevOps concepts
                                                                                                                                                  • ☰ 14.2. CI/CD pipelines overview
                                                                                                                                                    • ☰ 14.3. OpenShift Pipelines (Tekton)
                                                                                                                                                      • ☰ 14.4. GitOps with Argo CD
                                                                                                                                                        • ☰ 14.5. Integrating OpenShift with external CI tools
                                                                                                                                                        • ☰ 15. Operators and Platform Services
                                                                                                                                                          • ☰ 15.1. What are Operators
                                                                                                                                                            • ☰ 15.2. Operator Lifecycle Manager
                                                                                                                                                              • ☰ 15.3. Installing and managing Operators
                                                                                                                                                                • ☰ 15.4. Common platform Operators
                                                                                                                                                                  • ☰ 15.5. Custom Operators
                                                                                                                                                                  • ☰ 16. Upgrades, Maintenance, and Operations
                                                                                                                                                                    • ☰ 16.1. OpenShift upgrade process
                                                                                                                                                                      • ☰ 16.2. Backup and restore
                                                                                                                                                                        • ☰ 16.3. Node maintenance
                                                                                                                                                                          • ☰ 16.4. Cluster troubleshooting
                                                                                                                                                                            • ☰ 16.5. Capacity planning
                                                                                                                                                                            • ☰ 17. OpenShift on HPC and Specialized Workloads
                                                                                                                                                                              • ☰ 17.1. Running batch workloads on OpenShift
                                                                                                                                                                                • ☰ 17.2. OpenShift and GPUs
                                                                                                                                                                                  • ☰ 17.3. MPI and parallel workloads in containers
                                                                                                                                                                                    • ☰ 17.4. Hybrid HPC and cloud workflows
                                                                                                                                                                                    • ☰ 18. OpenShift in Practice
                                                                                                                                                                                      • ☰ 18.1. Typical OpenShift workflows
                                                                                                                                                                                        • ☰ 18.2. Development to production lifecycle
                                                                                                                                                                                          • ☰ 18.3. Case studies from industry
                                                                                                                                                                                            • ☰ 18.4. Common pitfalls and best practices
                                                                                                                                                                                            • ☰ 19. Future Directions and Ecosystem
                                                                                                                                                                                              • ☰ 19.1. Kubernetes ecosystem overview
                                                                                                                                                                                                • ☰ 19.2. OpenShift roadmap
                                                                                                                                                                                                  • ☰ 19.3. Serverless and event-driven workloads
                                                                                                                                                                                                    • ☰ 19.4. AI and data platforms on OpenShift
                                                                                                                                                                                                    • ☰ 20. Final Project and Hands-On Exercises
                                                                                                                                                                                                      • ☰ 20.1. Deploying a containerized application
                                                                                                                                                                                                        • ☰ 20.2. Implementing CI/CD with OpenShift
                                                                                                                                                                                                          • ☰ 20.3. Securing and scaling an application
                                                                                                                                                                                                            • ☰ 20.4. Monitoring and troubleshooting report