Command reference

MicroK8s adds the ‘microk8s’ command with a number of commands:

Addon helper commands

Some commands are specific to particular addons (e.g. microk8s cilium) and may not do anything useful if the respective addon is not currently enabled. For more information on these commands, see the Addon documentation.

  • microk8s cilium
  • microk8s helm
  • microk8s istioctl
  • microk8s linkerd

microk8s add-node

Usage: microk8s add-node

Options:

  • -l, --token-ttl TTL. Specify how long the token is valid in seconds, before it expires. Value of “-1” indicates that the token is usable only once (i.e. after joining a node, the token becomes invalid)

  • -t, --token TOKEN. Specify the bootstrap token to add, must be 32 characters long. Auto generates when empty.

Description:
Running this command will generate a connection string and output a list of suggested microk8s join commands to add an additional MicroK8s node to the current cluster.

Examples:

microk8s add-node

…will result in output similar to:

  1. Join node with: microk8s join 192.168.0.2:25000/eLCTbltkDzxOnSKAkmVMbOPYgSrAieEl
  2. If the node you are adding is not reachable through the default interface you can
  3. use one of the following:
  4. microk8s join 192.168.0.2:25000/eLCTbltkDzxOnSKAkmVMbOPYgSrAieEl
  5. microk8s join 192.168.250.1:25000/eLCTbltkDzxOnSKAkmVMbOPYgSrAieEl
  6. microk8s join 10.57.200.1:25000/eLCTbltkDzxOnSKAkmVMbOPYgSrAieEl
  7. microk8s join 10.128.63.1:25000/eLCTbltkDzxOnSKAkmVMbOPYgSrAieEl
  8. microk8s join 172.17.0.1:25000/eLCTbltkDzxOnSKAkmVMbOPYgSrAieEl
  9. microk8s join 10.1.37.68:25000/eLCTbltkDzxOnSKAkmVMbOPYgSrAieEl
  10. microk8s join 192.168.122.1:25000/eLCTbltkDzxOnSKAkmVMbOPYgSrAieEl

microk8s config

Usage: microk8s config [-l]

Options:

  • -l, --use-loopback : Report the cluster address using the loopback
    address (127.0.0.1) rather than the default interface address.

Description:
Retrieves and outputs the current config information from MicroK8s (similar to that returned by kubectl).

Examples:

microk8s config

…will result in output similar to:

  1. apiVersion: v1
  2. clusters:
  3. - cluster:
  4. certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCREND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dwWkliQTdRcGNKSTZlaEM4aFUwSmI2b3ZwSU9zZnR6SFF6SVA4NWRhOEsKWGptbVY2UzNLQnZtZlpKMU1WZzFuUFBGYnpBdVhoaXI0RmFvZ3AzL2lwNkVFdWtYNUYydnQvVDdSaC9XODFDNQphUFhpTDdSMTUxQm9aU3U2Y2ZUdGx2Y092cW9DSDFvaXlvWlJIV2dSeElPVTU2dXVuRXlUdVNoMjJnbGVSSlAyCk8xWk9rNEVBS3VNMEsra05SeEVvcXNmeFliYlZicENvbGVJRXlLUVhhNzJJU0RrdlVWRmhRMkxGZTJ1bmtvRDgKY2JZbVAxVU1tZ009Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
  5. server: https://192.168.0.2:16443
  6. name: microk8s-cluster
  7. contexts:
  8. - context:
  9. cluster: microk8s-cluster
  10. user: admin
  11. name: microk8s
  12. current-context: microk8s
  13. kind: Config
  14. preferences: {}
  15. users:
  16. - name: admin
  17. user:
  18. username: admin
  19. password: S05BcnhqaWpCNzlRaWtDZEIzNHEzVU5qKzZCaERUbWxjQ2d6VTFmcjkrQT0K

microk8s dashboard-proxy

Usage: microk8s dashboard-proxy

Options:

Description:
Available on 1.19+ releases. This command enables the dashboard add-on if is not already enabled, configures port-forwarding to allow the dashboard to be accessed from the local machine, and prints the URL and token to access the dashboard.

Examples:

microk8s dashboard-proxy

