# 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:

### Downloading `kubeconfig` using `duploctl`

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

### 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`.
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="/files/YoWBBAc2JkezzRki5Ad4" alt=""><figcaption></figcaption></figure>

<div align="left"><figure><img src="/files/orY7Vjzi1tlia6bZauY2" 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`](/docs/automation-platform/overview/use-cases/jit-access.md) to access your Kubernetes cluster without obtaining permanent access keys.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.duplocloud.com/docs/automation-platform/kubernetes-overview/kubectl/kubectl-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
