File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed
cli_reference/openshift_cli Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -16,3 +16,6 @@ include::modules/cli-configuring-completion.adoc[leveloffset=+2]
1616
1717// Enabling tab completion for Zsh
1818include::modules/cli-configuring-completion-zsh.adoc[leveloffset=+2]
19+
20+ // Configuring a kubeconfig file by using the oc CLI
21+ include::modules/cli-configuring-kubeconfig-using-cli.adoc[leveloffset=+1]
Original file line number Diff line number Diff line change 1+ // Module included in the following assemblies:
2+ //
3+ // * cli_reference/openshift_cli/configuring-cli.adoc
4+
5+ :_mod-docs-content-type: PROCEDURE
6+ [id="cli-accessing-kubeconfig-using-cli_{context} "]
7+ = Accessing kubeconfig by using the oc CLI
8+
9+ 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.
10+
11+ .Prerequisites
12+
13+ * You have access to the {product-title} web console or API server endpoint.
14+
15+ .Procedure
16+
17+ . Log in to your OpenShift cluster by running the following command:
18+ +
19+ [source,terminal]
20+ ----
21+ $ oc login <api-server-url > -u <username > -p <password > <1><2><3>
22+ ----
23+ +
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.
27+
28+ . Save the cluster configuration to a local file by running the following command:
29+ +
30+ [source,terminal]
31+ ----
32+ $ oc config view -- raw > kubeconfig
33+ ----
34+
35+ . Set the `KUBECONFIG` environment variable to point to the exported file by running the following command:
36+ +
37+ [source,terminal]
38+ ----
39+ $ export KUBECONFIG=./kubeconfig
40+ ----
41+
42+ . Use `oc` to interact with your OpenShift cluster by running the following command:
43+ +
44+ [source,terminal]
45+ ----
46+ $ oc get nodes
47+ ----
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+ ====
You can’t perform that action at this time.
0 commit comments