Skip to content
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

Update cli.adoc #21

Merged
merged 6 commits into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions docs/modules/ROOT/pages/getting-started/cli.adoc
Original file line number Diff line number Diff line change
@@ -1 +1,78 @@
= Getting started with the CLI

While {ProductName} offers a powerful UI, users may also want to access the platform through the `kubectl` command line interface (CLI). For users to gain this access, a Platform Engineer (PE) must first configure their instance of {ProductName} to support CLI access. They must also draft a template `kubeconfig` file for their organization. Afterwards, users can edit that template to create a `kubeconfig` file specific to themselves. Then, they use that file to gain access to {ProductName} through the CLI.

Whether you need to enable CLI access, or to gain access once it is available, refer to the relevant procedures below.

== Enabling CLI access for {ProductName}

.Procedure

. Follow link:https://docs.nginx.com/nginx-management-suite/admin-guides/authentication/oidc/oidc-keycloak/[these instructions] to set up Keycloak as an OpenID Connect (OIDC) identity provider. Be aware that, when installing {ProductName}, you already set up a Keycloak server and created a realm called `redhat-external`.
. In your preferred text editor, use the `kubeconfig` template below to create a template specific to your organization. Be sure to provide the following values, specific to your organization, for the corresponding fields in the template file:
.. The API URL for your cluster, for example: `https://api-toolchain-host-operator.apps.stone-prd-host1.wdlc.p1.openshiftapps.com`
.. Your OIDC issuer URL, for example: `https://sso.redhat.com/auth/realms/redhat-external`
.. Your OIDC client ID, for example: `rhoas-cli-prod`
+
[source]
--
apiVersion: v1
clusters:
- cluster:
server: <1>
name: konflux
contexts:
- context:
cluster: konflux
namespace: <username>-tenant
user: oidc
name: konflux
current-context: konflux
kind: Config
preferences: {}
users:
- name: oidc
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
args:
- oidc-login
- get-token
- --oidc-issuer-url= <2>
- --oidc-client-id= <3>
command: kubectl
env: null
interactiveMode: IfAvailable
provideClusterInfo: false
--
. Make this template `kubeconfig`, now specific to your organization, available to users of your {ProductName} instance.

== Accessing {ProductName} through the CLI

.Prerequisites

* Install link:https://kubernetes.io/docs/tasks/tools/[`kubectl`]
* Install link:https://github.com/int128/kubelogin[`kubelogin`]

.Procedure

. Get the template `kubeconfig` file for your organization's instance of {ProductName}. A PE should be able to provide you with this.
. Using your preferred text editor, in your copy of the template `kubeconfig`, replace <username> with your {ProductName} username.
. Use one of these two methods for making your `kubeconfig` file accessible to the `kubectl` CLI tool:
.. In your CLI, run the following command:
+
[source]
--
export $KUBECONFIG=<path to your kubeconfig file>
--
+
.. Or, overwrite the file located at `~/.kube/config` with your `kubeconfig` file.
. Verify your available contexts by running the following command in your CLI. You should see the `konflux` context.
+
`kubectl config get-contexts`
. Still in your CLI, set `konflux` as the default context:
+
`kubectl config set-context konflux`
. Trigger a round trip from your machine to the cluster and back, to verify the connection:
+
`kubectl get cm`
Loading