-
Notifications
You must be signed in to change notification settings - Fork 1.8k
OCPBUGS-54613: Added acessing to kubeconfig using oc CLI module #95219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -16,3 +16,10 @@ include::modules/cli-configuring-completion.adoc[leveloffset=+2] | |||||
|
||||||
// Enabling tab completion for Zsh | ||||||
include::modules/cli-configuring-completion-zsh.adoc[leveloffset=+2] | ||||||
|
||||||
[id="cli-configuring-kubeconfig_{context}"] | ||||||
== Configuring a kubeconfig file by using the oc CLI | ||||||
|
||||||
You can use the `oc` Command-Line Interface (CLI) to log in to your OpenShift cluster and retrieve the `kubeconfig` file. The `kubeconfig` file contains the configuration information required to interact with the cluster using CLI tools such as `kubectl` or `oc`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
include::modules/cli-configuring-kubeconfig-using-cli.adoc[leveloffset=+2] |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,50 @@ | ||||||
// Module included in the following assemblies: | ||||||
// | ||||||
// * cli_reference/openshift_cli/configuring-cli.adoc | ||||||
|
||||||
:_mod-docs-content-type: PROCEDURE | ||||||
[id="cli-accessing-kubeconfig-using-cli_{context}"] | ||||||
= Accessing `kubeconfig` using the `oc` CLI | ||||||
|
||||||
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. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
.Prerequisites | ||||||
|
||||||
* You have access to the {product-title} web console or API server endpoint. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
.Procedure | ||||||
|
||||||
. Log in to your OpenShift cluster by running the following command: | ||||||
+ | ||||||
[source,terminal] | ||||||
---- | ||||||
$ oc login <api-server-url> -u <username> -p <password> <1> | ||||||
---- | ||||||
+ | ||||||
<1> Replace `<api-server-url>` with the full API server URL, such as `https://api.my-cluster.example.com:6443`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also mention/give an example of |
||||||
|
||||||
. Save the cluster configuration to a local file by running the following command: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think
Suggested change
|
||||||
+ | ||||||
[source,terminal] | ||||||
---- | ||||||
$ oc config view --raw > kubeconfig | ||||||
---- | ||||||
|
||||||
. Set the `KUBECONFIG` environment variable to point to the exported file by running the following command: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
+ | ||||||
[source,terminal] | ||||||
---- | ||||||
$ export KUBECONFIG=./kubeconfig | ||||||
---- | ||||||
|
||||||
. You can now use `kubectl` to interact with your OpenShift cluster by running the following command: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
+ | ||||||
[source,terminal] | ||||||
---- | ||||||
$ kubectl get nodes | ||||||
---- | ||||||
|
||||||
[NOTE] | ||||||
==== | ||||||
If you plan to reuse the exported `kubeconfig` file across sessions or machines, store it securely and avoid committing it to source control. | ||||||
==== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or
Could you re-word it (similar to the suggestion) as we do not
configure
thekubeconfig
file?