Skip to main content

Red Hat OpenShift

Written by Aron Day

This page explains what OpenShift does differently and what 3B needs as a result. The install itself is the same as on any cluster, so follow the Helm installation guide and use this page for the steps that are specific to OpenShift.

3B runs on OpenShift 4.20 and newer. Earlier releases can’t run the user-namespaced pods that 3B’s step isolation depends on.

What 3B needs from OpenShift

Most of 3B runs under OpenShift’s default restricted-v2 security context constraints (SCC). That includes nginx, Zero, edge, the orchestrator, Blobstore, and the database. Blobstore needs one value changed, which step 4 covers.

Three pods need more than restricted-v2 allows, because they start gVisor sandboxes for workflow steps. These are api, worker, and git-service. Step isolation explains how this works in detail. In short, each of these pods runs in its own user namespace, so root inside the pod is an unprivileged user on the node. Inside that namespace, 3B creates another user namespace for each sandbox and mounts the sandbox’s filesystems there. restricted-v2 blocks this in three ways:

  • The pods run as root inside their own user namespace, while restricted-v2 requires a user ID from the project’s range.

  • They need the SETUID, SETGID, and SETFCAP capabilities to map user IDs into each sandbox. These capabilities only apply inside the pod’s user namespace.

  • gVisor mounts its own /proc and temporary filesystems while it builds a sandbox, which the container_t SELinux type doesn’t allow. These pods need container_engine_t, the type Red Hat’s nested-container SCC uses.

They also need a seccomp profile that allows the namespace and mount system calls. The runtime’s default profile blocks them. 3B ships a profile for this, which is the one 3B’s own cloud runs.

Nothing in 3B runs as a privileged container or uses host networking, host paths, or host process IDs. The SCCs on this page keep privilege escalation off, and SELinux stays enforcing.

Two short-lived Jobs, credential-key-activation and workflow-proof-activation, run as user 9999. They need OpenShift’s built-in nonroot-v2 SCC, which is restricted-v2 with any non-root user ID allowed. If you set secrets.generate: false, the secret-provisioning Job does too.

Creating an SCC, granting it, and installing the seccomp profile on nodes need a cluster administrator. You only do these once per cluster. Installing and upgrading the Helm release after that only needs admin rights in the 3b project.

Before you start

You need the following:

  • OpenShift 4.20 or newer, with x86-64 worker nodes. The seccomp profile only covers x86-64.

  • A default StorageClass with volume expansion, as described in the installation guide.

  • The oc command line tool, logged in as a cluster administrator for steps 2 and 3.

Follow steps 1 to 4 of the installation guide to set your variables, create the 3b namespace, create the image pull secret, and log Helm in to the registry. You can use oc in place of kubectl throughout. Skip step 5, the node compatibility check, because the install runs that check itself.

Step 1: Get the seccomp profile

The profile ships inside the Helm chart. Download the chart for the version you’re installing and unpack it:

helm pull oci://oci.tines.com/3b/charts/3b --version "$VERSION" \
  --untar --untardir "3b-$VERSION"

The profile is now at 3b-$VERSION/3b/files/sandboxd-seccomp.json.

Step 2: Install the seccomp profile on your nodes

Every node that can run the api, worker, or git-service pods needs the profile at /var/lib/kubelet/seccomp/profiles/sandboxd.json. On OpenShift, a MachineConfig is the usual way to put a file on every node in a pool.

This creates a MachineConfig for the worker pool:

ROLE=worker
PROFILE=$(base64 < "3b-$VERSION/3b/files/sandboxd-seccomp.json" | tr -d '\n')
oc apply -f - <<EOF
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
  name: 99-${ROLE}-3b-sandboxd-seccomp
  labels:
    machineconfiguration.openshift.io/role: ${ROLE}
spec:
  config:
    ignition:
      version: 3.2.0
    storage:
      files:
        - path: /var/lib/kubelet/seccomp/profiles/sandboxd.json
          mode: 420
          overwrite: true
          contents:
            source: data:text/plain;charset=utf-8;base64,${PROFILE}
