Skip to content

Commit b8c2e60

Browse files
committed
OSDOCS#16913: CQA for next set of CLI assemblies
1 parent f3b048c commit b8c2e60

13 files changed

Lines changed: 158 additions & 133 deletions

cli_reference/openshift_cli/administrator-cli-commands.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ include::_attributes/common-attributes.adoc[]
66

77
toc::[]
88

9-
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.
1011

1112
For developer commands, see the xref:../../cli_reference/openshift_cli/developer-cli-commands.adoc#cli-developer-commands[OpenShift CLI developer command reference].
1213

cli_reference/openshift_cli/configuring-cli.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ include::_attributes/common-attributes.adoc[]
66

77
toc::[]
88

9+
[role="_abstract"]
10+
TODO
11+
12+
// TODO move this below to module? so small though. Maybe just consider removing the umbrella heading
913
[id="cli-enabling-tab-completion"]
1014
== Enabling tab completion
1115

cli_reference/openshift_cli/developer-cli-commands.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ include::_attributes/common-attributes.adoc[]
66

77
toc::[]
88

9-
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+
1012
ifdef::openshift-enterprise,openshift-origin[]
1113
For administrator commands, see the xref:../../cli_reference/openshift_cli/administrator-cli-commands.adoc#cli-administrator-commands[OpenShift CLI administrator command reference].
1214
endif::openshift-enterprise,openshift-origin[]

cli_reference/openshift_cli/extending-cli-plugins.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ include::_attributes/common-attributes.adoc[]
66

77
toc::[]
88

9-
You can write and install plugins to build on the default `oc` commands,
10-
allowing you to perform new and more complex tasks with the
9+
[role="_abstract"]
10+
You can write and install plugins to build on the default `oc` commands, allowing you to perform new and more complex tasks with the
1111
ifndef::openshift-dedicated,openshift-rosa,openshift-rosa-hcp[]
1212
{product-title}
1313
endif::openshift-dedicated,openshift-rosa,openshift-rosa-hcp[]

cli_reference/openshift_cli/managing-cli-profiles.adoc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@ include::_attributes/common-attributes.adoc[]
66

77
toc::[]
88

9-
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
10-
ifndef::microshift,openshift-dedicated,openshift-rosa,openshift-rosa-hcp[]
11-
xref:../../authentication/understanding-authentication.adoc#understanding-authentication[user authentication]
12-
endif::microshift,openshift-dedicated,openshift-rosa,openshift-rosa-hcp[]
13-
ifdef::microshift[]
14-
user authentication
15-
endif::[]
16-
a {product-title}
17-
server information associated with a _nickname_.
9+
[role="_abstract"]
10+
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_.
1811

1912
include::modules/about-cli-profiles-switch.adoc[leveloffset=+1]
2013

21-
include::modules/manual-configuration-of-cli-profiles.adoc[leveloffset=+1]
14+
include::modules/manual-configuration-of-cli-profiles-example.adoc[leveloffset=+1]
15+
16+
include::modules/manual-configuration-of-cli-profiles.adoc[leveloffset=+2]
2217

2318
include::modules/load-and-merge-rules.adoc[leveloffset=+1]
19+
20+
[role="_additional-resources"]
21+
[id="additional-resources_managing-cli-profiles"]
22+
== Additional resources
23+
24+
* xref:../../cli_reference/index.adoc#cli-tools-overview[CLI tools overview]
25+
ifndef::microshift,openshift-dedicated,openshift-rosa,openshift-rosa-hcp[]
26+
* xref:../../authentication/understanding-authentication.adoc#understanding-authentication[user authentication]
27+
endif::microshift,openshift-dedicated,openshift-rosa,openshift-rosa-hcp[]

modules/about-cli-profiles-switch.adoc

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44

55
:_mod-docs-content-type: CONCEPT
66
[id="about-switches-between-cli-profiles_{context}"]
7-
= About switches between CLI profiles
7+
= About switching between CLI profiles
88

9-
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
1211

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:
1414

