# Why installing kubectl if already using microk8s (video from canaonical)

**URL:** <https://discuss.kubernetes.io/t/why-installing-kubectl-if-already-using-microk8s-video-from-canaonical/14829>\
**Category:** microk8s\
**Created:** [February 14, 2021, 5:58pm UTC](https://discuss.kubernetes.io/t/why-installing-kubectl-if-already-using-microk8s-video-from-canaonical/14829 "2021-02-14T17:58:17Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alessandro\_Dentella](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/alessandro_dentella/32/6541_2.png) [@Alessandro\_Dentella](https://discuss.kubernetes.io/u/Alessandro_Dentella)\
**Post date:** [February 14, 2021, 5:58pm UTC](https://discuss.kubernetes.io/t/why-installing-kubectl-if-already-using-microk8s-video-from-canaonical/14829/1 "2021-02-14T17:58:17Z")

</div>

While studying microk8s I watched the video titled [MicroK8s basics (Part 1): MicroK8s installation & simple commands](https://www.youtube.com/watch?v=wN6FlmPy2qA) in the [celebrateubuntu youtube channel](https://www.youtube.com/watch?v=wN6FlmPy2qA).

I’m puzzled as it installs both microk8s AND kubectl. Why that?

If it wasn’t for the authoritative channel I would have thought at an error, but since it’s from Ubuntu there must be an explanation that I can’t make out…

---

<div class="post-metadata">

**Author:** ![metabsd](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/metabsd/32/6946_2.png) [@metabsd](https://discuss.kubernetes.io/u/metabsd)\
**Post date:** [February 14, 2021, 10:58pm UTC](https://discuss.kubernetes.io/t/why-installing-kubectl-if-already-using-microk8s-video-from-canaonical/14829/2 "2021-02-14T22:58:23Z")

</div>

`sudo snap alias microk8s.kubectl`

---

<div class="post-metadata">

**Author:** ![Alessandro\_Dentella](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/alessandro_dentella/32/6541_2.png) [@Alessandro\_Dentella](https://discuss.kubernetes.io/u/Alessandro_Dentella)\
**Post date:** [February 14, 2021, 11:26pm UTC](https://discuss.kubernetes.io/t/why-installing-kubectl-if-already-using-microk8s-video-from-canaonical/14829/3 "2021-02-14T23:26:43Z")

</div>

Thanks, @metabsd, I know how to create the alias.

My question is why did the video suggest to also install kubeclt (`sudo snap install kubectl`) when, in fact, it already had kubectl from the installation of microk8s.

---

<div class="post-metadata">

**Author:** ![metabsd](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/metabsd/32/6946_2.png) [@metabsd](https://discuss.kubernetes.io/u/metabsd)\
**Post date:** [February 14, 2021, 11:45pm UTC](https://discuss.kubernetes.io/t/why-installing-kubectl-if-already-using-microk8s-video-from-canaonical/14829/4 "2021-02-14T23:45:44Z")

</div>

I have not seen the video but the only logical reason I see is to `snap install kubectl` from another Ubuntu to manage the cluster from outside.

---

<div class="post-metadata">

**Author:** ![Alessandro\_Dentella](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/alessandro_dentella/32/6541_2.png) [@Alessandro\_Dentella](https://discuss.kubernetes.io/u/Alessandro_Dentella)\
**Post date:** [April 7, 2021, 8:50am UTC](https://discuss.kubernetes.io/t/why-installing-kubectl-if-already-using-microk8s-video-from-canaonical/14829/5 "2021-04-07T08:50:18Z")

</div>

I have now another case to use kubectl from `snap install kubectl`: It correctly reads `~/.kube/config` that `kubectl` from `microk8s` does not!!!

\*☹

---

<div class="post-metadata">

**Author:** ![balchua1](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/balchua1/32/5372_2.png) [@balchua1](https://discuss.kubernetes.io/u/balchua1)\
**Post date:** [April 7, 2021, 11:19am UTC](https://discuss.kubernetes.io/t/why-installing-kubectl-if-already-using-microk8s-video-from-canaonical/14829/6 "2021-04-07T11:19:51Z")

</div>

I also use kubectl from snap. I export the microk8s config to `~/.kube/config`.

---

<div class="post-metadata">

**Author:** ![horvatic](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/horvatic/32/7332_2.png) [@horvatic](https://discuss.kubernetes.io/u/horvatic)\
**Post date:** [April 8, 2021, 4:48am UTC](https://discuss.kubernetes.io/t/why-installing-kubectl-if-already-using-microk8s-video-from-canaonical/14829/7 "2021-04-08T04:48:56Z")

</div>

Why would you need to setup ~/.kube/config on the same machine using microk8s? My setup is microk8’s for internal cluster actions, and kubectl for external actions

---

<div class="post-metadata">

**Author:** ![Alessandro\_Dentella](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/alessandro_dentella/32/6541_2.png) [@Alessandro\_Dentella](https://discuss.kubernetes.io/u/Alessandro_Dentella)\
**Post date:** [May 1, 2021, 10:27pm UTC](https://discuss.kubernetes.io/t/why-installing-kubectl-if-already-using-microk8s-video-from-canaonical/14829/8 "2021-05-01T22:27:28Z")

</div>

To be able to launch a command from one cluster in another cluster… I think that’s the point of ~/.kube/config, isn’t it?

---

<div class="post-metadata">

**Author:** ![horvatic](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/horvatic/32/7332_2.png) [@horvatic](https://discuss.kubernetes.io/u/horvatic)\
**Post date:** [May 2, 2021, 1:39am UTC](https://discuss.kubernetes.io/t/why-installing-kubectl-if-already-using-microk8s-video-from-canaonical/14829/9 "2021-05-02T01:39:43Z")

</div>

So my current setup uses the ~/.kube/config. My current setup is such:

```auto
workstation -> master
                  -> node
                  -> node
                  -> node

```

I use the kubectl command to do actions on my master. The workstation has the `~/.kube/config`

It sounds like you are trying to do this:

```auto
master1 -> master2

```

Where master1 is a k8’s master, and master2 is a k8s master. Both running microk8’s. Is that correct?

I would think this may cause some issues, but I can’t confirm. Why can’t you use the workstation approach?

```auto
workstation -> master1
            -> master2 

```

---

<div class="post-metadata">

**Author:** ![Alessandro\_Dentella](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/alessandro_dentella/32/6541_2.png) [@Alessandro\_Dentella](https://discuss.kubernetes.io/u/Alessandro_Dentella)\
**Post date:** [May 2, 2021, 10:03pm UTC](https://discuss.kubernetes.io/t/why-installing-kubectl-if-already-using-microk8s-video-from-canaonical/14829/10 "2021-05-02T22:03:06Z")

</div>

I also installed microk8s on my laptop, just to study it. At that point I has kubect as alias to `microk8s.kubectl`.

Nowhere in the docs I read this is not a recommended setup. From my workstation want to reach any need to must administer.

I _can_ use kubectl from its own snap rather that from `microk8s`, but I’d like to know **why** I need to do that. Docs say that `microk8s.kubectl` should read `~/.kube/config`.

Why do you think is should cause “some issues”?

---

<div class="post-metadata">

**Author:** ![horvatic](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/horvatic/32/7332_2.png) [@horvatic](https://discuss.kubernetes.io/u/horvatic)\
**Post date:** [May 4, 2021, 3:02am UTC](https://discuss.kubernetes.io/t/why-installing-kubectl-if-already-using-microk8s-video-from-canaonical/14829/11 "2021-05-04T03:02:44Z")

</div>

The some issues is more of a gut feeling. I have no idea how microk8’s sets up its config, but it “just works” out of the box for local, Looking at my master node it doesn’t even have a `~/.kube/config` file, but I can still do microk8s.kubectl commands.

My method isn’t the “recommended setup”, but it seems to work really well.

Reading the docs I do not see how it would work with the `~/.kube/config`. It seems to point at the opposite.

> MicroK8s comes with its own packaged version of the kubectl command for operating Kubernetes. By default, this is accessed through MicroK8s, to avoid interfering with any version which may already be on the host machine (including its configuration).

I would setup a master config with all your masters and use kubectl, not microk8s kubectl. That would seem to solve your issue