EOF

The Machine Config Operator then updates the nodes in the pool one at a time, and each node drains and reboots. Watch the pool with oc get mcp "$ROLE" -w. It’s finished when UPDATED is True and UPDATING is False.

If 3B runs on a different pool, set ROLE to that pool’s role. On a single-node or three-node cluster, where the control plane nodes also run workloads, set ROLE=master.

Before each upgrade, download the new chart as in step 1 and compare its profile with the one in your MachineConfig:

oc get mc "99-${ROLE}-3b-sandboxd-seccomp" \
  -o jsonpath='{.spec.config.storage.files[0].contents.source}' |
  sed 's/.*base64,//' | base64 -d |
  diff - "3b-$VERSION/3b/files/sandboxd-seccomp.json"

If the profiles differ, apply the MachineConfig again with the new profile and wait for the pool to finish updating before you upgrade 3B.

Step 3: Create the SCC and grant it

Create an SCC named 3b-sandbox for the three sandbox pods. It follows Red Hat’s built-in nested-container SCC, with three differences. It allows SETFCAP, it allows any user and group IDs instead of the project’s range, and it allows the 3B seccomp profile.

oc apply -f - <<EOF
apiVersion: security.openshift.io/v1
kind: SecurityContextConstraints
metadata:
  name: 3b-sandbox
allowHostDirVolumePlugin: false
allowHostIPC: false
allowHostNetwork: false
allowHostPID: false
allowHostPorts: false
allowPrivilegeEscalation: false
allowPrivilegedContainer: false
allowedCapabilities: [SETUID, SETGID, SETFCAP]
defaultAddCapabilities: null
requiredDropCapabilities: null
readOnlyRootFilesystem: false
userNamespaceLevel: RequirePodLevel
runAsUser:
  type: RunAsAny
fsGroup:
  type: RunAsAny
supplementalGroups:
  type: RunAsAny
seLinuxContext:
  type: MustRunAs
  seLinuxOptions:
    type: container_engine_t
seccompProfiles:
  - runtime/default
  - localhost/profiles/sandboxd.json
volumes: [configMap, csi, downwardAPI, emptyDir, ephemeral, persistentVolumeClaim, projected, secret]
users: []
groups: []
EOF

userNamespaceLevel: RequirePodLevel means a pod can only use this SCC if it runs in its own user namespace. That’s why RunAsAny is safe here, because any user ID in the pod, root included, maps to an unprivileged user on the node.

Grant it to the service accounts of the three sandbox pods, and grant nonroot-v2 to the Jobs:

oc adm policy add-scc-to-user 3b-sandbox -n 3b \
  -z api -z worker -z git-service -z openshift-preflight
oc adm policy add-scc-to-user nonroot-v2 -n 3b \
  -z credential-key-activation -z workflow-proof-activation -z secret-provisioning

The chart creates these service accounts during the install, and you can grant the SCCs before they exist. openshift-preflight needs 3b-sandbox to start a test sandbox pod at the start of the install. If you set serviceAccountName in your values, for all of 3B or for one service, grant the SCCs to those accounts instead.

Step 4: Configure your values

Write your values file as step 6 of the installation guide describes, and add the following:

sandboxd:
  seccompProfile:
    type: Localhost
    localhostProfile: profiles/sandboxd.json

blobstore:
  podSecurityContext:
    fsGroup: null

nginx:
  nodePort: 0

The sandboxd.seccompProfile setting runs the sandbox containers under the profile from step 2. By default they run without a seccomp profile, which the 3b-sandbox SCC doesn’t allow.

Blobstore normally runs with a fixed fsGroup so it can write to its volume. OpenShift assigns a group from the project’s range instead and rejects any other, so fsGroup: null removes the fixed value.

Routes reach nginx through its Service, so it doesn’t need a fixed NodePort. nginx.nodePort: 0 lets Kubernetes pick a free one instead of 30080, which another application on a shared cluster may already use.

