Search for a command to run...
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.
OpenShift Container Platform (OCP) is the supported product and requires a Red Hat subscription. OKD is the free community distribution of the same source and is a good way to try the platform without a subscription.
libvirt and qemu-kvm installed and runningcrc installer packagecrc binary)CRC runs a complete single-node OpenShift cluster on your workstation.
# 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 versionOn ARM64 use crc-linux-arm64.tar.xz instead.
# Install the host prerequisites (virtual machine, networking)
crc setup
# Start the cluster (this takes 5-15 minutes on first run)
crc startTo 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# 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# 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 consoleoc 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 versionThe 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.
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 versionmkdir -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# 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)"| Method | When to use it |
|---|---|
| Agent-based installer | Recommended for most production clusters, including disconnected installs |
| Installer-provisioned infrastructure (IPI) | You want the installer to create the VMs/bare metal hosts themselves |
| Assisted installer | You want Red Hat to guide you through a hosted installation |
| OKD (installer-provisioned) | The free community distribution, same install flow as OCP |
# 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# 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 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-worldapiVersion: 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# 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 -wNever run as the kubeadmin user — it is a break-glass account. Create real users
in the identity provider and grant them roles instead.
Use projects for tenancy and apply the edit role per project rather than
granting cluster-wide access.
Deny traffic by default with NetworkPolicy
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-by-default
spec:
podSelector: {}
policyTypes:
- IngressEnable audit logging
apiVersion: config.openshift.io/v1
kind: Audit
metadata:
name: cluster
spec:
profile: WriteRequestBodiesEncrypt traffic between nodes with the OpenShift encryption operators for Secrets and ConfigMaps.
Keep the cluster updated — OpenShift requires regular upgrades to stay supported:
oc adm upgradeInstall Minikube v1.39 on Linux, macOS and Windows, start a local Kubernetes cluster with the right driver, manage add-ons, load images and troubleshoot common failures.
Set up GitHub Actions, GitLab CI and Jenkins with pipeline examples, runner configuration, caching strategies and deployment automation you can copy straight into your projects.