Command Palette

Search for a command to run...

GitHubGitHub

OpenShift Installation Guide

Install OpenShift Container Platform 4.22 or OpenShift Local (CRC) for local development, install the oc CLI and deploy a production cluster with the agent-based installer.

OpenShift is Kubernetes with a developer-focused platform on top: integrated builds, deployments, routes, operators and a multi-tenant security model. This guide covers the three ways to get it running — locally with OpenShift Local (CRC), on a single node for development, and in production with the agent-based installer.

Prerequisites

For OpenShift Local (CRC)

  • 4 CPU cores or more
  • 16 GB RAM or more (CRC refuses to start with less)
  • 100 GB of free disk space
  • A supported CPU with virtualization enabled (Intel VT-x or AMD-V)
  • On Linux: libvirt and qemu-kvm installed and running
  • On macOS: the crc installer package
  • On Windows: Hyper-V enabled (or WSL2 with the crc binary)

For a production installation

  • 3 or more bare-metal or virtual machines
  • A Red Hat subscription (or an OpenShift Developer subscription for a trial)
  • DNS and a load balancer for the API endpoint
  • A disconnected or connected registry for the release images

Method 1: OpenShift Local (CRC)

CRC runs a complete single-node OpenShift cluster on your workstation.

Installing the CRC Binary

# Install the host dependencies (Debian / Ubuntu)
sudo apt install -y libvirt-daemon-system libvirt-clients bridge-utils libvirt-daemon qemu-kvm
 
# Download CRC
curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/crc-linux-amd64.tar.xz
 
# Extract and install
tar xf crc-linux-amd64.tar.xz
sudo mv crc-linux-amd64/crc /usr/local/bin/
rm -rf crc-linux-amd64
 
# Verify
crc version

On ARM64 use crc-linux-arm64.tar.xz instead.

Setting Up and Starting the Cluster

# Install the host prerequisites (virtual machine, networking)
crc setup
 
# Start the cluster (this takes 5-15 minutes on first run)
crc start

To run the paid OpenShift Container Platform edition, add your Red Hat pull secret:

# Create a pull secret at https://console.redhat.com/openshift/create/local
crc config set pull-secret /path/to/pull-secret.txt
 
# Start with the OCP release
crc start

Working with the Cluster

# Open the web console
crc console
 
# Log in with the developer account
oc login -u developer -p developer
 
# Check the cluster
oc get nodes
oc get clusterversion
oc get pods -n openshift-apiserver
# Create a project and deploy an application
oc new-project demo
oc new-app https://github.com/openshift/hello-world.git
 
# Watch the rollout
oc get pods -w
 
# Expose the application with a route
oc expose svc/hello-world
oc get route hello-world

Managing the CRC Instance

# Check the status
crc status
 
# Stop and start again
crc stop
crc start
 
# Delete the cluster and free the disk space
crc delete
 
# Open a shell inside the VM
crc console

Method 2: The OpenShift CLI (oc)

oc is the OpenShift client. It is a superset of kubectl and works against any Kubernetes cluster.

# Download the archive
curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/oc/latest/linux/oc.tar.gz
 
# Extract and install (the archive contains oc and kubectl)
tar xzf oc.tar.gz
sudo mv oc kubectl /usr/local/bin/
 
# Verify
oc version

Method 3: Production Installation

The agent-based installer is the recommended way to install a production cluster. It is simple, uses the same install-config.yaml on every node, and supports disconnected environments.

Download the Installer

curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-install-linux.tar.gz
tar xzf openshift-install-linux.tar.gz
sudo mv openshift-install /usr/local/bin/
openshift-install version

Create the Install Configuration

mkdir -p ~/ocp-install && cd ~/ocp-install
 
openshift-install create install-config --dir=.

This writes an install-config.yaml that you must edit before continuing:

apiVersion: v1
baseDomain: example.com
metadata:
  name: my-cluster
compute:
  - name: master
    replicas: 3
  - name: worker
    replicas: 3
controlPlaneTopology: HighlyAvailable
network:
  type: OVNKubernetes
  machineNetwork:
    - cidr: 10.0.0.0/16
  clusterNetwork:
    - cidr: 10.128.0.0/14
    hostPrefix: 23
  serviceNetwork:
    - 172.30.0.0/16
platform:
  baremetal: {}
sshKey: |
  ssh-rsa AAAA... your-public-key

Install the Cluster

# Create the manifests and bootstrap the cluster
openshift-install create manifests --dir=.
openshift-install create cluster --dir=. --wait-for-node-ready
 
# Wait for the cluster to finish installing
openshift-install wait for cluster --timeout=30m
 
# Log in with the generated kubeadmin credentials
oc login -u kubeadmin -p "$(cat ~/ocp-install/kubeadmin-password)"

Other Installation Methods

MethodWhen to use it
Agent-based installerRecommended for most production clusters, including disconnected installs
Installer-provisioned infrastructure (IPI)You want the installer to create the VMs/bare metal hosts themselves
Assisted installerYou want Red Hat to guide you through a hosted installation
OKD (installer-provisioned)The free community distribution, same install flow as OCP

Post-Installation Configuration

Projects (Namespaces)

# Create a project
oc new-project my-app
 
# List projects
oc get projects
 
# Grant a developer access to their own project
oc adm policy add-role-to-user edit <username> -n my-app

Routes and TLS

# Create a route for a service
oc expose svc/my-service --hostname=my-app.apps.example.com
 
# Terminate TLS at the route
oc create route edge my-service --hostname=my-app.apps.example.com --tls-certificate=cert --tls-private-key=key

Build and Deploy from Source

# Build a container image from a Git repository
oc new-build https://github.com/openshift/hello-world.git
 
# Start the build
oc start-build hello-world
 
# Deploy the resulting image
oc new-app hello-world
 
# Follow the build logs
oc logs -f bc/hello-world

Storage

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: fast-ssd
provisioner: openshift-storage.noobaa.io/obc
parameters:
  bucketName: my-bucket
  region: us-east-1
# Check the default storage classes
oc get storageclass
 
# Create a persistent volume claim
oc create -f pvc.yaml

Upgrading the Cluster

# Check the available upgrade paths
oc adm upgrade
 
# Check the current version
oc get clusterversion
 
# Start the upgrade
oc adm upgrade --to-latest=true
 
# Watch the rollout
oc get clusterversion -w

Troubleshooting

Security Best Practices

  1. Never run as the kubeadmin user — it is a break-glass account. Create real users in the identity provider and grant them roles instead.

  2. Use projects for tenancy and apply the edit role per project rather than granting cluster-wide access.

  3. Deny traffic by default with NetworkPolicy

    apiVersion: networking.k8s.io/v1
    kind: NetworkPolicy
    metadata:
      name: deny-by-default
    spec:
      podSelector: {}
      policyTypes:
        - Ingress
  4. Enable audit logging

    apiVersion: config.openshift.io/v1
    kind: Audit
    metadata:
      name: cluster
    spec:
      profile: WriteRequestBodies
  5. Encrypt traffic between nodes with the OpenShift encryption operators for Secrets and ConfigMaps.

  6. Keep the cluster updated — OpenShift requires regular upgrades to stay supported:

    oc adm upgrade

Next Steps