Leave nginx.tls.enabled off, because the OpenShift router terminates TLS. Also leave sandboxd.hostUsers and usernsbox.enabled at their defaults. OpenShift doesn’t need either, and the 3b-sandbox SCC only admits pods that run in their own user namespace.

Then install the chart and verify it, as steps 7 and 8 of the installation guide describe.

Before it creates anything, helm install runs a Job named openshift-preflight. It checks the OpenShift version, that each pod is admitted by an SCC you granted, and that a sandbox pod starts under the seccomp profile. It prints PASS or FAIL for each check and stops the install if any check fails. Upgrades don’t run it.

Step 5: Expose 3B with Routes

The chart’s nginx service is the front door for every hostname, so each Route points at it. Create one edge-terminated Route for each hostname in externalUrls. With the two hostnames from the installation guide, that’s:

for host in 3b.example.com 3b-edge.example.com; do
  oc -n 3b create route edge "$host" --service=nginx --port=http \
    --hostname="$host" --insecure-policy=Redirect
  oc -n 3b annotate route "$host" \
    haproxy.router.openshift.io/timeout=86400s \
    haproxy.router.openshift.io/timeout-tunnel=86400s
done

The router’s default timeout is 30 seconds, and its default for websockets is 1 hour. Some API responses, such as AI chat, stream for minutes, and the UI keeps a websocket open for real-time sync, so the annotations raise both timeouts to match 3B’s own.

The router’s default certificate only covers the cluster’s *.apps domain. For any other hostname, add your own certificate to each Route with --cert, --key, and --ca-cert, and point DNS for each hostname at the router’s load balancer. The router forwards X-Forwarded-Proto: https, which 3B needs when something in front of it terminates TLS. See TLS termination.

If you enable space hosts, also create a wildcard Route for the edge hostname’s parent domain. The router gives a wildcard domain to the first project that claims it and then rejects other projects’ Routes under it. So pick an edge hostname whose parent domain belongs to 3B alone, such as edge.3b.example.com, before you install. A Route’s hostname can’t start with *, so give it any name under that domain and set the wildcard policy:

oc -n 3b create route edge space-hosts --service=nginx --port=http \
  --hostname=wildcard.3b.example.com --wildcard-policy=Subdomain \
  --insecure-policy=Redirect
oc -n 3b annotate route space-hosts \
  haproxy.router.openshift.io/timeout=86400s \
  haproxy.router.openshift.io/timeout-tunnel=86400s

The certificate for this Route must cover *.3b.example.com. The default ingress controller only admits wildcard Routes when its routeAdmission.wildcardPolicy is WildcardsAllowed.

Troubleshooting

  • helm install fails with job openshift-preflight failed. The checks are printed above the error. Helm older than 3.18 doesn’t print them, so read them with oc logs -n 3b job/openshift-preflight. Fix each FAIL, then run helm uninstall 3b -n 3b and install again.

  • The api, worker, or git-service ReplicaSet reports unable to validate against any security context constraint. The 3b-sandbox SCC is missing, it isn’t granted to that service account, or sandboxd.seccompProfile isn’t set in your values. Check the grant with oc get rolebinding -n 3b -o wide | grep 3b-sandbox.

  • A sandbox pod fails with CreateContainerError and a seccomp profile not found message. The node doesn’t have /var/lib/kubelet/seccomp/profiles/sandboxd.json yet. Check that the MachineConfig pool for that node has finished updating.

  • The worker pod starts, but steps fail and the logs show unshare or mount errors such as function not implemented or operation not permitted. The profile on the node is probably older than the one in the chart. Compare them as described in step 2, and check that oc get pod -n 3b <pod> -o yaml shows openshift.io/scc: 3b-sandbox.

  • The credential-key-activation or workflow-proof-activation Job never starts, and its events mention user 9999. Grant nonroot-v2 to its service account.

  • The Blobstore StatefulSet creates no pod, and its events say that 1000 isn’t an allowed group. Set blobstore.podSecurityContext.fsGroup to null.

  • Long-running responses, such as AI chat, fail after about 30 seconds. A Route is missing the timeout annotations from step 5.

Did this answer your question?