-
Notifications
You must be signed in to change notification settings - Fork 258
feat(k8s): update kubectl #4224
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
Closed
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
aa25fac
feat(k8s): update kubectl
bene2k1 985182f
Apply suggestions from code review
bene2k1 e908682
feat(k8s): update docs kubectl
bene2k1 fc237a6
feat(k8s): update doc
bene2k1 ee6cf74
feat(k8s): update quickstart
bene2k1 246ba77
fix(k8): small fix
bene2k1 a784c83
feat(k8s): update doc
bene2k1 5d2157f
Apply suggestions from code review
bene2k1 1bb088d
feat(k8s): add link to iam docs
bene2k1 bd8d83f
feat(iam): auto-generated iam resources MTA-5431 (#4231)
ldecarvalho-doc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,79 @@ | ||
| --- | ||
| meta: | ||
| title: How to connect to a cluster with kubectl | ||
| title: How to connect to a Kubernetes Kapsule cluster with kubectl | ||
| description: Learn how to connect to a Kubernetes cluster using kubectl. Follow steps to manage cluster resources, deploy applications, and view logs easily from your local computer. | ||
| content: | ||
| h1: How to connect to a cluster with kubectl | ||
| paragraph: This page explains how to connect to a Kubernetes cluster via kubectl | ||
| h1: How to connect to a Kubernetes Kapsule cluster with kubectl | ||
| paragraph: This guide details the steps to connect to a Kubernetes cluster using kubectl, the Kubernetes command-line tool. | ||
| tags: connection cluster kubectl | ||
| dates: | ||
| validation: 2024-11-18 | ||
| validation: 2025-01-15 | ||
| posted: 2020-09-20 | ||
| categories: | ||
| - kubernetes | ||
| --- | ||
|
|
||
| Once your [cluster is created](/containers/kubernetes/how-to/create-cluster/), a `.kubeconfig` file is available for download to manage several Kubernetes clusters. You can use this with `kubectl`, the Kubernetes command line tool, allowing you to run commands against your Kubernetes clusters. You can use `kubectl` from a terminal on your local computer to deploy applications, inspect and manage cluster resources, and view logs. | ||
| Once your [cluster is created](/containers/kubernetes/how-to/create-cluster/), you can install a `kubeconfig` file unsing Scaleway's command-line tool on your local machine to manage your Kubernetes cluster. | ||
|
|
||
| You can use this with `kubectl`, the Kubernetes command-line tool, allowing you to run commands against your Kubernetes cluster. This enables you to deploy applications, inspect and manage cluster resources, and view logs directly from your local machine. | ||
|
|
||
| <Macro id="requirements" /> | ||
|
|
||
| - A Scaleway account logged into the [console](https://console.scaleway.com) | ||
| - [Owner](/identity-and-access-management/iam/concepts/#owner) status or [IAM permissions](/identity-and-access-management/iam/concepts/#permission) allowing you to perform actions in the intended Organization | ||
| - Created a [Kubernetes Kapsule cluster](/containers/kubernetes/how-to/create-cluster/) | ||
| - A [Scaleway account](https://console.scaleway.com) logged into the console. | ||
| - [Owner status](https://console.scaleway.com) or [IAM permissions](/identity-and-access-management/iam/concepts/#permission) to perform actions in the intended Organization. | ||
| - A [Kubernetes Kapsule cluster](/containers/kubernetes/how-to/create-cluster/) created. | ||
bene2k1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - [kubectl](https://kubernetes.io/docs/tasks/tools/) installed locally. | ||
| - The [Scaleway CLI](/developer-tools/scaleway-cli/quickstart/) installed locally. | ||
|
|
||
| ## Setting fine-grained permissions (IAM Policies) for Kubernetes access | ||
|
|
||
| If your Organization uses IAM to control access, ensure that you or your group/application has the following permission sets assigned at the Project scope: | ||
|
|
||
| - `KubernetesFullAccess` (or `KubernetesReadOnly`, depending on your needs): | ||
| Grants you the ability to manage (or list/read) Kubernetes clusters, nodes, and related actions in your Scaleway Project. | ||
|
|
||
| To create a new policy with the correct permission sets, follow these steps: | ||
|
|
||
| ### Key elements of IAM Policy configuration | ||
bene2k1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 1. **Create a new policy**: Navigate to the **Policies** tab in your Organization’s IAM console and create a new policy. | ||
| 2. **Add your user (or group/application)**: Assign your user, group, or application as the **Principal**. | ||
| 3. **Add an IAM rule**: | ||
| - **Scope**: Set to **Access to resources** and specify the desired Project(s). | ||
| - **Permission Sets**: Include the following as needed: | ||
| - `KubernetesFullAccess` for full cluster management. | ||
| - `KubernetesReadOnly` for read-only access. | ||
| 4. Click **Validate** and then **Create Policy**. | ||
|
|
||
| Refer to our [policy and permission sets documentation](/identity-and-access-management/iam/reference-content/permission-sets/) for more details. | ||
|
|
||
| ## Accessing the cluster | ||
|
|
||
| You can use the Scaleway CLI to retrieve (and merge) your `kubeconfig` file automatically, then interact with your Kubernetes cluster. | ||
bene2k1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 1. [Install kubectl](https://kubernetes.io/docs/tasks/tools/) on your local computer. | ||
| 2. Download the `.kubeconfig` files from your cluster's **overview** page: | ||
| <Lightbox src="scaleway-kapsule_kubeconfig.webp" alt="" /> | ||
| 3. Configure access to your cluster. You can do this in one of two ways: | ||
| ### Install and configure the Scaleway CLI | ||
|
|
||
| Set the `KUBECONFIG` environment variable: | ||
| ``` | ||
| export KUBECONFIG=/$HOME/Downloads/Kubeconfig-ClusterName.yaml | ||
| ``` | ||
| If you have not set up the Scaleway CLI yet: | ||
|
|
||
| Or use `use $HOME/.kube/config file`: | ||
| ``` | ||
| mv $HOME/Downloads/Kubeconfig-ClusterName.yaml $HOME/.kube/config | ||
| ``` | ||
| 1. Follow our [installation guide](/developer-tools/scaleway-cli/quickstart) for platform-specific instructions using Homebrew, Chocolatey, or manual methods. | ||
| 2. Run the following command and follow the prompts to set up your CLI with your Scaleway API keys: | ||
| ```bash | ||
| scw init | ||
| ``` | ||
| You will need your [API Key](https://identity-and-access-management/iam/how-to/#creating-API-keys) (Access Key & Secret Key). | ||
bene2k1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Either way, make sure you replace `/$HOME/Downloads/Kubeconfig-ClusterName.yaml` with the correct name and path of your downloaded `.kubeconfig` file. | ||
| 4. Run the following command to finish: | ||
| ``` | ||
| kubectl get nodes | ||
| ``` | ||
| ### Retrieve and install the kubeconfig using `scw` | ||
|
|
||
| 1. Run the following command to install the kubeconfig file for your cluster: | ||
| ```bash | ||
| scw k8s kubeconfig install <cluster-id> | ||
| ``` | ||
| This command will: | ||
| - Download the `kubeconfig` for the specified cluster. | ||
| - Merge it into your existing kubeconfig file (default location: `~/.kube/config`). | ||
|
|
||
| 2. Verify the installation: | ||
| ```bash | ||
| kubectl get nodes | ||
| ``` | ||
| A list of nodes from your Kapsule cluster should appear. If not, review the troubleshooting section. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.