Skip to content

Commit

Permalink
Merge pull request #1376 from run-ai/Add-kubeconfig
Browse files Browse the repository at this point in the history
Add kubeconfig
  • Loading branch information
SherinDaher-Runai authored Jan 20, 2025
2 parents c75cd7b + 15a2dba commit be46dd2
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Add Run:ai authorization to kubeconfig

The ***runai kubeconfig set*** command allows users to configure their kubeconfig file with Run:ai authorization token. This setup enables users to gain access to the Kubernetes (k8s) cluster seamlessly.


!!! Note
Setting kubeconfig is not required in order to use the CLI. This command is used to enable third-party workloads under Run:ai authorization.

## Usage

To set the token (will be fetched automatically) inside the kubeconfig file, run the following command:

```
runai kubeconfig set
```


## Prerequisites

Before executing the command, ensure that

1. Cluster authentication is configured and enabled.
2. The user has a kubeconfig file configured.
3. The user is logged in (use the [runai login](../runai_login.md) command).


### Cluster configuration

To enable cluster authentication, add the following flags to the Kubernetes server API of each cluster:

```
spec:
containers:
- command:
...
- --oidc-client-id=<OIDC_CLIENT_ID>
- --oidc-issuer-url=url=https://<HOST>/auth/realms/<REALM>
- --oidc-username-prefix=-
```

### User Kubeconfig configuration

Add the following to the Kubernetes client configuration file (./kube/config). For the full command reference, see [kubeconfig set](../runai_kubeconfig_set.md).

* Make sure to replace values with the actual cluster information and user credentials.
* There can be multiple contexts in the kubeconfig file. The command will configure the current context.


```
apiVersion: v1
kind: Config
preferences:
colors: true
current-context: <CONTEXT_NAME>
contexts:
- context:
cluster: <CLUSTER_NAME>
user: <USER_NAME>
name: <CONTEXT_NAME>
clusters:
- cluster:
server: <CLUSTER_URL>
certificate-authority-data: <CLUSTER_CERT>
name: <CLUSTER_NAME>
users:
- name: <USER_NAME>
```

1 change: 1 addition & 0 deletions docs/Researcher/cli-reference/new-cli/runai.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ runai [flags]
* [runai attach](runai_attach.md) - [Deprecated] attach
* [runai cluster](runai_cluster.md) - cluster management
* [runai config](runai_config.md) - configuration management
* [runai kubeconfig](runai_kubeconfig.md) - kubeconfig management
* [runai describe](runai_describe.md) - [Deprecated] Display detailed information about resources
* [runai exec](runai_exec.md) - [Deprecated] exec
* [runai list](runai_list.md) - [Deprecated] display resource list. By default displays the job list
Expand Down
24 changes: 24 additions & 0 deletions docs/Researcher/cli-reference/new-cli/runai_kubeconfig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## runai kubeconfig

kubeconfig management

### Options

```
-h, --help help for kubeconfig
```

### Options inherited from parent commands

```
--config-file string config file name; can be set by environment variable RUNAI_CLI_CONFIG_FILE (default "config.json")
--config-path string config path; can be set by environment variable RUNAI_CLI_CONFIG_PATH
-d, --debug enable debug mode
-q, --quiet enable quiet mode, suppress all output except error messages
--verbose enable verbose mode
```

### SEE ALSO

* [runai](runai.md) - Run:ai Command-line Interface
* [runai kubeconfig set](runai_kubeconfig_set.md) - kubeconfig set login token
27 changes: 27 additions & 0 deletions docs/Researcher/cli-reference/new-cli/runai_kubeconfig_set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## runai kubeconfig set

kubeconfig set login token

```
runai kubeconfig set [flags]
```

### Options

```
-h, --help help for set
```

### Options inherited from parent commands

```
--config-file string config file name; can be set by environment variable RUNAI_CLI_CONFIG_FILE (default "config.json")
--config-path string config path; can be set by environment variable RUNAI_CLI_CONFIG_PATH
-d, --debug enable debug mode
-q, --quiet enable quiet mode, suppress all output except error messages
--verbose enable verbose mode
```

### SEE ALSO

* [runai kubeconfig](runai_kubeconfig.md) - kubeconfig management
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ nav:
- 'Overview': 'Researcher/cli-reference/new-cli/overview.md'
- 'CLI Reference': 'Researcher/cli-reference/new-cli/runai.md'
- 'CLI Examples': 'Researcher/cli-reference/new-cli/cli-examples.md'
- 'CLI Guides' :
- 'Set cluster authorization': 'Researcher/cli-reference/new-cli/guides/set-kubeconfig-with-oidc-parameters.md'

- 'CLI V1':
- 'Introduction' : 'Researcher/cli-reference/Introduction.md'
- 'runai attach' : 'Researcher/cli-reference/runai-attach.md'
Expand Down

0 comments on commit be46dd2

Please sign in to comment.