…will result in output similar to:

  1. Checking if Dashboard is running.
  2. Waiting for Dashboard to come up.
  3. Dashboard will be available at https://127.0.0.1:10443
  4. Use the following token to login:
  5. eyJhbGciOiKSUzI1NiIsImtpZCI6IkYtMzlhQzZFMjBtTU9zYWYteVgxWk9uekVlQ1JpQXAxanFjYWI3MEluWVEifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZWZhdWx0LXRva2VuLXNmNXc4Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImRlZmF1bHQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJiOGRjNmFjYi02NTA4LTQ1Y2YtYWE1Mi1iNTQ0NmY0ZDQ2YWIiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06ZGVmYXVsdCJ9.NS7sjzIlhN5zNivlQ5vpJdISf75wZfmxRj13CwhgZNhwxHtLDhV7QmpCbgT9D7qAOLbCdi1Xti2zsowkJ4x6E_IH3pM6I1rQ1rx0tPLSsbWXxUkCazcb_argaoJ4LY4MrgSbt0VtFS-6Ljiqh0f4jx8hTr5OTrMO9c_bSg0E-Km1AMRlZsl9-GTo4eLHznOXmsgrQRi5cPbj6zsSs_ckekTDbfn8vxZ35tM3qF4otdo7S9YbAyfiTnTIg6hIhNEzX_pYouOKo-Gz-zcO58ALFb1WRa9k3dfpuNHoR5q5vc-H2qX5Yt63TdU4DLdCHGNcpc8yvRWcqjUpnswSbS9RTQ
  1. ### microk8s dbctl
  2. **Usage:** `microk8s dbctl [-h] [--debug] {restore,backup}`
  3. **Options:**
  4. \-h, --help show this help message and exit
  5. debug print debug output
  6. **Sub-commands:**
  7. {restore,backup} backup and restore operations
  8. **Description:**
  9. Available on 1.19+ releases, this command allows for backing up and restoring the dqlite based MicroK8s datastore.
  10. **Examples:**
  11. - To take a backup:
  12. `microk8s dbctl backup [-o backup-file]`
  13. The `-o backup-file` is optional. If not provided a backup file name using the current date and time will be produced.
  14. - To restore dqlite from backup:
  15. `microk8s dbctl restore <backup-file.tar.gz>`
  16. ### microk8s ctr
  17. **Usage:** `microk8s ctr [command]`
  18. **Options:**
  19. - any ctr command: see below
  20. **Description:**
  21. This command provides access to the containerd CLI command `ctr`. It is provided as a convenience, for more information on using `ctr`, please see the relevant manpage with `man ctr` or run the built-in help with `microk8s ctr`.
  22. **Examples:**
  23. `microk8s ctr version`
  24. will result in output similar to:

Client: Version: v1.2.5 Revision: bb71b10fd8f58240ca47fbb579b9d1028eea7c84

  1. ### microk8s disable
  2. **Usage:** `microk8s disable addon [addon ...]`
  3. **Options:**
  4. - *addon* : The name of the addon to disable.
  5. **Description:**
  6. MicroK8s addons can be enabled or disabled at any time. This command accepts the name of an addon and then proceeds to make the necessary changes to remove it from the current node. Note that some services and applications may not continue to work properly if addons are removed.
  7. **Examples:**
  8. `microk8s disable dns`
  9. will usually result in output detailing what has been done. In this case,
  10. the ouput will be similar to:

Disabling DNS Reconfiguring kubelet Removing DNS manifest serviceaccount “coredns” deleted configmap “coredns” deleted deployment.apps “coredns” deleted service “kube-dns” deleted clusterrole.rbac.authorization.k8s.io “coredns” deleted clusterrolebinding.rbac.authorization.k8s.io “coredns” deleted

  1. ### microk8s enable
  2. **Usage:** `microk8s enable addon [addon ... ]`
  3. **Options:**
  4. - *addon* : The name of the addon to enable.
  5. **Description:**
  6. MicroK8s addons can be enabled or disabled at any time. This command accepts the name of an addon and then proceeds to make the necessary changes to MicroK8s to enable it. For more details, see the documentation for the specific addon in question in the [addons documentation]($c78dbad259a33469.md).
  7. For a list of the current available addons, and whether or not they are enabled, run `microk8s status`.
  8. **Examples:**
  9. `microk8s enable storage`
  10. will result in output similar to:

