mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
OSDOCS#17273:CLI concepts and configuration
This commit is contained in:
committed by
openshift-cherrypick-robot
parent
dea6097000
commit
66a2dff904
@@ -6,9 +6,10 @@ include::_attributes/attributes-microshift.adoc[]
|
||||
|
||||
toc::[]
|
||||
|
||||
[role="_abstract"]
|
||||
You can use different command-line interface (CLI) tools to build, deploy, and manage a {microshift-short} node and workloads. With CLI tools, you can complete various administration and development operations from the terminal to manage deployments and interact with each component of the system.
|
||||
|
||||
CLI tools available for use with {microshift-short} are the following:
|
||||
The following CLI tools are available to use with {microshift-short}:
|
||||
|
||||
* Kubernetes CLI (`kubectl`)
|
||||
* The {oc-first} tool with an enabled subset of commands
|
||||
@@ -24,4 +25,4 @@ Commands for multi-node deployments, projects, and developer tools are not suppo
|
||||
== Additional resources
|
||||
|
||||
* xref:../microshift_cli_ref/microshift-oc-cli-install.adoc#microshift-oc-cli-install[Getting started with the OpenShift CLI]
|
||||
* link:https://docs.redhat.com/en/documentation/openshift_container_platform/{ocp-version}/html/cli_tools/openshift-cli-oc#cli-about-cli_cli-developer-commands[About the OpenShift CLI] ({OCP} documentation)
|
||||
* link:https://docs.redhat.com/en/documentation/openshift_container_platform/{ocp-version}/html/cli_tools/openshift-cli-oc#cli-about-cli_cli-developer-commands[About the OpenShift CLI]
|
||||
|
||||
@@ -6,75 +6,12 @@ include::_attributes/attributes-microshift.adoc[]
|
||||
|
||||
toc::[]
|
||||
|
||||
[role="_abstract"]
|
||||
The optional {oc-first} tool provides a subset of `oc` commands for {microshift-short} deployments. Using `oc` is convenient if you are familiar with {OCP} and Kubernetes.
|
||||
|
||||
include::modules/microshift-cli-oc-about.adoc[leveloffset=+1]
|
||||
|
||||
[id="cli-using-cli_{context}"]
|
||||
== Using oc with a {microshift-short} node
|
||||
|
||||
Review the following sections to learn how to complete common tasks in {microshift-short} using the `oc` CLI.
|
||||
|
||||
[id="viewing-pods_{context}"]
|
||||
=== Viewing pods
|
||||
|
||||
Use the `oc get pods` command to view the pods for the current project.
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
When you run `oc` inside a pod and do not specify a namespace, the namespace of the pod is used by default.
|
||||
====
|
||||
|
||||
[source,terminal]
|
||||
----
|
||||
$ oc get pods -o wide
|
||||
----
|
||||
|
||||
.Example output
|
||||
[source,terminal]
|
||||
----
|
||||
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE
|
||||
cakephp-ex-1-build 0/1 Completed 0 5m45s 10.131.0.10 ip-10-0-141-74.ec2.internal <none>
|
||||
cakephp-ex-1-deploy 0/1 Completed 0 3m44s 10.129.2.9 ip-10-0-147-65.ec2.internal <none>
|
||||
cakephp-ex-1-ktz97 1/1 Running 0 3m33s 10.128.2.11 ip-10-0-168-105.ec2.internal <none>
|
||||
----
|
||||
|
||||
[id="viewing-pod-logs_{context}"]
|
||||
=== Viewing pod logs
|
||||
|
||||
Use the `oc logs` command to view logs for a particular pod.
|
||||
|
||||
[source,terminal]
|
||||
----
|
||||
$ oc logs cakephp-ex-1-deploy
|
||||
----
|
||||
|
||||
.Example output
|
||||
[source,terminal]
|
||||
----
|
||||
--> Scaling cakephp-ex-1 to 1
|
||||
--> Success
|
||||
----
|
||||
|
||||
[id="listing-supported-apis_{context}"]
|
||||
=== Listing supported API resources
|
||||
|
||||
Use the `oc api-resources` command to view the list of supported API resources on the server.
|
||||
|
||||
[source,terminal]
|
||||
----
|
||||
$ oc api-resources
|
||||
----
|
||||
|
||||
.Example output
|
||||
[source,terminal]
|
||||
----
|
||||
NAME SHORTNAMES APIGROUP NAMESPACED KIND
|
||||
bindings true Binding
|
||||
componentstatuses cs false ComponentStatus
|
||||
configmaps cm true ConfigMap
|
||||
...
|
||||
----
|
||||
include::modules/microshift-cli-oc-logs.adoc[leveloffset=+1]
|
||||
|
||||
// Getting help
|
||||
include::modules/microshift-cli-oc-get-help.adoc[leveloffset=+1]
|
||||
|
||||
@@ -6,30 +6,10 @@ include::_attributes/attributes-microshift.adoc[]
|
||||
|
||||
toc::[]
|
||||
|
||||
Descriptions and example commands for {oc-first} commands are included in this reference document. You must have `cluster-admin` or equivalent permissions to use these commands. To list administrator commands and information about them, use the following commands:
|
||||
[role="_abstract"]
|
||||
Descriptions and example commands for {oc-first} commands are included in this reference document. You must have `cluster-admin` or equivalent permissions to use these commands.
|
||||
|
||||
* Enter the `oc adm -h` command to list all administrator commands:
|
||||
+
|
||||
.Command syntax
|
||||
+
|
||||
[source,terminal]
|
||||
----
|
||||
$ oc adm -h
|
||||
----
|
||||
|
||||
* Enter the `oc <command> --help` command to get additional details for a specific command:
|
||||
+
|
||||
.Command syntax
|
||||
+
|
||||
[source,terminal]
|
||||
----
|
||||
$ oc <command> --help
|
||||
----
|
||||
|
||||
[IMPORTANT]
|
||||
====
|
||||
Using `oc <command> --help` lists details for any `oc` command. Not all `oc` commands apply to using {product-title}.
|
||||
====
|
||||
include::modules/microshift-oc-cmd.adoc[leveloffset=+1]
|
||||
|
||||
// The OCP files are auto-generated from the openshift/oc repository; use the MicroShift-specific flags to generate MicroShift command files from the same repo
|
||||
include::modules/microshift-oc-by-example-content.adoc[leveloffset=+1]
|
||||
|
||||
@@ -6,6 +6,7 @@ include::_attributes/attributes-microshift.adoc[]
|
||||
|
||||
toc::[]
|
||||
|
||||
[role="_abstract"]
|
||||
To use the {oc-first} tool, you must download and install it separately from your {microshift-short} installation. You can install `oc` by downloading the binary or by using Homebrew.
|
||||
|
||||
// Installing the OpenShift CLI on Linux
|
||||
|
||||
@@ -6,6 +6,7 @@ include::_attributes/attributes-microshift.adoc[]
|
||||
|
||||
toc::[]
|
||||
|
||||
[role="_abstract"]
|
||||
Configure {oc-first} based on your preferences for working with it.
|
||||
|
||||
[id="cli-enabling-tab-completion"]
|
||||
|
||||
@@ -6,6 +6,7 @@ include::_attributes/attributes-microshift.adoc[]
|
||||
|
||||
toc::[]
|
||||
|
||||
[role="_abstract"]
|
||||
The Kubernetes command-line interface (CLI), `kubectl`, can be used to run commands against a Kubernetes cluster. Because {microshift-short} is a certified Kubernetes distribution, you can use the supported `kubectl` CLI tool or you can gain extended functionality by using the {oc-first}.
|
||||
|
||||
[id="microshift-kubectl-binary_{context}"]
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
[id="cli-enabling-tab-completion-zsh_{context}"]
|
||||
= Enabling tab completion for Zsh
|
||||
|
||||
[role="_abstract"]
|
||||
After you install the OpenShift CLI (`oc`), you can enable tab completion to automatically complete `oc` commands or suggest options when you press Tab. The following procedure enables tab completion for the Zsh shell.
|
||||
|
||||
.Prerequisites
|
||||
@@ -27,5 +28,5 @@ if [ $commands[oc] ]; then
|
||||
fi
|
||||
EOF
|
||||
----
|
||||
|
||||
+
|
||||
Tab completion is enabled when you open a new terminal.
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
[id="cli-enabling-tab-completion_{context}"]
|
||||
= Enabling tab completion for Bash
|
||||
|
||||
[role="_abstract"]
|
||||
After you install the OpenShift CLI (`oc`), you can enable tab completion to automatically complete `oc` commands or suggest options when you press Tab. The following procedure enables tab completion for the Bash shell.
|
||||
|
||||
.Prerequisites
|
||||
@@ -29,6 +30,4 @@ $ oc completion bash > oc_bash_completion
|
||||
$ sudo cp oc_bash_completion /etc/bash_completion.d/
|
||||
----
|
||||
+
|
||||
You can also save the file to a local directory and source it from your `.bashrc` file instead.
|
||||
|
||||
Tab completion is enabled when you open a new terminal.
|
||||
You can also save the file to a local directory and source it from your `.bashrc` file instead. Tab completion is enabled when you open a new terminal.
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
[id="cli-installing-cli-brew_{context}"]
|
||||
= Installing the OpenShift CLI by using Homebrew
|
||||
|
||||
[role="_abstract"]
|
||||
For macOS, you can install the OpenShift CLI (`oc`) by using the link:https://brew.sh[Homebrew] package manager.
|
||||
|
||||
.Prerequisites
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
[id="cli-installing-cli-rpm_{context}"]
|
||||
= Installing the OpenShift CLI by using an RPM
|
||||
|
||||
[role="_abstract"]
|
||||
For {op-system-base-full}, you can install the {oc-first} as an RPM if you have an active {product-title} subscription on your Red Hat account.
|
||||
|
||||
[IMPORTANT]
|
||||
@@ -16,7 +17,7 @@ You must install `oc` for {op-system-base} 9 by downloading the binary. Installi
|
||||
|
||||
.Prerequisites
|
||||
|
||||
* Must have root or sudo privileges.
|
||||
* You must have root or sudo privileges.
|
||||
|
||||
.Procedure
|
||||
|
||||
@@ -78,7 +79,7 @@ endif::openshift-rosa[]
|
||||
.Verification
|
||||
|
||||
* Verify your installation by using an `oc` command:
|
||||
|
||||
+
|
||||
[source,terminal]
|
||||
----
|
||||
$ oc <command>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
[id="microshift-cli-oc-about_{context}"]
|
||||
= About the OpenShift CLI
|
||||
|
||||
[role="_abstract"]
|
||||
With the OpenShift command-line interface (CLI), the `oc` command, you can deploy and manage {microshift-short} projects from a terminal. The CLI `oc` tool is ideal in the following situations:
|
||||
|
||||
* Working directly with project source code
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
[id="cli-getting-help_{context}"]
|
||||
= Getting help
|
||||
|
||||
[role="_abstract"]
|
||||
You can get help with CLI commands and {microshift-short} resources in the following ways.
|
||||
|
||||
* Use `oc help --flag` to get information about a specific CLI command:
|
||||
|
||||
62
modules/microshift-cli-oc-logs.adoc
Normal file
62
modules/microshift-cli-oc-logs.adoc
Normal file
@@ -0,0 +1,62 @@
|
||||
// Module included in the following assemblies:
|
||||
//
|
||||
// * microshift-cli-using-oc/microshift-oc-apis-errors.adoc
|
||||
|
||||
:_mod-docs-content-type: CONCEPT
|
||||
[id="cli-using-cli_{context}"]
|
||||
= Using oc with a {microshift-short} node
|
||||
|
||||
[role="_abstract"]
|
||||
You can complete common tasks in {microshift-short} by using the `oc` CLI.
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
When you run `oc` inside a pod and do not specify a namespace, the namespace of the pod is used by default.
|
||||
====
|
||||
|
||||
* To view the pods for the current project, run the `oc get pods` command:
|
||||
+
|
||||
[source,terminal]
|
||||
----
|
||||
$ oc get pods -o wide
|
||||
----
|
||||
+
|
||||
.Example output
|
||||
[source,terminal]
|
||||
----
|
||||
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE
|
||||
cakephp-ex-1-build 0/1 Completed 0 5m45s 10.131.0.10 ip-10-0-141-74.ec2.internal <none>
|
||||
cakephp-ex-1-deploy 0/1 Completed 0 3m44s 10.129.2.9 ip-10-0-147-65.ec2.internal <none>
|
||||
cakephp-ex-1-ktz97 1/1 Running 0 3m33s 10.128.2.11 ip-10-0-168-105.ec2.internal <none>
|
||||
----
|
||||
|
||||
* To view logs for a particular pod, run the `oc logs` command:
|
||||
+
|
||||
[source,terminal]
|
||||
----
|
||||
$ oc logs cakephp-ex-1-deploy
|
||||
----
|
||||
+
|
||||
.Example output
|
||||
[source,terminal]
|
||||
----
|
||||
--> Scaling cakephp-ex-1 to 1
|
||||
--> Success
|
||||
----
|
||||
|
||||
* To view the list of supported API resources on the server, run the `oc api-resources` command:
|
||||
+
|
||||
[source,terminal]
|
||||
----
|
||||
$ oc api-resources
|
||||
----
|
||||
+
|
||||
.Example output
|
||||
[source,terminal]
|
||||
----
|
||||
NAME SHORTNAMES APIGROUP NAMESPACED KIND
|
||||
bindings true Binding
|
||||
componentstatuses cs false ComponentStatus
|
||||
configmaps cm true ConfigMap
|
||||
...
|
||||
----
|
||||
@@ -6,6 +6,7 @@
|
||||
[id="microshift-oc-apis-errors_{context}"]
|
||||
= oc command errors in {microshift-short}
|
||||
|
||||
[role="_abstract"]
|
||||
Not all {oc-first} commands are relevant for {microshift-short} deployments. When you use `oc` to make a request call against an unsupported API, the `oc` binary usually generates an error message about a resource that cannot be found.
|
||||
|
||||
* For example, when you run the following `new-project` command:
|
||||
|
||||
29
modules/microshift-oc-cmd.adoc
Normal file
29
modules/microshift-oc-cmd.adoc
Normal file
@@ -0,0 +1,29 @@
|
||||
// Module included in the following assemblies:
|
||||
//
|
||||
// * microshift_cli_ref/microshift-oc-cli-commands.adoc
|
||||
|
||||
:_mod-docs-content-type: CONCEPT
|
||||
[id="microshift-oc-cmd_{context}"]
|
||||
= OpenShift administrator commands
|
||||
|
||||
[role="_abstract"]
|
||||
If you have `cluster-admin` or equivalent permissions, you can list administrator commands.
|
||||
|
||||
* Enter the `oc adm -h` command to list all administrator commands:
|
||||
+
|
||||
[source,terminal]
|
||||
----
|
||||
$ oc adm -h
|
||||
----
|
||||
|
||||
* Enter the `oc <command> --help` command to get additional details for a specific command:
|
||||
+
|
||||
[source,terminal]
|
||||
----
|
||||
$ oc <command> --help
|
||||
----
|
||||
+
|
||||
[IMPORTANT]
|
||||
====
|
||||
Using `oc <command> --help` lists details for any `oc` command. Not all `oc` commands apply to using {product-title}.
|
||||
====
|
||||
Reference in New Issue
Block a user