15+
.CLI configuration file
1516
[source,yaml]
1617
----
1718
apiVersion: v1
18-
clusters: <1>
19+
clusters:
1920
- cluster:
2021
insecure-skip-tls-verify: true
2122
server: https://openshift1.example.com:8443
@@ -24,7 +25,7 @@ clusters: <1>
2425
insecure-skip-tls-verify: true
2526
server: https://openshift2.example.com:8443
2627
name: openshift2.example.com:8443
27-
contexts: <2>
28+
contexts:
2829
- context:
2930
cluster: openshift1.example.com:8443
3031
namespace: alice-project
@@ -35,25 +36,24 @@ contexts: <2>
3536
namespace: joe-project
3637
user: alice/openshift1.example.com:8443
3738
name: joe-project/openshift1/alice
38-
current-context: joe-project/openshift1.example.com:8443/alice <3>
39+
current-context: joe-project/openshift1.example.com:8443/alice
3940
kind: Config
4041
preferences: {}
4142
users: <4>
4243
- name: alice/openshift1.example.com:8443
4344
user:
4445
token: xZHd2piv5_9vQrg-SKXRJ2Dsl9SceNJdhNTljEKTb8k
4546
----
47+
where:
4648

47-
<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.
5253

5354
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:
5455

5556
.Verify the current working environment
56-
5757
[source,terminal,options="nowrap"]
5858
----
5959
$ oc status
@@ -62,7 +62,6 @@ $ oc status
6262
.Example output
6363
[source,terminal]
6464
----
65-
oc status
6665
In project Joe's Project (joe-project)
6766
6867
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
107106

108107
[NOTE]
109108
====
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:
111110
112111
[source,terminal]
113112
----

modules/cli-configuring-kubeconfig-using-cli.adoc

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66
[id="cli-accessing-kubeconfig-using-cli_{context}"]
77
= Accessing kubeconfig by using the oc CLI
88

9+
[role="_abstract"]
910
You can use the `oc` CLI to log in to your OpenShift cluster and retrieve a kubeconfig file for accessing the cluster from the command line.
1011

12+
[IMPORTANT]
13+
====
14+
If you plan to reuse the exported `kubeconfig` file across sessions or machines, store it securely and avoid committing it to source control.
15+
====
16+
1117
.Prerequisites
1218

1319
* You have access to the {product-title} web console or API server endpoint.
@@ -18,12 +24,14 @@ You can use the `oc` CLI to log in to your OpenShift cluster and retrieve a kube
1824
+
1925
[source,terminal]
2026
----
21-
$ oc login <api-server-url> -u <username> -p <password> <1><2><3>
27+
$ oc login <api_server_url> -u <username> -p <password>
2228
----
2329
+
24-
<1> Specify the full API server URL. For example: `https://api.my-cluster.example.com:6443`.
25-
<2> Specify a valid username. For example: `kubeadmin`.
26-
<3> Provide the password for the specified user. For example, the `kubeadmin` password generated during cluster installation.
30+
where:
31+
32+
`<api_server_url>`:: Specifies the full API server URL; for example, `https://api.my-cluster.example.com:6443`.
33+
`<username>`:: Specifies a valid username; for example, `kubeadmin`.
34+
`<password>`:: Specifies the password for the specified user; for example, the `kubeadmin` password generated during cluster installation.
2735

2836
. Save the cluster configuration to a local file by running the following command:
2937
+
@@ -45,8 +53,3 @@ $ export KUBECONFIG=./kubeconfig
4553
----
4654
$ oc get nodes
4755
----
48-
49-
[NOTE]
50-
====
51-
If you plan to reuse the exported `kubeconfig` file across sessions or machines, store it securely and avoid committing it to source control.
52-
====

modules/cli-extending-plugins-installing.adoc

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
[id="cli-installing-plugins_{context}"]
77
= Installing and using CLI plugins
88

9+
[role="_abstract"]
910
After you write a custom plugin for the
1011
ifndef::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[]
1112
{product-title}
1213
endif::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[]
1314
ifdef::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[]
1415
OpenShift
1516
endif::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[]
16-
CLI, you must install
17-
the plugin before use.
17+
CLI, you must install the plugin before use.
1818

1919
.Prerequisites
2020

@@ -50,19 +50,15 @@ The following compatible plugins are available:
5050
/usr/local/bin/<plugin_file>
5151
----
5252
+
53-
If your plugin is not listed here, verify that the file begins with `oc-`
54-
or `kubectl-`, is executable, and is on your `PATH`.
53+
If your plugin is not listed here, verify that the file begins with `oc-` or `kubectl-`, is executable, and is on your `PATH`.
5554
. Invoke the new command or option introduced by the plugin.
5655
+
57-
For example, if you built and installed the `kubectl-ns` plugin from the
58-
link:https://github.com/kubernetes/sample-cli-plugin[Sample plugin repository],
59-
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.
6057
+
6158
[source,terminal]
6259
----
6360
$ oc ns
6461
----
6562
+
6663
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.

