We use cookies to make your experience better.
Learn about deploying Coder in OpenShift Container Platform
This deployment guide shows you how to customize your OpenShift Container
Platform cluster in order to deploy Coder. The OpenShift Container Platform
includes default security features, notably the restricted
Security Context
Constraint (SCC), which can interfere with applications, including Coder.
This guide describes customizations to the OpenShift cluster as well as Coder that ensure an optimal user experience.
oc
and kubectl
)OpenShift's SCC feature enforces particular settings that applications must
run with. The default restricted
SCC requires that applications run as a user
within a project-specific range (MustRunAsRange
) and must not define a
seccomp profile.
You can view the restrictions using oc describe scc restricted
:
$ oc describe scc restricted
Name: restricted
Priority: <none>
Access:
Users: <none>
Groups: system:authenticated
Settings:
Allow Privileged: false
Allow Privilege Escalation: true
Default Add Capabilities: <none>
Required Drop Capabilities: KILL,MKNOD,SETUID,SETGID
Allowed Capabilities: <none>
Allowed Seccomp Profiles: <none>
Allowed Volume Types: configMap,downwardAPI,emptyDir,persistentVolumeClaim,projected,secret
Allowed Flexvolumes: <all>
Allowed Unsafe Sysctls: <none>
Forbidden Sysctls: <none>
Allow Host Network: false
Allow Host Ports: false
Allow Host PID: false
Allow Host IPC: false
Read Only Root Filesystem: false
Run As User Strategy: MustRunAsRange
UID: <none>
UID Range Min: <none>
UID Range Max: <none>
SELinux Context Strategy: MustRunAs
User: <none>
Role: <none>
Type: <none>
Level: <none>
FSGroup Strategy: MustRunAs
Ranges: <none>
Supplemental Groups Strategy: RunAsAny
Ranges: <none>
You can override the default settings by defining the following in your Helm Values file:
coderd:
podSecurityContext:
runAsUser: null
seccompProfile: null
securityContext:
seccompProfile: null
Coder's default base images for workspaces, such as enterprise-base
, run as
the coder
user (UID 1000). By default, the OpenShift platform does not
allow running with this user, as service accounts use the restricted
SCC by
default, and must run with a project-specific UID.
Coder creates workspaces in pods with the service account environments
, and
we recommend adding this service account to the anyuid
or nonroot
Security
Context Constraint using:
$ oc adm policy add-scc-to-user nonroot -z environments
clusterrole.rbac.authorization.k8s.io/system:openshift:scc:nonroot added: "environments"
$ oc adm policy who-can use scc nonroot
resourceaccessreviewresponse.authorization.openshift.io/<unknown>
Namespace: coder
Verb: use
Resource: securitycontextconstraints.security.openshift.io
Users: system:admin
system:serviceaccount:coder:environment
In order to run Coder workspaces without modifying Security Context Constraints, you can modify the user and permissions from the base images. First, determine the UID range for the project using:
$ oc describe project coderName: coder
Created: 10 days ago
Labels: <none>
Annotations: openshift.io/description=
openshift.io/display-name=
openshift.io/requester=kube:admin
openshift.io/sa.scc.mcs=s0:c26,c10
openshift.io/sa.scc.supplemental-groups=1000670000/10000
openshift.io/sa.scc.uid-range=1000670000/10000
Display Name: <none>
Description: <none>
Status: Active
Node Selector: <none>
Quota: <none>
Resource limits: <none>
Create a BuildConfig
that outputs an image with a UID in the given range
(in this case, sa.scc.uid-range begins with 1000670000):
kind: BuildConfig
apiVersion: build.openshift.io/v1
metadata:
name: example
namespace: coder
spec:
triggers:
- type: ConfigChange
runPolicy: Serial
source:
type: Dockerfile
dockerfile: |
FROM docker.io/codercom/enterprise-base:ubuntu
# Switch to root
USER root
# As root, change the coder user id
RUN usermod --uid=1000670000 coder
# Go back to the user 'coder'
USER coder
strategy:
type: Docker
dockerStrategy:
imageOptimizationPolicy: SkipLayers
output:
to:
kind: ImageStreamTag
name: 'enterprise-base:latest'
When creating workspaces, configure Coder to connect to the internal OpenShift registry and use this base image.
See an opportunity to improve our docs? Make an edit.