---
title: Working with kubectl
description: Canonical makes open source secure, reliable and easy to use, providing
  support for Ubuntu and a portfolio of enterprise-grade technologies. Founded in
  2004, Canonical operates globally with team members in over 80 countries.
url: https://canonical.com/microk8s/docs/working-with-kubectl?format=md
---

*Submit*

# Working with kubectl

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). It is run in a terminal like this:

```
microk8s kubectl
```

If you are using or want to use a different kubectl command, see the relevant sections below for your OS

### Linux

If you’d prefer to use your host’s [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) command, running the following command will output the kubeconfig file from MicroK8s.

```
microk8s config
```

If you have not already configured kubectl on the host, you can just open a terminal and generate the required config :

```
cd $HOME
mkdir .kube
cd .kube
microk8s config > config
```

If you have already configured other Kubernetes clusters, you should merge the output from the `microk8s config` with the existing config (copy the output, omitting the first two lines, and paste it onto the end of the existing config using a text editor).

### Windows

MicroK8s comes with its own [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) command, which can be accessed like this:

```
microk8s kubectl
```

There are some advantages to running the Windows native version of `kubectl`, notably when working with files(which otherwise need to be copied to/from the VM). To install the Windows version of `kubectl`, see the [official documentation](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-on-windows). Running the following command will output the kubeconfig file from MicroK8s:

```
microk8s config
```

If you have not already configured kubectl on the host for other clusters, you can open a ‘cmd’ Command Prompt and run the following:

```
cd %USERPROFILE%
mkdir .kube
cd .kube
microk8s config > config
```

If you have already configured other Kubernetes clusters, you should merge the output from the `microk8s config` with the existing config (copy the output, omitting the first two lines, and paste it onto the end of the existing config using a text editor).

### macOS

MicroK8s comes with its own [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) command, which can be accessed like this:

```
microk8s kubectl
```

There are some advantages to running the native version of `kubectl` for macOS, notably when working with files (which otherwise need to be copied to/from the VM). To install the macOS version of `kubectl`, see the [official documentation](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-on-macos). Running the following command will output the kubeconfig file from MicroK8s:

```
microk8s config
```

If you have not already configured kubectl on the host, you can just open a terminal and generate the required config :

```
cd $HOME
mkdir .kube
cd .kube
microk8s config > config
```

If you have already configured other Kubernetes clusters, you should merge the output from the `microk8s config` with the existing config (copy the output, omitting the first two lines, and paste it onto the end of the existing config using a text editor).

Last updated 6 years ago. [Help improve this document in the forum](https://discuss.kubernetes.io/t/working-with-kubectl/11258).