modules/cli-extending-plugins-writing.adoc

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,27 @@
66
[id="cli-writing-plugins_{context}"]
77
= Writing CLI plugins
88

9+
[role="_abstract"]
910
You can write a plugin for the
1011
ifndef::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[]
1112
{product-title}
1213
endif::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[]
1314
ifdef::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[]
1415
OpenShift
1516
endif::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[]
16-
CLI in any programming language
17-
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.
1918

20-
.Procedure
19+
This procedure creates a simple Bash plugin that prints a message to the terminal when the `oc foo` command is issued.
2120

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
2422

2523
. Create a file called `oc-foo`.
2624
+
2725
When naming your plugin file, keep the following in mind:
2826

2927
* The file must begin with `oc-` or `kubectl-` to be recognized as a
3028
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`.
3630
3731
. Add the following contents to the file.
3832
+
@@ -56,20 +50,18 @@ fi
5650

5751
echo "I am a plugin named kubectl-foo"
5852
----
59-
53+
+
6054
After you install this plugin for the
6155
ifndef::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[]
6256
{product-title}
6357
endif::openshift-rosa,openshift-rosa-hcp,openshift-dedicated[]
6458
ifdef::openshift-rosa,openshift-rosa-hcp[]
6559
OpenShift
6660
endif::openshift-rosa,openshift-rosa-hcp[]
67-
CLI, it can be invoked
68-
using the `oc foo` command.
61+
CLI, it can be invoked using the `oc foo` command.
6962

7063
[role="_additional-resources"]
7164
.Additional resources
7265

73-
* Review the link:https://github.com/kubernetes/sample-cli-plugin[Sample plugin repository]
74-
for an example of a plugin written in Go.
75-
* Review the link:https://github.com/kubernetes/cli-runtime/[CLI runtime repository] for a set of utilities to assist in writing plugins in Go.
66+
* link:https://github.com/kubernetes/sample-cli-plugin[Sample plugin repository]
67+
* link:https://github.com/kubernetes/cli-runtime/[CLI runtime repository]
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * cli_reference/openshift_cli/managing-cli-profiles.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="manual-configuration-of-cli-profiles-example_{context}"]
7+
= Manually configuring CLI profiles
8+
9+
[role="_abstract"]
10+
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:
26+
+
27+
[source,terminal,options="nowrap"]
28+
----
29+
$ oc login https://openshift1.example.com --token=ns7yVhuRNpDM9cgzfhhxQ7bM5s7N2ZVrkZepSRf4LC0
30+
----
31+
32+
. View the cluster entry automatically created:
33+
+
34+
[source,terminal,options="nowrap"]
35+
----
36+
$ oc config view
37+
----
38+
+
39+
.Example output
40+
[source,terminal]
41+
----
42+
apiVersion: v1
43+
clusters:
44+
- cluster:
45+
insecure-skip-tls-verify: true
46+
server: https://openshift1.example.com
47+
name: openshift1-example-com
48+
contexts:
49+
- context:
50+
cluster: openshift1-example-com
51+
namespace: default
52+
user: alice/openshift1-example-com
53+
name: default/openshift1-example-com/alice
54+
current-context: default/openshift1-example-com/alice
55+
kind: Config
56+
preferences: {}
57+
users:
58+
- name: alice/openshift1.example.com
59+
user:
60+
token: ns7yVhuRNpDM9cgzfhhxQ7bM5s7N2ZVrkZepSRf4LC0
61+
----
62+
63+
. Update the current context to have users log in to the desired namespace:
64+
+
65+
[source,terminal]
66+
----
67+
$ oc config set-context `oc config current-context` --namespace=<project_name>
68+
----
69+
70+
. Examine the current context, to confirm that the changes are implemented:
71+
+
72+
[source,terminal]
73+
----
74+
$ oc whoami -c
75+
----
76+
+
77+
All subsequent CLI operations uses the new context, unless otherwise specified by overriding CLI options or until the context is switched.

0 commit comments

Comments
 (0)