Voiced by Amazon Polly |
Imagine you’re managing a bustling city of containers. Every container wants access, every pod has demands, and security threats lurk in the shadows. How do you keep order without stifling innovation? Enter Security Context Constraints (SCCs) — OpenShift’s built-in security bouncers that ensure only the right workloads get the right access, at the right time.
In this blog, we take you on a journey through what SCCs are, why they matter, and how they help safeguard your containerized workloads.
Become an Azure Expert in Just 2 Months with Industry-Certified Trainers
- Career-Boosting Skills
- Hands-on Labs
- Flexible Learning
What Are Security Context Constraints (SCCs)?
SCCs are OpenShift’s policy framework that defines the rules under which pods are allowed to run. They govern container behavior, permissions, and runtime settings, shaping how your workloads interact with the underlying host and each other.
With SCCs, you gain control over:
- User privileges and preventing privilege escalation.
- Filesystem access and volume mount permissions.
- Linux security context like SELinux or AppArmor.
These controls make SCCs a cornerstone of OpenShift’s strong security foundation.
Key Features of SCCs
Here are the building blocks SCCs use to lock down container behavior:
- RunAsUser
- Controls which User ID (UID) the container runs under.
- Modes:
- MustRunAs: Specific UID or range.
- RunAsAny: Any UID allowed.
- MustRunAsRange: Must fall within a defined range.
- AllowPrivilegedContainer
- Defines if a container can run with elevated (privileged) access.
- Default: false. Setting true permits full root-level actions.
- SELinuxContext
- Sets the SELinux labels for the container, enforcing strict isolation.
- Modes:
- MustRunAs: Must match defined policies.
- RunAsAny: No restrictions.
- FSGroup
- Assigns a Group ID (GID) for filesystems inside the container, ensuring proper group access.
- SupplementalGroups
- Allows additional group memberships, expanding access where needed.
- Volumes
- Specifies allowed volume types (e.g., emptyDir, PVC, secret, configMap).
Default SCCs: The Built-in Security Models
OpenShift ships with several predefined SCCs:
- restricted
- The most secure default.
- Prevents root access, limits volume types, enforces strict SELinux.
- anyuid
- Allows running as any UID, including root.
- For workloads requiring elevated privileges.
- privileged
- Grants full host control.
- Should be used cautiously, only for highly trusted system-level tasks.
- hostaccess
- Permits access to host resources, such as mounting host filesystems.
- nonroot
- Ensures workloads don’t run as root but is less restrictive than restricted.
Behind the Scenes: How SCCs Work
The SCC lifecycle looks like this:
- Define Rules
- Admins craft SCC policies outlining what pods can and cannot do.
- Assign SCCs
- SCCs are linked to specific users or service accounts.
- Enforce Policies
- When a pod is created, OpenShift checks the associated SCC and only schedules it if all rules are satisfied.
If a pod violates SCC policies? It never makes it past the gate.
Hands-On Lab: Working with SCCs in OpenShift
Let’s walk through a practical lab demonstrating how SCCs work in action.
Task 1: Apply SCCs to Enable Nginx Deployment
Step 1: Create a new project
1 |
oc new-project test-scc |
Step 2: Create an Nginx deployment
1 |
oc create deployment ng-dep --image=nginx |
Step 3: Get and describe the Nginx pod
1 2 3 |
oc get pods oc describe pod <nginx-pod-name> |
You’ll notice the pod fails because by default, OpenShift blocks containers running as root.
Step 4: List all available SCCs
1 |
oc get scc |
Step 5: Describe the anyuid SCC
1 |
oc describe scc anyuid |
Step 6: Create a service account
1 |
oc create sa nginx-sa |
Step 7: Apply the anyuid SCC to the service account
1 |
oc adm policy add-scc-to-user anyuid -z nginx-sa |
This allows the service account to run containers with any UID.
Step 8: Assign the service account to the deployment
1 |
oc set serviceaccount deployment/ng-dep nginx-sa |
Step 9: Check the pods again
1 |
oc get pods |
Your Nginx pod should now run successfully using the nginx-sa service account!
Why SCCs Are Crucial for Pod Security
In an environment where hundreds or thousands of containers operate, SCCs reduce the attack surface by:
- Blocking unnecessary privileges.
- Enforcing least privilege principles.
- Shielding the host system from unauthorized access.
- Supporting compliance and audit requirements.
With SCCs, you turn your OpenShift cluster into a well-guarded fortress, where every workload operates within clearly defined, secure boundaries.
Final Thoughts: Crafting a Secure OpenShift Landscape
Security Context Constraints are not just an optional feature — they are essential tools for any OpenShift administrator aiming to maintain a secure, resilient, and compliant container platform.
By understanding and mastering SCCs, you can: Protect your workloads. Prevent privilege misuse. Ensure your cluster operates securely at scale.
Would you like me to include practical YAML examples or a hands-on walkthrough on how to create and apply custom SCCs?
Enhance Your Productivity with Microsoft Copilot
- Effortless Integration
- AI-Powered Assistance
About CloudThat
CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.
CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 650k+ professionals in 500+ cloud certifications and completed 300+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training Partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, AWS GenAI Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery Partner, AWS Microsoft Workload Partners, Amazon EC2 Service Delivery Partner, Amazon ECS Service Delivery Partner, AWS Glue Service Delivery Partner, Amazon Redshift Service Delivery Partner, AWS Control Tower Service Delivery Partner, AWS WAF Service Delivery Partner, Amazon CloudFront, Amazon OpenSearch, AWS DMS, AWS Systems Manager, Amazon RDS, and many more.

WRITTEN BY Sirin Kausar Isak Ali
Comments