---
title: "Configuring kubectl on an OVHcloud Managed Kubernetes cluster"
description: "The OVHcloud Managed Kubernetes service provides you with access to Kubernetes clusters, without the hassle of installing or operating them."
url: https://docs.us.ovhcloud.com/en/public-cloud/managed-kubernetes/configure-kubectl
lang: en
---
> For AI agents: the complete documentation index is available at https://docs.us.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.us.ovhcloud.com/en/llms-full.txt.

# Configuring kubectl on an OVHcloud Managed Kubernetes cluster

The OVHcloud Managed Kubernetes service provides you with access to Kubernetes clusters, without the hassle of installing or operating them.

 

## Requirements

- You must have an OVHcloud Managed Kubernetes cluster.
- You must have the [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) command-line tool installed.

You can find the detailed installation instructions for `kubectl` in Kubernetes’ [official documentation](https://kubernetes.io/docs/tasks/tools/).

 

## Instructions

### Step 1 - Configure the default settings for kubectl

Log in to the [OVHcloud Control Panel](https://manager.us.ovhcloud.com/), go to the `Public Cloud` section, and select the Public Cloud project concerned.

Click `Managed Kubernetes Service` in the left-hand menu. Then, click on your **Cluster's name**.

Then, click on `Download kubeconfig` to download the `kubectl` configuration file:

_How are kubeconfig files loaded?_

- From the `--kubeconfig` flag, is specified
- From the `KUBECONFIG` environment variable, if set
- From the `$HOME/.kube/config` file, by default

If you want to use this configuration file by default in `kubectl`, you can save it with the filename `config` in the `$HOME/.kube/` directory. Alternatively, you can place it in your working directory, with either the `KUBECONFIG` environment variable or the `--kubeconfig` flag.

In this example, we are using the `KUBECONFIG` environment variable method.

 

#### For MacOS or Linux:

Type the following command into your terminal:

```
export KUBECONFIG=/Users/myuser/.kube/example-cluster.yml
```

 

#### For Windows 7, 10, and 11:

1. From the Windows menu or Cortana search bar, search for "Modify system environment variables".
2. In the System Properties window, click on the _Advanced_ tab, then click the _Environment Variables_ button near the bottom.
3. In the window that opens (pictured below), add a new variable, `KUBECONFIG`, with the path to the `kube-config` file as its value.

You can also add the variable for the current shell process with this command :

```
set KUBECONFIG=example-cluster.yml
```

 

### Step 2 - Verify that _kubectl_ can connect to the cluster

You can verify that `kubectl` can interact with the cluster by using it to send a `cluster-info` command:

```
kubectl cluster-info
```

The cluster should return a response with some key information about itself:

```
kubectl cluster-info
Kubernetes control plane is running at https://xxxxxx.c1.va1.k8s.ovh.us
CoreDNS is running at https://xxxxxx.c1.va1.k8s.ovh.us/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://xxxxxx.c1.va1.k8s.ovh.us/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
```

 

### Define the access for several Kubernetes clusters

You can also specify several kubeconfig files in your `KUBECONFIG` environment variable, separated by a colon (`:`).

```
export KUBECONFIG=/Users/myuser/.kube/example-cluster.yml:/Users/myuser/.kube/example-cluster2.yml
```

 

### Switch to a different cluster

You can switch between different clusters by using the `kubectl config` command.

```
kubectl config use-context kubernetes-admin@example-cluster
Switched to context "kubernetes-admin@example-cluster".

$ kubectl config use-context kubernetes-admin@example-cluster2
Switched to context "kubernetes-admin@example-cluster2".
```

Or you can install and use [kubectx](https://github.com/ahmetb/kubectx).

 

## Go further

To deploy your first application on your Kubernetes cluster, we suggest you refer to our guide on [Deploying an application](https://docs.us.ovhcloud.com/en/public-cloud/managed-kubernetes/deploy-hello-world.md).

Browse all the [Managed Kubernetes Service (MKS) guides](https://docs.us.ovhcloud.com/en/public-cloud/managed-kubernetes/landing-page-managed-kubernetes.md).

Browse the rest of the [OVHcloud US documentation](https://docs.us.ovhcloud.com/en/index.md) for guides on our other products and services.

Learn more about [Managed Kubernetes](https://us.ovhcloud.com/public-cloud/kubernetes/) on the OVHcloud US website.
