# Local Kubectl Setup

`kubectl` is the command-line tool used to interact with Kubernetes clusters. It allows you to deploy applications, inspect and manage cluster resources, and troubleshoot issues directly from your terminal. This setup guide will walk you through installing `kubectl` on your computer, downloading the `kubeconfig` file, and configuring `kubectl` for your environment.

## Installing `kubectl`

Install `kubectl` on your local computer:

1. Use these [tools ](https://kubernetes.io/docs/tasks/tools/)to install `kubectl` locally.
2. Run these commands to enable `kubectl` to use the downloaded `kubeconfig`.

### **For Linux or macOS**

```shell
export KUBECONFIG=/home/duplo/duploinfra-INFRASTRUCTURE_NAME.yaml # INFRASTRUCTURE_NAME is your DuploCloud Infrastructure name.
```

### **For Windows**

```powershell
setx KUBECONFIG "%USERPROFILE%\Downloads\duploinfra-INFRASTRUCTURE_NAME.yaml" # INFRASTRU
```

## Downloading `kubeconfig`

The `kubeconfig` file is a configuration file used by `kubectl` to connect to a Kubernetes cluster. It contains essential information such as the cluster's API server address, authentication credentials, and context settings that define which cluster and namespace `kubectl` should interact with. Refer to [this article](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/) for more information about `kubeconfig`. Download `kubeconfig` one of two ways: using `duploctl` or from within the DuploCloud Portal:&#x20;

### Downloading `kubeconfig` using `duploctl`

To download `kubeconfig` using `duploctl`, follow [these instructions](https://cli.duplocloud.com/Jit/#duplo_resource.jit.DuploJit.update_kubeconfig).&#x20;

### Downloading `kubeconfig` from the DuploCloud Portal

1. In the DuploCloud Portal, navigate to **Administrators** -> **Infrastructure.**
2. In the **NAME** column, select the Infrastructure where you want to set up `kubectl`.&#x20;
3. Click the **EKS** (for AWS), **GKE** (for GCP), or the **AKS** (for Azure) tab. The **Download Kubeconfig For Plan** pane displays.
4. Click **Download Kubeconfig** to download the `kubeconfig` file.

<figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2Fgjm1eqK3Hp4KpbSHed9q%2FScreenshot%20(232).png?alt=media&#x26;token=29162d88-83ad-423a-a4df-1eb425532569" alt=""><figcaption></figcaption></figure>

<div align="left"><figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2Fmbr7xKt3kH6efPMBdxID%2Fpic%202.png?alt=media&#x26;token=ae1a3cbe-52cf-4938-baa8-652907e7a979" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
If you don't have Administrator access, you can use `duplo-jit` to access Kubernetes. When you click **Download kubeconfig**, the **Access to Kubernetes from your Workstation** window gives you the option to install [`duplo-jit`](https://docs.duplocloud.com/docs/automation-platform/overview/use-cases/jit-access) to access your Kubernetes cluster without obtaining permanent access keys.
{% endhint %}
