Openshift Cheat Sheet
Openshift Cheat Sheet
Helm
Client Setup
# Follow instructions from GUI setup and download client
oc login
CLI Commands
Note: all Kubernetes commands work with the oc client. So also check Kubernetes
oc login [<cluster>]
oc projects # List projects
oc project <project> # Switch project
oc new-project <project>
oc whoami -t # Get current session API token
oc new-app https://github.com/name/project
oc new-app https://github.com/name/project --context-dir=<build dir>
For actual builds from a directory. Careful! If this is a git repo this won't work as the remote git
repo will be used!
oc new-app --name=<application> .
oc start-build <application> --from-dir . # Force build from dir (even if it is a
git repo)
oc start-build <application> -F # Wait for completion and print full
build log
oc start-build <application> -w # Wait for completion
oc new-app --list
Cluster Administration
Removing/Readding nodes
Initial Setup
Commands derived from jaxenter.com for Openshift:
Either use
oc login -u system:admin
oc get nodes --no-headers | awk '{print $1}' | xargs -I {} sh -c 'echo {}; oc describe
node {} | grep Allocated -A 5 | grep -ve Event -ve Allocated -ve percent -ve -- ;
echo'
Note that the resulting JSON will have no parameters yet. You'll have to identify places to
replace with parameters (syntax is "${PARAMETER}") and to declare those parameters.
Orchestration
Using Terraform with Openshift
Misc
Turning off sticky sessions: