KAHIBARO Bookshelves
Discord Login Register

13. Security in OpenShift

How Security Works in OpenShift

Security in OpenShift is not an afterthought or an optional add-on. It is designed as a built-in, layered model that spans:

  • The cluster and its control plane
  • The applications and containers running in it
  • The users and automation interacting with it
  • The software supply chain that feeds it

This chapter gives a conceptual overview of OpenShift’s security model and where the main mechanisms (covered in later subsections) fit into that model.

Core Principles of OpenShift Security

OpenShift’s security design is largely driven by a few core principles:

  • Secure by default: Many potentially risky capabilities are disabled or constrained out of the box (for example, containers are not allowed to run as root by default).
  • Least privilege: Users, service accounts, and workloads are given only the permissions they need to perform their tasks, enforced through RBAC and Security Context Constraints.
  • Multi-tenancy and isolation: Multiple teams and applications can share a cluster while being logically and, where needed, network-level isolated.
  • Defense in depth: Multiple layers of protection (identity, network, runtime, image, storage, audit, etc.) limit the impact of misconfigurations or compromises.
  • Policy-driven: Security behavior is encoded as declarative policy (YAML resources, Operator-managed components) that can be versioned, reviewed, and automated.

Understanding these principles helps interpret why certain defaults and restrictions exist in OpenShift and how to work with them rather than against them.

Security Layers in an OpenShift Cluster

OpenShift security can be thought of in several interlocking layers. Later subsections of this module go deeper into specific mechanisms; here the focus is the overall picture.

1. Identity and Access at the Cluster Level

At the outermost layer, OpenShift controls:

  • Who can access the cluster (users, service accounts, automation)
  • What they can do (permissions to read, modify, or administer resources)

Key ideas:

  • Authentication: Verifying identity (for example, via OAuth, external providers like LDAP/OIDC, or kubeconfigs).
  • Authorization: Determining if an authenticated identity is allowed to perform a given action on a resource, based on Kubernetes-style RBAC.
  • Separation between human and non-human identities: People use user accounts; workloads use service accounts. These are distinct and governed by different policies.

Later in this module, Role-Based Access Control is treated in detail; here it is enough to recognize that most security-sensitive actions in OpenShift pass through this gate.

2. Project and Namespace Isolation

OpenShift uses projects (Kubernetes namespaces with additional metadata and policy) as the main multi-tenancy boundary for workloads.

Security implications of this boundary include:

  • Objects (pods, services, routes, etc.) are isolated per project; by default, one project cannot modify another’s resources.
  • Access control (RBAC) often uses projects as a scope: for example, granting a user admin in a single project but not cluster-wide.
  • Network policies and Security Context Constraints can be applied differently per project, enabling different security postures for dev, test, and prod spaces.

From a security perspective, proper project design helps:

  • Limit the blast radius of a compromised application
  • Separate duties between teams
  • Enforce different policies in different environments

3. Workload and Container Runtime Security

OpenShift puts strong guardrails around how containers run:

  • Default non-root execution: Pods are often denied the ability to run as UID 0 (root) unless explicitly allowed by policy.
  • Restricted capabilities: Linux capabilities, privilege escalation, and host-level access (host networking, host PID/IPC) are curbed by default.
  • Mandatory use of Security Context Constraints (SCCs): SCCs define what is allowed for pods: user IDs, volume types, privilege level, SELinux contexts, and so on.

This layer aims to ensure that even if application code is vulnerable, the container’s ability to harm the host or other workloads is limited.

Later in this module, Security Context Constraints are covered in more detail; for now, understand them as a key OpenShift-specific policy mechanism around workload execution.

4. Network and Traffic Control

Network security in OpenShift focuses on:

  • Controlling which pods and services can talk to which others
  • Defining how and when external traffic can reach workloads

Important aspects:

  • Intra-cluster isolation: By default in many configurations, pods may communicate freely across namespaces; network policies can be used to restrict this.
  • Perimeter exposure: Only certain objects (like routes or ingress) are intended to expose applications externally.
  • Integration with underlying network plugins and load balancers to enforce segmentation, encryption, or traffic shaping as required.

From a security standpoint, fine-grained network controls:

  • Reduce lateral movement possibilities in case of compromise
  • Allow implementing zero-trust style communication patterns

Network security specifics, including policies and ingress behavior, are expanded upon in the dedicated network security subsection.

5. Image and Supply Chain Security

OpenShift recognizes that the code and images you run are a major source of risk. Security in this area focuses on:

  • Image provenance: Where images come from (trusted registries vs unknown public sources).
  • Image scanning: Detecting known vulnerabilities (CVEs), misconfigurations, or embedded secrets.
  • Image policy enforcement: Preventing the use of images that are out-of-policy (for example, unscanned or from unapproved registries).