Enabling default storage class deployment.apps/hostpath-provisioner created storageclass.storage.k8s.io/microk8s-hostpath created serviceaccount/microk8s-hostpath created clusterrole.rbac.authorization.k8s.io/microk8s-hostpath created clusterrolebinding.rbac.authorization.k8s.io/microk8s-hostpath created Storage will be available soon

  1. ### microk8s inspect
  2. **Usage:** `microk8s inspect`
  3. **Options:**
  4. **Description:**
  5. This command creates a detailed profile of the current state of the running MicroK8s. This is primarily useful for troubleshooting and reporting bugs.
  6. **Examples:**
  7. `microk8s inspect`
  8. will result in output similar to:

Inspecting services Service snap.microk8s daemon-cluster-agent is running Service snap.microk8s daemon-flanneld is running Service snap.microk8s daemon-containerd is running Service snap.microk8s daemon-apiserver is running Service snap.microk8s daemon-apiserver-kicker is running Service snap.microk8s daemon-proxy is running Service snap.microk8s daemon-kubelet is running Service snap.microk8s daemon-scheduler is running Service snap.microk8s daemon-controller-manager is running Service snap.microk8s daemon-etcd is running Copy service arguments to the final report tarball Inspecting AppArmor configuration Gathering system information Copy processes list to the final report tarball Copy snap list to the final report tarball Copy VM name (or none) to the final report tarball Copy disk usage information to the final report tarball Copy memory usage information to the final report tarball Copy server uptime to the final report tarball Copy current linux distribution to the final report tarball Copy openSSL information to the final report tarball Copy network configuration to the final report tarball Inspecting kubernetes cluster Inspect kubernetes cluster

Building the report tarball Report tarball is at /var/snap/microk8s/982/inspection-report-20191017_180222.tar.gz

  1. ### microk8s join
  2. **Usage:** `microk8s join <master>:<port>/<token>`
  3. **Options:**
  4. **Description:**
  5. Used to join the local MicroK8s node in to a remote cluster. An invitation in
  6. the form of a token is required, which is issued by running the
  7. `microk8s add-node` command on the master MicroK8s node.
  8. Running `microk8s add-node` will output a number of different commands which can
  9. be used from the node wishing to join, taking into account different
  10. network addressing. The `microk8s join` command will need the address and port
  11. number of the master node, as well as the token, in order for this command to
  12. be successful.
  13. **Examples:**
  14. `microk8s join 10.128.63.163:25000/JGoShFJfHtbieSOsMhmkgsOHrwtxDKRH`
  15. ### microk8s kubectl
  16. **Usage:** `microk8s kubectl [command]`
  17. **Options:**
  18. - any `kubectl` command : See description.
  19. **Description:**
  20. This command runs the standard Kubernetes `kubectl` which ships with MicroK8s.
  21. **Examples:**
  22. `microk8s kubectl get all`
  23. will result in output similar to:

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.152.183.1 443/TCP 108m

  1. ### microk8s leave
  2. **Usage:** `microk8s leave`
  3. **Options:**
  4. **Description:**
  5. When run on a node which has previously joined a cluster with `microk8s join`,
  6. this command will remove the current node from the cluster and return it to
  7. single node operation.
  8. **Examples:**
  9. `microk8s leave`
  10. ### microk8s refresh-certs (version 1.19+)
  11. **Usage:** `microk8s refresh-certs [</ca-path>] [-u] [-c]`
  12. **Options**:
  13. - \-c : check the expiration time of the current certificate.
  14. - \-u : Undo the last operation.
  15. **Description**:
  16. A self-signed CA is created by MicroK8s at install time. Starting from the 1.19 release, it is possible to refresh that CA with an auto-generated one or to configure Kubernetes to use a user-provided one.
  17. Call `microk8s refresh-certs` with no arguments to auto-generate a new CA or provide a `</ca-path>` with the CAs `ca.crt` and `ca.key` files.
  18. On its own:

