This guide summarizes the required files and configuration to deploy a project on OpenShift. Replace the placeholders with values specific to your application.
Dockerfile– adjusted for OpenShift, sets permissions and environment variables.openshift/deployment.yaml– defines the Deployment for{{APP_NAME}}in{{NAMESPACE}}.openshift/service.yaml– exposes the application internally.openshift/route.yaml– optional external route for the Service.openshift/network-policy.yaml– network access rules.openshift/pipeline/pipeline.yaml– Tekton Pipeline definition.openshift/pipeline/pipeline-pvc.yaml– persistent volume claim for the pipeline.openshift/pipeline/pipeline-run.yaml– sample pipeline run.
Ensure the Dockerfile includes OpenShift-friendly settings:
- Create
/opt/app-root/src,/opt/app-root/home, and/tmpdirectories. - Set environment variables:
HOME=/opt/app-root/homeNODE_ENV=productionPORT=8080NPM_CONFIG_CACHE=/opt/app-root/home/.npmNODE_OPTIONS=--max-old-space-size=384NPM_RUN=build
- Grant write permissions for UID range
{{UID_RANGE}}. - Switch to an unprivileged user (e.g.,
USER 1002290000). - Apply OpenShift labels such as
io.openshift.expose-services="8080:http".
Configure these variables in your Deployment manifest:
- name: NODE_ENV
value: production
- name: PORT
value: "8080"
- name: HOME
value: /opt/app-root/home
- name: NPM_CONFIG_CACHE
value: /opt/app-root/home/.npm
- name: NODE_OPTIONS
value: "--max-old-space-size=384"
- name: NPM_RUN
value: buildAdd additional variables as required by your project.
{{APP_NAME}}– application name{{NAMESPACE}}– target OpenShift project/namespace{{UID_RANGE}}– allowed UID range for the security context (e.g.,1002290000-1002300000){{MCS_LABELS}}– MCS labels (e.g.,s0:c48,c17){{SUPPLEMENTAL_GROUPS}}– supplemental groups (e.g.,1002290000/10000){{SCC}}– security context constraint name
Use this template as a starting point when adapting the deployment for a new project.