Configuring kubectl on an OVHcloud Managed Kubernetes cluster
Find out how to retrieve the `kubectl` configuration file to interact with an OVHcloud Managed Kubernetes cluster.
Find out how to retrieve the `kubectl` configuration file to interact with an OVHcloud Managed Kubernetes cluster.
Last updated 27th April, 2022.
The OVHcloud Managed Kubernetes service gives you access to Kubernetes clusters, without the hassle of installing or operating them.
This guide will cover how to retrieve the kubectl
configuration file to interact with an OVHcloud Managed Kubernetes cluster.
kubectl
command-line tool installed.You can find the detailed installation instructions for kubectl
in Kubernetes' official documentation.
Log in to the OVHcloud Control Panel, go to the Public Cloud
section and select the Public Cloud project concerned.
Access the administration UI for your OVHcloud Managed Kubernetes clusters by clicking on Managed Kubernetes Service
in the left-hand menu.
Then, click on one of your Kubernetes cluster in the tab.
Then, click on kubeconfig
to download the kubectl
configuration file:
How kubeconfig files are loaded?
--kubeconfig
flag, is specifiedKUBECONFIG
environment variable, if set$HOME/.kube/config
file, by defaultSo, after downloading it, 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.
Type the following command into your terminal:
export KUBECONFIG=/Users/myuser/.kube/my-test-cluster.yml
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=my-test-cluster.yml
You can verify that kubectl
is able to 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.c2.gra.k8s.ovh.net
CoreDNS is running at https://xxxxxx.c2.gra.k8s.ovh.net/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://xxxxxx.c2.gra.k8s.ovh.net/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
You can also specify several kubeconfig files in your KUBECONFIG
environment variable, separated by a colon (:
).
export KUBECONFIG=/Users/myuser/.kube/my-test-cluster.yml:/Users/myuser/.kube/my-test-cluster2.yml
You can switch between different clusters by using the kubectl config
command.
$ kubectl config use-context kubernetes-admin@my-test-cluster
Switched to context "kubernetes-admin@my-test-cluster".
$ kubectl config use-context kubernetes-admin@my-test-cluster2
Switched to context "kubernetes-admin@my-test-cluster2".
Or you can install and use kubectx.
To deploy your first application on your Kubernetes cluster, we suggest you refer to our guide to Deploying an application.
Join our community of users.
Please feel free to give any suggestions in order to improve this documentation.
Whether your feedback is about images, content, or structure, please share it, so that we can improve it together.
Your support requests will not be processed via this form. To do this, please use the "Create a ticket" form.
Thank you. Your feedback has been received.
Access your community space. Ask questions, search for information, post content, and interact with other OVHcloud Community members.
Discuss with the OVHcloud community