Skip to content

Commit

Permalink
refactor: simplify kubectl connection
Browse files Browse the repository at this point in the history
  • Loading branch information
deimosfr committed Nov 1, 2024
1 parent 8275b43 commit ba10ce4
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 13 deletions.
9 changes: 8 additions & 1 deletion website/docs/using-qovery/interface/cli.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
last_modified_on: "2024-09-04"
last_modified_on: "2024-11-01"
title: CLI
description: How to use the Qovery CLI (Command Line Interface)
---
Expand Down Expand Up @@ -643,6 +643,13 @@ export KUBECONFIG=<path_to_kubeconfig_file>

3. You can now use tools like `k9s` or `kubectl` to access and manage your cluster:


<Alert type="info">

Some cloud providers like GCP or AWS require additional configuration to access the cluster. Make sure you have CLI binaries installed (gcloud CLI/AWS CLI/...), and the right permissions and credentials set up (environment variables or profile file).

</Alert>

**Using k9s**

Launch the k9s terminal UI to interact with your Kubernetes cluster:
Expand Down
7 changes: 7 additions & 0 deletions website/docs/using-qovery/interface/cli.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,13 @@ export KUBECONFIG=<path_to_kubeconfig_file>

3. You can now use tools like `k9s` or `kubectl` to access and manage your cluster:


<Alert type="info">

Some cloud providers like GCP or AWS require additional configuration to access the cluster. Make sure you have CLI binaries installed (gcloud CLI/AWS CLI/...), and the right permissions and credentials set up (environment variables or profile file).

</Alert>

**Using k9s**

Launch the k9s terminal UI to interact with your Kubernetes cluster:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
last_modified_on: "2024-01-05"
last_modified_on: "2024-11-01"
$schema: "/.meta/.schemas/guides.json"
title: How to connect to your EKS cluster with kubectl
description: How to connect to your EKS cluster using kubectl
Expand Down Expand Up @@ -57,13 +57,20 @@ To interact with your cluster, you will need `kubectl` installed.
The AWS CLI must be installed and configured on your machine.
[https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html)

**Qovery CLI**

The Qovery CLI is required to get the kubeconfig file of your cluster:
[https://hub.qovery.com/docs/using-qovery/interface/cli/](https://hub.qovery.com/docs/using-qovery/interface/cli/)

</li>

<li>

#### Add your IAM user to the Admin group
#### IAM user permissions

Since `kubectl` will use IAM to authenticate, you need to add your IAM user (the one the AWS CLI is authenticated with) to the `Admins` group you created when setting up Qovery.
Since `kubectl` will use IAM to authenticate, you need to have one of those things:
1. Add your IAM user (the one the AWS CLI is authenticated with) to the `Admins` group you created when setting up Qovery
2. Have the permissions to access the EKS cluster via SSO ([see cluster advanced settings for it](/docs/using-qovery/configuration/cluster-advanced-settings/#awsiamenable_sso))

<p align="center">
<img src="/img/how-to-connect-to-your-eks-cluster-with-kubectl/1.png" alt="AWS console - add admin user" />
Expand All @@ -74,12 +81,31 @@ Since `kubectl` will use IAM to authenticate, you need to add your IAM user (the

#### Download the Kubeconfig file

To connect to your EKS cluster you will need to set a context to `kubectl`. This is done with a `Kubeconfig` file.
To get the kubeconfig file of your cluster, run the following command to list your clusters and get the desired cluster ID:

```bash
$ qovery cluster list
Id | Name | Type | Status | Last Update
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | Qovery Prod | cluster | DEPLOYED | 2024-10-11 07:40:33.562523 +0000 UTC
```

When installing a new cluster, Qovery stores it in an S3 bucket on your account. You can retrieve the Kubeconfig of your cluster directly from the Qovery interface by following the procedure "Get your cluster kubeconfig file" [within this section][docs.using-qovery.configuration.clusters#performing-actions-on-your-clusters].
Then run the following command to get the kubeconfig file (replace with your cluster ID):

</li>
```bash
$ qovery cluster kubeconfig --cluster-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
INFO[2024-11-01T11:42:49+01:00] Kubeconfig file created in the current directory.
INFO[2024-11-01T11:42:49+01:00] Execute `export KUBECONFIG=/Users/user/kubeconfig-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.yaml` to use it.
```

The path of your kubeconfig file will be displayed in the output. You can now use it to set the context for `kubectl`.

<Alert type="warning">

On AWS you'll need to have the `AWS_PROFILE` environment variable set to the right profile to be able to download the kubeconfig file or AWS credentials set as environment variables.

</Alert>

</li>

<li>

Expand Down Expand Up @@ -217,4 +243,4 @@ Qovery helps you manage your Kubernetes cluster and deploy your applications on
</Alert>


[docs.using-qovery.configuration.clusters#performing-actions-on-your-clusters]: /docs/using-qovery/configuration/clusters/#performing-actions-on-your-clusters

Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,20 @@ To interact with your cluster, you will need `kubectl` installed.
The AWS CLI must be installed and configured on your machine.
[https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html)

**Qovery CLI**

The Qovery CLI is required to get the kubeconfig file of your cluster:
[https://hub.qovery.com/docs/using-qovery/interface/cli/](https://hub.qovery.com/docs/using-qovery/interface/cli/)

</li>

<li>

#### Add your IAM user to the Admin group
#### IAM user permissions

Since `kubectl` will use IAM to authenticate, you need to add your IAM user (the one the AWS CLI is authenticated with) to the `Admins` group you created when setting up Qovery.
Since `kubectl` will use IAM to authenticate, you need to have one of those things:
1. Add your IAM user (the one the AWS CLI is authenticated with) to the `Admins` group you created when setting up Qovery
2. Have the permissions to access the EKS cluster via SSO ([see cluster advanced settings for it](/docs/using-qovery/configuration/cluster-advanced-settings/#awsiamenable_sso))

<p align="center">
<img src="/img/how-to-connect-to-your-eks-cluster-with-kubectl/1.png" alt="AWS console - add admin user" />
Expand All @@ -62,12 +69,31 @@ Since `kubectl` will use IAM to authenticate, you need to add your IAM user (the

#### Download the Kubeconfig file

To connect to your EKS cluster you will need to set a context to `kubectl`. This is done with a `Kubeconfig` file.
To get the kubeconfig file of your cluster, run the following command to list your clusters and get the desired cluster ID:

```bash
$ qovery cluster list
Id | Name | Type | Status | Last Update
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | Qovery Prod | cluster | DEPLOYED | 2024-10-11 07:40:33.562523 +0000 UTC
```

When installing a new cluster, Qovery stores it in an S3 bucket on your account. You can retrieve the Kubeconfig of your cluster directly from the Qovery interface by following the procedure "Get your cluster kubeconfig file" [within this section][docs.using-qovery.configuration.clusters#performing-actions-on-your-clusters].
Then run the following command to get the kubeconfig file (replace with your cluster ID):

</li>
```bash
$ qovery cluster kubeconfig --cluster-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
INFO[2024-11-01T11:42:49+01:00] Kubeconfig file created in the current directory.
INFO[2024-11-01T11:42:49+01:00] Execute `export KUBECONFIG=/Users/user/kubeconfig-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.yaml` to use it.
```

The path of your kubeconfig file will be displayed in the output. You can now use it to set the context for `kubectl`.

<Alert type="warning">

On AWS you'll need to have the `AWS_PROFILE` environment variable set to the right profile to be able to download the kubeconfig file or AWS credentials set as environment variables.

</Alert>

</li>

<li>

Expand Down

0 comments on commit ba10ce4

Please sign in to comment.