You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This reference provides descriptions and example commands for OpenShift CLI (`oc`) administrator commands. You must have `cluster-admin` or equivalent permissions to use these commands.
9
+
[role="_abstract"]
10
+
To learn more about the {oc-first} administrator commands, review their descriptions and example commands. You must have `cluster-admin` or equivalent permissions to use these commands.
10
11
11
12
For developer commands, see the xref:../../cli_reference/openshift_cli/developer-cli-commands.adoc#cli-developer-commands[OpenShift CLI developer command reference].
This reference provides descriptions and example commands for OpenShift CLI (`oc`) developer commands.
9
+
[role="_abstract"]
10
+
To learn more about the {oc-first} developer commands, review their descriptions and example commands.
11
+
10
12
ifdef::openshift-enterprise,openshift-origin[]
11
13
For administrator commands, see the xref:../../cli_reference/openshift_cli/administrator-cli-commands.adoc#cli-administrator-commands[OpenShift CLI administrator command reference].
A CLI configuration file allows you to configure different profiles, or contexts, for use with the xref:../../cli_reference/index.adoc#cli-tools-overview[CLI tools overview]. A context consists of
You can use a CLI configuration file to create different profiles, or contexts, for use with the {oc-first}. A context consists of user authentication and a {product-title} server information associated with a _nickname_.
Contexts allow you to easily switch between multiple users across multiple {product-title} servers, or clusters, when using CLI operations. Nicknames make managing CLI configurations easier by providing short-hand references to contexts, user credentials, and cluster details.
10
-
After a user logs in with the `oc` CLI for the first time,
11
-
{product-title} creates a `~/.kube/config` file if one does not already exist. As more authentication and connection details are provided to the CLI, either automatically during an `oc login` operation or by manually configuring CLI profiles, the updated information is stored in the configuration file:
9
+
[role="_abstract"]
10
+
TODO
12
11
13
-
.CLI config file
12
+
Contexts allow you to easily switch between multiple users across multiple {product-title} servers, or clusters, when using CLI operations. Nicknames make managing CLI configurations easier by providing short-hand references to contexts, user credentials, and cluster details.
13
+
After a user logs in with the `oc` CLI for the first time, {product-title} creates a `~/.kube/config` file if one does not already exist. As more authentication and connection details are provided to the CLI, either automatically during an `oc login` operation or by manually configuring CLI profiles, the updated information is stored in the configuration file:
<1> The `clusters` section defines connection details for
48
-
{product-title} clusters, including the address for their master server. In this example, one cluster is nicknamed `openshift1.example.com:8443` and another is nicknamed `openshift2.example.com:8443`.
49
-
<2> This `contexts` section defines two contexts: one nicknamed `alice-project/openshift1.example.com:8443/alice`, using the `alice-project` project, `openshift1.example.com:8443` cluster, and `alice` user, and another nicknamed `joe-project/openshift1.example.com:8443/alice`, using the `joe-project` project, `openshift1.example.com:8443` cluster and `alice` user.
50
-
<3> The `current-context` parameter shows that the `joe-project/openshift1.example.com:8443/alice` context is currently in use, allowing the `alice` user to work in the `joe-project` project on the `openshift1.example.com:8443` cluster.
51
-
<4> The `users` section defines user credentials. In this example, the user nickname `alice/openshift1.example.com:8443` uses an access token.
49
+
`clusters`:: Specifies connection details for {product-title} clusters, including the address for their master server. In this example, one cluster is nicknamed `openshift1.example.com:8443` and another is nicknamed `openshift2.example.com:8443`.
50
+
`contexts`:: Specifies two contexts: one nicknamed `alice-project/openshift1.example.com:8443/alice`, using the `alice-project` project, `openshift1.example.com:8443` cluster, and `alice` user, and another nicknamed `joe-project/openshift1.example.com:8443/alice`, using the `joe-project` project, `openshift1.example.com:8443` cluster and `alice` user.
51
+
`current-context`:: Specifies that the `joe-project/openshift1.example.com:8443/alice` context is currently in use, allowing the `alice` user to work in the `joe-project` project on the `openshift1.example.com:8443` cluster.
52
+
`users`:: Specifies user credentials. In this example, the user nickname `alice/openshift1.example.com:8443` uses an access token.
52
53
53
54
The CLI can support multiple configuration files which are loaded at runtime and merged together along with any override options specified from the command line. After you are logged in, you can use the `oc status` or `oc project` command to verify your current working environment:
54
55
55
56
.Verify the current working environment
56
-
57
57
[source,terminal,options="nowrap"]
58
58
----
59
59
$ oc status
@@ -62,7 +62,6 @@ $ oc status
62
62
.Example output
63
63
[source,terminal]
64
64
----
65
-
oc status
66
65
In project Joe's Project (joe-project)
67
66
68
67
service database (172.30.43.12:5434 -> 3306)
@@ -107,7 +106,7 @@ At any time, you can use the `oc config view` command to view your current CLI c
107
106
108
107
[NOTE]
109
108
====
110
-
If you have access to administrator credentials but are no longer logged in as the default system user `system:admin`, you can log back in as this user at any time as long as the credentials are still present in your CLI config file. The following command logs in and switches to the default project:
109
+
If you have access to administrator credentials but are no longer logged in as the default system user `system:admin`, you can log back in as this user at any time as long as the credentials are still present in your CLI configuration file. The following command logs in and switches to the default project:
you can use the following command to view the current namespace.
56
+
For example, if you built and installed the `kubectl-ns` plugin from the link:https://github.com/kubernetes/sample-cli-plugin[Sample plugin repository], you can use the following command to view the current namespace.
60
57
+
61
58
[source,terminal]
62
59
----
63
60
$ oc ns
64
61
----
65
62
+
66
63
Note that the command to invoke the plugin depends on the plugin file name.
67
-
For example, a plugin with the file name of `oc-foo-bar` is invoked by the `oc foo bar`
68
-
command.
64
+
For example, a plugin with the file name of `oc-foo-bar` is invoked by the `oc foo bar` command.
or script that allows you to write command-line commands. Note that you can not
18
-
use a plugin to overwrite an existing `oc` command.
17
+
CLI in any programming language or script that allows you to write command-line commands. Note that you cannot use a plugin to overwrite an existing `oc` command.
19
18
20
-
.Procedure
19
+
This procedure creates a simple Bash plugin that prints a message to the terminal when the `oc foo` command is issued.
21
20
22
-
This procedure creates a simple Bash plugin that prints a message to the
23
-
terminal when the `oc foo` command is issued.
21
+
.Procedure
24
22
25
23
. Create a file called `oc-foo`.
26
24
+
27
25
When naming your plugin file, keep the following in mind:
28
26
29
27
* The file must begin with `oc-` or `kubectl-` to be recognized as a
30
28
plugin.
31
-
* The file name determines the command that invokes the plugin. For example, a
32
-
plugin with the file name `oc-foo-bar` can be invoked by a command of
33
-
`oc foo bar`. You can also use underscores if you want the command to contain
34
-
dashes. For example, a plugin with the file name `oc-foo_bar` can be invoked
35
-
by a command of `oc foo-bar`.
29
+
* The file name determines the command that invokes the plugin. For example, a plugin with the file name `oc-foo-bar` can be invoked by a command of `oc foo bar`. You can also use underscores if you want the command to contain dashes. For example, a plugin with the file name `oc-foo_bar` can be invoked by a command of `oc foo-bar`.
If you want to manually configure your CLI configuration files, you can use the `oc config` command instead of directly modifying the files.
11
+
12
+
[NOTE]
13
+
====
14
+
This section covers more advanced usage of CLI configurations. In most situations, you can use the `oc login` and `oc project` commands to log in and switch between contexts and projects.
15
+
====
16
+
17
+
// TODO, Add a non-xref reference to the reference table. no need to additional resources i think, since it'll be right after
18
+
19
+
.Prerequisites
20
+
21
+
* TODO, any?
22
+
23
+
.Procedure
24
+
25
+
. Log in as a user that uses an access token. This token is used by the `alice` user:
0 commit comments