Common patterns include:

  • Using internal registries and image streams as controlled sources.
  • Integrating scanners and admission policies to block risky images from being deployed.
  • Combining CI/CD with image security so that vulnerabilities are identified early.

Later in this module, image security and scanning are explored in-depth.

6. Configuration and Secret Handling

Applications need configuration, credentials, and sensitive keys. OpenShift provides mechanisms to:

  • Separate static configuration from code (for example, in ConfigMaps).
  • Keep sensitive data in dedicated objects (Secrets) that have stricter handling.
  • Control how and where such data is projected into running pods (environment variables, files, volumes).

From a security perspective:

  • Proper use of Secrets reduces accidental exposure of credentials in images, logs, or source control.
  • Access to configuration objects is subject to RBAC, allowing fine-grained control over who can read what.

While this course has a separate module for configuration and secrets management, in the security context the important point is: use the platform’s dedicated mechanisms, not ad-hoc approaches.

7. Platform Hardening and Node Security

Beneath the Kubernetes and OpenShift abstractions, the cluster runs on operating systems and hosts that must be hardened.

Security-related aspects include:

  • Using hardened, minimal host operating systems (e.g. Red Hat Enterprise Linux CoreOS in many OpenShift deployments).
  • Managing OS patches and kernel updates, often through cluster-managed over-the-air updates.
  • Ensuring that access to nodes (SSH, console) is tightly controlled and audited.
  • Applying disk encryption, FIPS mode, and other host-level security features as appropriate to compliance requirements.

The platform aims to minimize the need for manual node-level configuration by operators, which in turn reduces configuration drift and security risk.

8. Monitoring, Auditing, and Compliance

A crucial security layer is visibility:

  • Auditing: Recording who did what, when, and from where, at the Kubernetes API and platform levels.
  • Logging: Capturing application and infrastructure logs for incident detection and forensic analysis.
  • Metrics and alerts: Monitoring abnormal behavior (for example, spikes in error rates, unexpected restarts, or resource consumption).

OpenShift includes:

  • An API server audit logging capability that can be configured for different levels of detail.
  • Integration points for centralized log collectors and SIEM systems.
  • Tools and Operators to check for compliance with various standards and recommended benchmarks.

Security is not only about preventing incidents, but also about detecting, investigating, and learning from them.

Shared Responsibility: Who Secures What?

OpenShift usually runs in environments where different parties share responsibility:

  • Platform provider / infrastructure team:
    • Installs, configures, and upgrades the cluster
    • Secures the control plane, the underlying OS, and core services
    • Manages baseline policies (SCCs, network policies, cluster-wide RBAC)
  • Application teams:
    • Write secure code and containerize it safely
    • Use ConfigMaps and Secrets appropriately
    • Choose images and dependencies responsibly
    • Define resource-level policies (such as per-project network policies)
  • Security and compliance teams:
    • Define global policies, approved registries, and standards
    • Integrate logging, monitoring, and scanning with broader enterprise tools
    • Review and audit cluster configurations and access patterns

OpenShift’s design reflects this shared responsibility by:

  • Providing clear policy abstraction layers
  • Allowing central governance, but with room for team-level autonomy
  • Making security posture partly declarative and version-controlled

Understanding where your role sits in this model helps you decide which security controls you should focus on when working with OpenShift.

Balancing Security and Developer Productivity

Strict security measures can conflict with developers’ expectations, especially when they are used to running containers with broad privileges. OpenShift aims to strike a balance by:

  • Providing secure defaults that block common risky behaviors.
  • Allowing exceptions through explicit policies (for example, using different SCCs for specific projects).
  • Encouraging patterns that are both secure and convenient, such as:
    • Building images that do not require root
    • Using service accounts with scoped permissions
    • Using internal registries and automated scanning instead of ad-hoc images

From a practical standpoint:

  • Many “it doesn’t work on OpenShift” problems are actually security policy violations (for example, running as root, needing hostPath volumes, or using unsupported capabilities).
  • The recommended approach is to adapt workloads to the platform’s security model where possible, rather than weaken the cluster-wide security posture.

How This Security Module is Organized

The remainder of the security module breaks down the main security mechanisms in OpenShift:

  • Security model overview (this chapter): Big-picture view of the layers and principles.
  • Role-Based Access Control: How to define and apply permissions and roles for controlling actions on resources.
  • Security Context Constraints: How OpenShift controls what pods are allowed to do on the host and in the kernel.
  • Image security and scanning: How to manage images safely, check for vulnerabilities, and enforce policies on what can be deployed.
  • Network security: How to restrict and shape network communication inside and outside the cluster.
  • Compliance and auditing: How to observe, prove, and maintain a desired security posture over time.

Together, these topics give you the tools to design, operate, and use OpenShift clusters in a way that meets real-world security and compliance expectations.

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