Back to Home
OpenShift
Deploying and managing applications on OpenShift
deploynew-appbuildimagestream rollout
OpenShift Deployments
Deploying and managing applications on OpenShift.
Deploying Applications
# Deploy from source code (Git)
oc new-app https://github.com/user/repo.git
# Deploy from source with a specific branch
oc new-app https://github.com/user/repo.git#main
# Deploy from source with builder image
oc new-app python:3.11~https://github.com/user/repo.git
# Deploy from container image
oc new-app nginx:latest
# Deploy from Dockerfile
oc new-app https://github.com/user/repo.git --strategy=docker
# Deploy with environment variables
oc new-app https://github.com/user/repo.git -e KEY=VALUE -e DB_HOST=db.example.com
# Deploy with a name
oc new-app nginx:latest --name=my-nginx
# Create a route after deployment
oc expose svc/my-nginx
Build Management
# List builds
oc get builds
# Start a build
oc start-build my-app
# Start build from local source
oc start-build my-app --from-dir=.
# Follow build logs
oc logs -f bc/my-app
# Cancel a build
oc cancel-build my-app-1
# Rebuild
oc start-build my-app --from-restart
# View build config
oc get bc my-app -o yaml
oc describe bc my-app
Image Streams
# List image streams
oc get is
# List image streams in openshift namespace
oc get is -n openshift
# Import image from external registry
oc import-image my-image:latest --from=registry.example.com/my-image:latest
# Tag an image
oc tag my-image:latest my-image:v1.0
# Describe image stream
oc describe is my-image
Rollout Management
# Check rollout status
oc rollout status dc/my-app
# View rollout history
oc rollout history dc/my-app
# Rollback to previous version
oc rollout undo dc/my-app
# Rollback to specific version
oc rollout undo dc/my-app --to-version=2
# Pause rollout
oc rollout pause dc/my-app
# Resume rollout
oc rollout resume dc/my-app
# Restart deployment
oc rollout restart dc/my-app
# Set replica count
oc scale dc/my-app --replicas=3