# How to use kubectl

**URL:** <https://forums.suse.com/t/how-to-use-kubectl/10508>\
**Category:** SUSE Rancher Prime\
**Created:** [May 22, 2018, 1:55pm UTC](https://forums.suse.com/t/how-to-use-kubectl/10508 "2018-05-22T13:55:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jim](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jim](https://forums.suse.com/u/jim)\
**Post date:** [May 22, 2018, 1:55pm UTC](https://forums.suse.com/t/how-to-use-kubectl/10508/1 "2018-05-22T13:55:08Z")

</div>

which container i can attend to use kubectl command to vi yuml files.  
I want to use kubectl to create Deployment or other things.  
In the http mode. vi command is too difficult to use.

---

<div class="post-metadata">

**Author:** ![etlweather](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/etlweather/32/419_2.png) [@etlweather](https://forums.suse.com/u/etlweather)\
**Post date:** [May 23, 2018, 2:18pm UTC](https://forums.suse.com/t/how-to-use-kubectl/10508/2 "2018-05-23T14:18:04Z")

</div>

You can have kubectl on your local machine, and download the kubeconfig file from the cluster dashboard and place it in `~/.kube/config` as instructed on the screen.

 ![2018-05-23%2010_16_50-Rancher](https://us1.discourse-cdn.com/flex022/uploads/suse/original/2X/e/e5bb624da28f0c292bc3aca005e7e1061029c492.png)

![2018-05-23%2010_17_14-Rancher](https://us1.discourse-cdn.com/flex022/uploads/suse/original/2X/b/b01b5b4123b8ded68297fe02778ca52a18f05d77.png)

---

<div class="post-metadata">

**Author:** ![mbuckman](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/mbuckman/32/4143_2.png) [@mbuckman](https://forums.suse.com/u/mbuckman)\
**Post date:** [June 5, 2018, 1:54pm UTC](https://forums.suse.com/t/how-to-use-kubectl/10508/3 "2018-06-05T13:54:02Z")

</div>

So technically I can only manage one cluster at a time from my local machine, or update the config each time I want to switch to another cluster?

---

<div class="post-metadata">

**Author:** ![etlweather](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/etlweather/32/419_2.png) [@etlweather](https://forums.suse.com/u/etlweather)\
**Post date:** [June 5, 2018, 2:04pm UTC](https://forums.suse.com/t/how-to-use-kubectl/10508/4 "2018-06-05T14:04:05Z")

</div>

Good question - I didn’t think of that before… and since I will be managing more than one cluster…

Well the YAML has `clusters:` as an array, so presumably you can put in multiple cluster definitions. Same goes for `contexts` array and `users` array.

So, **presumably** , you can combine multiple configuration into one.

---

<div class="post-metadata">

**Author:** ![mbuckman](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/mbuckman/32/4143_2.png) [@mbuckman](https://forums.suse.com/u/mbuckman)\
**Post date:** [June 5, 2018, 3:42pm UTC](https://forums.suse.com/t/how-to-use-kubectl/10508/5 "2018-06-05T15:42:55Z")

</div>

I do believe my config file is correct but I am only able to access one cluster at a time, the last one listed in the config file. This transition which was planned to only take two weeks at most is turning into a lot longer, not too happy with the direction Rancher is headed towards but I remain optimistic.

---

<div class="post-metadata">

**Author:** ![dhawton](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/dhawton/32/4131_2.png) [@dhawton](https://forums.suse.com/u/dhawton)\
**Post date:** [June 5, 2018, 5:24pm UTC](https://forums.suse.com/t/how-to-use-kubectl/10508/6 "2018-06-05T17:24:27Z")

</div>

Kubectl is not rancher… that’s kubernetes. Rancher does not do more than give you configs for kubectl. [https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/)

---

<div class="post-metadata">

**Author:** ![etlweather](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/etlweather/32/419_2.png) [@etlweather](https://forums.suse.com/u/etlweather)\
**Post date:** [June 6, 2018, 1:32am UTC](https://forums.suse.com/t/how-to-use-kubectl/10508/7 "2018-06-06T01:32:06Z")

</div>

Seems like someone is listening…

> <https://github.com/rancher/rancher/issues/13853>
>
> kube config suppports having more than one cluster defined and switching "contex…ts" we should give the user the ability to generate a kubeconfig that has all the clusters they have access to in it so that they can quickly and easily switch between clusters
> 
> gz#11880

---

<div class="post-metadata">

**Author:** ![etlweather](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/etlweather/32/419_2.png) [@etlweather](https://forums.suse.com/u/etlweather)\
**Post date:** [June 6, 2018, 2:05pm UTC](https://forums.suse.com/t/how-to-use-kubectl/10508/8 "2018-06-06T14:05:30Z")

</div>

This may be of help to access multiple cluster: [https://github.com/ahmetb/kubectx](https://github.com/ahmetb/kubectx)

---

<div class="post-metadata">

**Author:** ![d3fk](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/d3fk/32/6299_2.png) [@d3fk](https://forums.suse.com/u/d3fk)\
**Post date:** [April 21, 2020, 11:23am UTC](https://forums.suse.com/t/how-to-use-kubectl/10508/10 "2020-04-21T11:23:24Z")

</div>

I created a light Kubectl container (~45Mb didn’t find equivalent) so that it enables you with many possibilities (multiple config files, running from docker on your sys or directly from K8s Pods, Jobs, CronJobs…): [https://hub.docker.com/r/d3fk/kubectl](https://hub.docker.com/r/d3fk/kubectl)  
Hope this helps.
