Oc: Difference between revisions
(50 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=External= | =External= | ||
* https://docs.openshift.com/container-platform/4.7/cli_reference/openshift_cli/usage-oc-kubectl.html | |||
* https://docs.openshift.com/container-platform/ | * https://docs.openshift.com/container-platform/4.7/cli_reference/openshift_cli/developer-cli-commands.html | ||
* https://docs.openshift.com/container-platform/ | |||
=Internal= | =Internal= | ||
* [[OpenShift Command Line Tools#Overview|OpenShift Command Line Tools]] | |||
* [[OpenShift Operations#Subjects|OpenShift Operations]] | * [[OpenShift Operations#Subjects|OpenShift Operations]] | ||
* [[oadm]] | * [[oadm]] | ||
* [[kubectl]] | |||
=Overview= | =Overview= | ||
oc is the OpenShift remote client that talks with the master API server. Intended for regular users. The cluster administrator's CLI interface is [[oadm#Overview|oadm]]. For more details on CLI tool configuration and context see: {{Internal|OpenShift Command Line Tools#Overview|OpenShift Command Line Tools}} | |||
=oc and kubectl= | |||
Because OpenShift is a certified Kubernetes distribution, kubectl binaries that ship with OpenShift can be used with the cluster. The oc binary offers extended functionality. | |||
=Installation= | |||
{{Warn|Make sure to upgrade the client if the server is upgraded.}} | |||
==RHEL== | ==RHEL== | ||
Line 19: | Line 22: | ||
If a new RHEL node needs to be enabled to allow access to an OpenShift environment, and the entire OpenShift set of packages was not installed, only OpenShift clients can be installed as part of the <tt>atomic-openshift-clients</tt> package: | If a new RHEL node needs to be enabled to allow access to an OpenShift environment, and the entire OpenShift set of packages was not installed, only OpenShift clients can be installed as part of the <tt>atomic-openshift-clients</tt> package: | ||
<syntaxhighlight lang='bash'> | |||
yum install atomic-openshift-clients | |||
</syntaxhighlight> | |||
If you get: | If you get: | ||
<syntaxhighlight lang='text'> | |||
No package '''atomic-openshift-clients''' available. | |||
Error: Nothing to do | |||
</syntaxhighlight> | |||
that means that either the host has no access to an OpenShift subscription, and, in consequence, no access to the appropriate repository, or that the "atomic-openshift-excluder" package was previously installed, and an "unexclude" command must be executed, as described here: [[OpenShift_3.5_Installation#Excluders|OpenShift Yum Excluders]]. | that means that either the host has no access to an OpenShift subscription, and, in consequence, no access to the appropriate repository, or that the "atomic-openshift-excluder" package was previously installed, and an "unexclude" command must be executed, as described here: [[OpenShift_3.5_Installation#Excluders|OpenShift Yum Excluders]]. | ||
==Mac== | ==Mac== | ||
Download from https://access.redhat.com/downloads/content/290, choose "OpenShift v3.5 MacOSX Client". Then extract the content and place "oc" in PATH. | Download from https://access.redhat.com/downloads/content/290, choose "OpenShift v3.5 MacOSX Client". Then extract the content and place "oc" in PATH. | ||
==Azure OpenShift oc for Mac== | |||
{{Internal|OpenShift_on_Azure#Mac|Azure OpenShift oc for Mac | Installation}} | |||
=Namespace Selection= | =Namespace Selection= | ||
{{Internal|OpenShift_Command_Line_Tools#Namespace_Selection|CLI Tools Namespace Selection}} | |||
=Output= | =Output= | ||
Line 57: | Line 60: | ||
The curl commands used to send the requests are displayed with: | The curl commands used to send the requests are displayed with: | ||
oc -- | oc --loglevel=10 ... | ||
=Commands= | =Commands= | ||
Line 67: | Line 70: | ||
* <span id="status"></span>[[oc status]] | * <span id="status"></span>[[oc status]] | ||
* <span id="logs"></span>[[oc logs]] | * <span id="logs"></span>[[oc logs]] | ||
* <span id="env"></span>[[oc env]] | |||
* <span id="explain"></span>[[oc explain]] | |||
==Login/Logout== | |||
* <span id="login"></span>[[oc login]] | |||
* <span id="logout"></span>[[oc logout]] | |||
==Set Context== | |||
* <span id='project'></span>[[oc project]], [[oc project|oc projects]] | |||
==Create, Update and Delete Resources== | ==Create, Update and Delete Resources== | ||
Line 75: | Line 89: | ||
* <span id="new-project"></span>[[oc new-project]] | * <span id="new-project"></span>[[oc new-project]] | ||
* <span id="new-app"></span>[[oc new-app]] | * <span id="new-app"></span>[[oc new-app]] | ||
* <span id="new-build"></span>[[oc new-build]] | |||
* <span id="update"></span>[[oc update]] | |||
* <span id="patch"></span>[[oc patch]] | |||
* [[oc set]] | |||
* [[oc apply]] | |||
==Pod/Container Tools== | |||
* <span id="logs"></span>[[oc logs]] | |||
* <span id="rsh"></span>[[oc rsh]] | |||
* <span id="rsync"></span>[[oc rsync]] | |||
* <span id="cp"></span>[[oc cp]] | |||
* <span id="exec"></span>[[oc exec]] | |||
* <span id="run"></span>[[oc run]] | |||
==Build== | |||
* <span id="start-build"></span>[[oc start-build]] | |||
==Deploy== | |||
* <span id="deploy"></span>[[oc deploy]] | |||
* <span id="rollout"></span>[[oc rollout]] | |||
* <span id="scale"></span>[[oc scale]] | |||
==Security== | |||
* <span id="policy"></span>[[oc policy]] | |||
==Miscellaneous== | ==Miscellaneous== | ||
* <span id="export"></span>[[oc export]] | * <span id="export"></span>[[oc export]] | ||
* <span id="extract"></span>[[oc extract]] | * <span id="extract"></span>[[oc extract]] | ||
* <span id="process"></span>[[oc process]] | * <span id="process"></span>[[oc process]] | ||
* <span id="rollback"></span>[[oc rollback]] | * <span id="rollback"></span>[[oc rollback]] | ||
* <span id="tag"></span>[[oc tag]] | * <span id="tag"></span>[[oc tag]] | ||
* <span id="whoami"></span>[[oc whoami]] | * <span id="whoami"></span>[[oc whoami]] | ||
* <span id="types"></span>[[oc types]] | |||
* <span id="port-forward"></span>[[oc port-forward]] | |||
* <span id='import-image'></span>[[oc import-image]] |
Latest revision as of 04:09, 10 April 2021
External
- https://docs.openshift.com/container-platform/4.7/cli_reference/openshift_cli/usage-oc-kubectl.html
- https://docs.openshift.com/container-platform/4.7/cli_reference/openshift_cli/developer-cli-commands.html
Internal
Overview
oc is the OpenShift remote client that talks with the master API server. Intended for regular users. The cluster administrator's CLI interface is oadm. For more details on CLI tool configuration and context see:
oc and kubectl
Because OpenShift is a certified Kubernetes distribution, kubectl binaries that ship with OpenShift can be used with the cluster. The oc binary offers extended functionality.
Installation
Make sure to upgrade the client if the server is upgraded.
RHEL
If a new RHEL node needs to be enabled to allow access to an OpenShift environment, and the entire OpenShift set of packages was not installed, only OpenShift clients can be installed as part of the atomic-openshift-clients package:
yum install atomic-openshift-clients
If you get:
No package '''atomic-openshift-clients''' available.
Error: Nothing to do
that means that either the host has no access to an OpenShift subscription, and, in consequence, no access to the appropriate repository, or that the "atomic-openshift-excluder" package was previously installed, and an "unexclude" command must be executed, as described here: OpenShift Yum Excluders.
Mac
Download from https://access.redhat.com/downloads/content/290, choose "OpenShift v3.5 MacOSX Client". Then extract the content and place "oc" in PATH.
Azure OpenShift oc for Mac
Namespace Selection
Output
In general, all oc commands can be configured to send their output in either JSON or YAML format, rather than execute the command.
This is achieved with
oc ... -o json|yaml
In case of oc get, the output of the server execution is rendered in JSON/YAML if -o json|-o yaml is used.
Logging and Debugging
oc ... --loglevel=8
This log level shows the API requests made with each command.
The curl commands used to send the requests are displayed with:
oc --loglevel=10 ...
Commands
Info
Login/Logout
Set Context
Create, Update and Delete Resources
- oc create
- oc edit
- oc delete
- oc new-project
- oc new-app
- oc new-build
- oc update
- oc patch
- oc set
- oc apply