sudo microk8s refresh-certs

  1. will generate and use a new CA.
  2. To use previously generated cert files, specify a path where the two files `ca.crt` and `ca.key` can be found:

sudo microk8s refresh-certs ./ca-path/

  1. To undo the last operation you can use the `-u` flag:

sudo microk8s refresh-certs -u

  1. To check the expiration time of the installed CA:

sudo microk8s refresh-certs -c

  1. **Notes:**
  2. - The CA should not be updated in a cluster without running workloads. Auxiliary certificates and credentials make use of the CA, so updating the CA in a live cluster will have unpredictable effects.
  3. - In a multi-node setup, nodes will need to leave and rejoin the cluster in order for new certificates to properly propagate.
  4. ### microk8s remove-node
  5. **Usage:** `microk8s remove-node address`
  6. **Options:**
  7. - address : The address of the node to be removed
  8. **Description:**
  9. Removes a specified node from the current cluster. The node should be identified by hostname/IP address by which it is known to the cluster. To retrieve this information you can run:
  10. `microk8s kubectl get nodes`
  11. This command only works on the master node of the cluster. To remove the local node from a remote cluster, see [`microk8s leave`]($b6016dfbb9a6573f.md#heading--microk8s-leave).
  12. **Examples:**
  13. `microk8s remove-node 10.128.63.163`
  14. ### microk8s reset
  15. **Usage:** `microk8s reset [--destroy-storage]`
  16. **Options:**
  17. - `--destroy-storage` : Also deletes any files which may have been created by the storage addon.
  18. **Description:**
  19. This command is used to return the MicroK8s node to the default initial state. This process may take some time and will remove any resources, authentication, running services, pods and optionally, storage. All addons will be disabled and the configuration will be reinitialised.
  20. This commands makes it easy to revert your MicroK8s to an install fresh state wihout having to reinstall anything.
  21. **Examples:**
  22. `microk8s reset`
  23. will result in output similar to:

Calling clean_cluster Cleaning resources in namespace default No resources found endpoints “kubernetes” deleted secret “default-token-5lqdh” deleted serviceaccount “default” deleted service “kubernetes” deleted …

  1. ### microk8s start
  2. **Usage:** `microk8s start`
  3. **Options:**
  4. **Description:**
  5. Will start MicroK8s, if the MicorK8s node has previously been halted with `microk8s stop`.
  6. **Examples:**
  7. `microk8s start`
  8. will result in output similar to:

Started. Enabling pod scheduling node/ubuntu1804 already uncordoned

  1. ### microk8s status
  2. **Usage:** `microk8s status`
  3. **Options:**
  4. **Description:**
  5. This command outputs some useful status information, including the current state of the MicroK8s node, and a list of all the available extensions, indicating which ones are enabled/disabled.
  6. **Examples:**
  7. `microk8s status`
  8. will result in output similar to:

microk8s is running

addons: enabled: cilium: # SDN, fast with full network policy dashboard: # Enable the Kubernetes dashboard dns: # CoreDNS disabled: fluentd: # Elasticsearch-Fluentd-Kibana logging and monitoring gpu: # Automatic enablement of Nvidia CUDA helm: # Leverage Helm charts to manage your Kubernetes apps ingress: # Ingress controller for external access. istio: # Core Istio service mesh services jaeger: # Kubernetes Jaeger operator with its simple config juju: # Model-driven operator engine knative: # Add Knative serverless middleware to your cluster kubeflow: # Enable Kubeflow for easy ML deployments linkerd: # Deploy the linkerd service mesh metallb: # Loadbalancer for your Kubernetes cluster metrics-server: # K8s Metrics Server for API access to service metrics prometheus: # Prometheus operator for monitoring and logging rbac: # Enable Role-Based Access Control for authorisation registry: # Private image registry exposed on localhost:32000 storage: # Storage class; allocates storage from host directory ```

microk8s stop

Usage: microk8s stop

Options:

Description:
Halts the current MicroK8s node.

Examples:

microk8s stop

…will result in output describing the shutdown process.

Last updated 30 days ago. Help improve this document in the forum.