> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gcore.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Install kubectl and connect to a Kubernetes cluster

kubectl is the standard command-line client for Kubernetes. It communicates with the Kubernetes API server to create, update, and manage cluster resources. For a complete list of commands, see the [kubectl official documentation](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands).

The procedures below cover installing kubectl, downloading the cluster kubeconfig from the Customer Portal, and verifying the connection. For a graphical alternative, [Lens](https://k8slens.dev) provides a desktop interface for managing clusters without the command line.

## Install kubectl and connect from Windows

1\. Download kubectl for Windows. The example below downloads v1.36.0. For the latest version, find the updated command in the [Kubernetes official documentation](https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/#install-kubectl-binary-with-curl-on-windows):

```sh theme={null}
curl.exe -LO https://dl.k8s.io/release/v1.36.0/bin/windows/amd64/kubectl.exe
```

2\. Add the directory containing **kubectl.exe** to the **PATH** environment variable so the system can find it. First, copy the download path from the command line:

<Frame>
  <img src="https://mintcdn.com/gcore/yxYVl3HpxFEvUXPS/images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/image_28.png?fit=max&auto=format&n=yxYVl3HpxFEvUXPS&q=85&s=c1a108cb84348da602e15d66da2d1107" alt="Windows command line showing the kubectl.exe download path to copy" width="1081" height="54" data-path="images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/image_28.png" />
</Frame>

Then navigate to **Windows settings** > **System** > **About** > **Advanced system settings** (or right-click **This PC** and select **Properties** > **Advanced system settings**):

<Frame>
  <img src="https://mintcdn.com/gcore/yxYVl3HpxFEvUXPS/images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/image_61.png?fit=max&auto=format&n=yxYVl3HpxFEvUXPS&q=85&s=001dd7eee20b6e71d0b23be83c967760" alt="Windows System Properties dialog showing Advanced system settings link" width="546" height="570" data-path="images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/image_61.png" />
</Frame>

In the dialog, click **Environment Variables**, double-click the **Path** system variable, paste the kubectl.exe path into the bottom empty field, and save the changes:

<Frame>
  <img src="https://mintcdn.com/gcore/yxYVl3HpxFEvUXPS/images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/image_62.png?fit=max&auto=format&n=yxYVl3HpxFEvUXPS&q=85&s=0ae83acffb375bd419cd32cecd3ea20d" alt="Windows Environment Variables dialog with kubectl path added to the Path system variable" width="883" height="767" data-path="images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/image_62.png" />
</Frame>

With kubectl available in the system PATH, the next steps configure cluster access.

3\. Create the `.kube` directory in `C:\Users\[username]` to store the cluster configuration file:

<Frame>
  <img src="https://mintcdn.com/gcore/yxYVl3HpxFEvUXPS/images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/image_46.png?fit=max&auto=format&n=yxYVl3HpxFEvUXPS&q=85&s=51e107459e024d11c86411d4cd109ddf" alt="Windows File Explorer showing the .kube directory created in the user home folder" width="739" height="190" data-path="images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/image_46.png" />
</Frame>

4\. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **Cloud** > **Managed Kubernetes**, click the cluster name, then click **Kubernetes config** to download the configuration file:

<Frame>
  <img src="https://mintcdn.com/gcore/-tGG7PWTFMtYIhJ9/images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/kubectl-download-config.png?fit=max&auto=format&n=-tGG7PWTFMtYIhJ9&q=85&s=850b936b5944c86225a6ed95e5a6c478" alt="Kubernetes cluster overview page with the Kubernetes config button in the top right of the cluster card" width="905" height="384" data-path="images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/kubectl-download-config.png" />
</Frame>

5\. Rename the downloaded file to `config` (no extension) and place it in the `.kube` folder. kubectl can now access it:

<Frame>
  <img src="https://mintcdn.com/gcore/yxYVl3HpxFEvUXPS/images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/image_45.png?fit=max&auto=format&n=yxYVl3HpxFEvUXPS&q=85&s=f645e569070cf40349908237cf43df42" alt="Windows File Explorer showing the kubeconfig file renamed to config and placed in the .kube folder" width="739" height="144" data-path="images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/image_45.png" />
</Frame>

6\. Verify kubectl can reach the cluster:

```sh theme={null}
kubectl get pods
```

Either result — `No resources found in default namespace` or a list of running pods — confirms kubectl is correctly configured.

## Install kubectl and connect from Ubuntu or Linux

1\. Download the latest stable kubectl binary:

```sh theme={null}
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
```

2\. Make the kubectl binary executable:

```sh theme={null}
chmod +x ./kubectl
```

3\. Move the binary to a directory in the **PATH** variable:

```sh theme={null}
sudo mv ./kubectl /usr/local/bin/kubectl
```

With kubectl installed, the next steps configure cluster access.

4\. Create the `.kube` directory in the home directory:

```sh theme={null}
mkdir ~/.kube
```

5\. In the Customer Portal, navigate to **Cloud** > **Managed Kubernetes**, click the cluster name, then click **Kubernetes config** to download the configuration file:

<Frame>
  <img src="https://mintcdn.com/gcore/-tGG7PWTFMtYIhJ9/images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/kubectl-download-config.png?fit=max&auto=format&n=-tGG7PWTFMtYIhJ9&q=85&s=850b936b5944c86225a6ed95e5a6c478" alt="Kubernetes cluster overview page with the Kubernetes config button in the top right of the cluster card" width="905" height="384" data-path="images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/kubectl-download-config.png" />
</Frame>

6\. Rename the downloaded file to `config` (no extension) and place it in the `.kube` folder:

<Frame>
  <img src="https://mintcdn.com/gcore/yxYVl3HpxFEvUXPS/images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/image_47.png?fit=max&auto=format&n=yxYVl3HpxFEvUXPS&q=85&s=670a86f82e32f0b8e52b3db6b5654d88" alt="Linux file manager showing the kubeconfig file renamed to config and placed in the .kube folder" width="789" height="485" data-path="images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/image_47.png" />
</Frame>

7\. Confirm cluster access:

```sh theme={null}
kubectl get pods
```

Successful output confirms that kubectl can communicate with the cluster.

## Install kubectl and connect from macOS

1\. Download the latest stable kubectl binary. For Intel Macs, use `amd64`; for Apple Silicon (M1/M2/M3), use `arm64`:

```sh theme={null}
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl"
```

2\. Make the binary executable:

```sh theme={null}
chmod +x ./kubectl
```

3\. Move the binary to a directory in the **PATH** variable. Check which directories are in PATH:

```sh theme={null}
echo $PATH
```

Select a directory from the output and move kubectl there. For example:

```sh theme={null}
sudo mv ./kubectl /usr/local/bin/kubectl
```

With kubectl installed, the next steps configure cluster access.

4\. Create the `.kube` directory in the home directory:

```sh theme={null}
mkdir ~/.kube
```

5\. In the Customer Portal, navigate to **Cloud** > **Managed Kubernetes**, click the cluster name, then click **Kubernetes config** to download the configuration file:

<Frame>
  <img src="https://mintcdn.com/gcore/-tGG7PWTFMtYIhJ9/images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/kubectl-download-config.png?fit=max&auto=format&n=-tGG7PWTFMtYIhJ9&q=85&s=850b936b5944c86225a6ed95e5a6c478" alt="Kubernetes cluster overview page with the Kubernetes config button in the top right of the cluster card" width="905" height="384" data-path="images/docs/cloud/kubernetes/clusters/connect/install-kubectl-and-connect-to-a-kubernetes-cluster/kubectl-download-config.png" />
</Frame>

6\. Rename the downloaded file to `config` (no extension) and place it in the `.kube` folder.

7\. Test the connection:

```sh theme={null}
kubectl get pods
```

If the command returns pod information or reports that no resources exist, the connection is working correctly.

## Renewal of kubectl certificates

Gcore renews kubectl access certificates every two years. Notifications are sent before the renewal date:

* **In the Customer Portal**: a notification appears with the expiry date and a reminder to download the new kubeconfig from the cluster page.
* **Via email**: two weeks before the renewal date, an email is sent with the renewal date. After the certificate is updated, a confirmation email is sent with a reminder to download the new certificate.
