$ oc explain pods
Display documentation for a certain resource.
$ oc explain pods
Log in to the OpenShift Container Platform server and save login information for subsequent use.
$ oc login
$ oc login -u user1
Create a new application by specifying source code, a template, or an image.
$ oc new-app .
$ oc new-app https://github.com/sclorg/cakephp-ex
$ oc new-app https://github.com/youruser/yourprivaterepo --source-secret=yoursecret
Create a new project and switch to it as the default project in your configuration.
$ oc new-project myproject
Switch to another project and make it the default in your configuration.
$ oc project test-project
Cancel a running, pending, or new build.
$ oc cancel-build python-1
python
build config$ oc cancel-build buildconfig/python --state=pending
Import the latest tag and image information from an image repository.
$ oc import-image my-ruby
Create a new build config from source code.
$ oc new-build .
$ oc new-build https://github.com/sclorg/cakephp-ex
Revert an application back to a previous deployment.
$ oc rollback php
$ oc rollback php --to-version=3
Start a new rollout, view its status or history, or roll back to a previous revision of your application.
$ oc rollout undo deploymentconfig/php
$ oc rollout latest deploymentconfig/php
Start a build from a build config or copy an existing build.
$ oc start-build python
$ oc start-build --from-build=python-1
$ oc start-build python --env=mykey=myvalue
Update the annotations on one or more resources.
$ oc annotate route/test-route haproxy.router.openshift.io/ip_whitelist="192.168.1.10"
$ oc annotate route/test-route haproxy.router.openshift.io/ip_whitelist-
Apply a configuration to a resource by file name or standard in (stdin) in JSON or YAML format.
pod.json
to a pod$ oc apply -f pod.json
Autoscale a deployment or replication controller.
$ oc autoscale deploymentconfig/parksmap-katacoda --min=2 --max=5
Create a resource by file name or standard in (stdin) in JSON or YAML format.
pod.json
$ oc create -f pod.json
Delete a resource.
parksmap-katacoda-1-qfqz4
$ oc delete pod/parksmap-katacoda-1-qfqz4
app=parksmap-katacoda
label$ oc delete pods -l app=parksmap-katacoda
Return detailed information about a specific object.
example
$ oc describe deployment/example
$ oc describe pods
Edit a resource.
$ oc edit deploymentconfig/parksmap-katacoda
$ OC_EDITOR="nano" oc edit deploymentconfig/parksmap-katacoda
$ oc edit deploymentconfig/parksmap-katacoda -o json
Expose a service externally as a route.
$ oc expose service/parksmap-katacoda
$ oc expose service/parksmap-katacoda --hostname=www.my-host.com
Display one or more resources.
default
namespace$ oc get pods -n default
python
deployment in JSON format$ oc get deploymentconfig/python -o json
Update the labels on one or more resources.
python-1-mz2rf
pod with the label status
set to unhealthy
$ oc label pod/python-1-mz2rf status=unhealthy
Set the desired number of replicas for a replication controller or a deployment.
ruby-app
deployment to three pods$ oc scale deploymentconfig/ruby-app --replicas=3
Manage secrets in your project.
my-pull-secret
to be used as an image pull secret by the default
service account$ oc secrets link default my-pull-secret --for=pull
Attach the shell to a running container.
python
container from pod python-1-mz2rf
$ oc attach python-1-mz2rf -c python
Copy files and directories to and from containers.
python-1-mz2rf
pod to the local file system$ oc cp default/python-1-mz2rf:/opt/app-root/src/README.md ~/mydirectory/.
Launch a command shell to debug a running application.
python
Deployment$ oc debug deploymentconfig/python
Execute a command in a container.
ls
command in the python
container from pod python-1-mz2rf
$ oc exec python-1-mz2rf -c python ls
Retrieve the log output for a specific build, build config, deployment, or pod.
python
deployment$ oc logs -f deploymentconfig/python
Forward one or more local ports to a pod.
8888
locally and forward to port 5000
in the pod$ oc port-forward python-1-mz2rf 8888:5000
Run a proxy to the Kubernetes API server.
8011
serving static content from ./local/www/
$ oc proxy --port=8011 --www=./local/www/
Open a remote shell session to a container.
python-1-mz2rf
pod$ oc rsh python-1-mz2rf
Copy contents of a directory to or from a running pod container. Only changed
files are copied using the rsync
command from your operating system.
$ oc rsync ~/mydirectory/ python-1-mz2rf:/opt/app-root/src/
Display the full list of API resources that the server supports.
$ oc api-resources
Display the full list of API versions that the server supports.
$ oc api-versions
Inspect permissions and reconcile RBAC roles.
$ oc auth can-i get pods --subresource=log
$ oc auth reconcile -f policy.json
Display the address of the master and cluster services.
$ oc cluster-info
Convert a YAML or JSON configuration file to a different API version and print to standard output (stdout).
pod.yaml
to the latest version$ oc convert -f pod.yaml
Extract the contents of a config map or secret. Each key in the config map or secret is created as a separate file with the name of the key.
ruby-1-ca
config map to the current directory$ oc extract configmap/ruby-1-ca
ruby-1-ca
config map to stdout$ oc extract configmap/ruby-1-ca --to=-
Idle scalable resources. An idled service will automatically become unidled when
it receives traffic or it can be manually unidled using the oc scale
command.
ruby-app
service$ oc idle ruby-app
Manage images in your OpenShift Container Platform cluster.
$ oc image mirror myregistry.com/myimage:latest myregistry.com/myimage:stable
Observe changes to resources and take action on them.
$ oc observe services
Updates one or more fields of an object using strategic merge patch in JSON or YAML format.
spec.unschedulable
field for node node1
to true
$ oc patch node/node1 -p '{"spec":{"unschedulable":true}}'
If you must patch a custom resource definition, you must include the
|
Manage authorization policies.
edit
role to user1
for the current project$ oc policy add-role-to-user edit user1
Process a template into a list of resources.
template.json
to a resource list and pass to oc create
$ oc process -f template.json | oc create -f -
Output shell completion code for the specified shell.
$ oc completion bash
Display general help information for the CLI and a list of available commands.
$ oc help
new-project
command$ oc help new-project