MicroK8s adds the ‘microk8s’ command with a number of commands:
- microk8s add-node
- microk8s addons
- microk8s config
- microk8s ctr
- microk8s dashboard-proxy
- microk8s dbctl
- microk8s disable
- microk8s enable
- microk8s images
- microk8s inspect
- microk8s join
- microk8s kubectl
- microk8s leave
- microk8s refresh-certs
- microk8s remove-node
- microk8s reset
- microk8s start
- microk8s status
- microk8s stop
- microk8s version
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:
microk8s join 192.168.1.50:25000/4b7fb85e6f00935265c675f00917bc94/e8d855527aa7
Use the '--worker' flag to join a node as a worker not running the control plane, eg:
microk8s join 192.168.1.50:25000/4b7fb85e6f00935265c675f00917bc94/e8d855527aa7 --worker
If the node you are adding is not reachable through the default interface you can use one of the following:
microk8s join 192.168.1.50:25000/4b7fb85e6f00935265c675f00917bc94/e8d855527aa7
microk8s join 172.17.0.1:25000/4b7fb85e6f00935265c675f00917bc94/e8d855527aa7
microk8s join 10.99.27.1:25000/4b7fb85e6f00935265c675f00917bc94/e8d855527aa7
microk8s join 10.164.205.1:25000/4b7fb85e6f00935265c675f00917bc94/e8d855527aa7
microk8s addons
Usage: microk8s addons repo [OPTIONS] COMMAND [ARGS]...
Options:
Commands:
-
add
- Add a MicroK8s addons repository -
list
- List configured MicroK8s addons repositories -
remove
- Remove a MicroK8s addons repository -
update
- Update a MicroK8s addons repository
Description:
This command is used to add, list, remove and update addons repositories.
Examples:
microk8s.addons repo list
…will result in output similar to:
REPO ADDONS SOURCE
community 17 /snap/microk8s/current/addons/community@dd28dd
core 17 /snap/microk8s/current/addons/core@247de6
microk8s.addons repo add myrepo https://github.com/myorg/myrepo --reference devbranch
…will add the repository https://github.com/myorg/myrepo
and give it a name of myrepo
. The addons in the devbranch
branch will be immediately available to MicroK8s.
microk8s.addons repo remove myrepo
…will remove the myrepo
repository. All addons provided by the removed repository will not be available to MicroK8s anymore.
microk8s.addons repo update myrepo
…will fetch the latest changes to the addons’ enable and disable scripts of the myrepo
repository.
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:
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCRENDQWV5Z0F3SUJBZ0lKQVBQMGhoaFduTTR0TUEwR0NTcUdTSWIzRFFFQkN3VUFNQmN4RlRBVEJnTlYKQkFNTURERXdMakUxTWk0eE9ETXVNVEFlRncweE9URXdNVFl3T1RRNE5UaGFGdzAwTnpBek1ETXdPVFE0TlRoYQpNQmN4RlRBVEJnTlZCQU1NRERFd0xqRTFNaTR4T0RNdU1UQ0NBU0l3RFFZSktvWklodmNOQVFFQkJRQURnZ0VQCkFEQ0NBUW9DZ2dFQkFQbWpiZ3F6NWxTL3FlTldlcDduVE9NUS94NXp6MUI5bGR3dTJkZkVxbEtIRXVWT3RZYU0KeVJMb0xtYmZBbUxTd2ZDSXIycWhyZ1UxTlFTd096WUVCeXpNZ01WaWtzejZlVjJ3Um10b3RxbXpXLzZHQTh1SQpmM1MvTURERHh2ZmQva1hrb2lpeTE5WCtPVENDTHFUTmJZRG45RkdRTjJWSVVzVWV5Z255LzJjbkpDb0xLTGtBCm04NHVTUXBLYUJ1T3hzeFZBU3J6cURINk1uczN5Y0pyWXRqSG9BaDBTcWxFdHhKblpGOGJpTGx2Q2lRVkMyNE4KQ2IyMkpRMHVyQWFRUlBIRmRsaGtKU1RBL2Y0VFp1VDN2N2tpaU9QZWpGT252M0lXYld3UXZRYU5ad0JmM0NQQwozK0dIRXNSU1NPYkQ5Z2FGODhVTXNScEM1TFBaVm12eFFVc0NBd0VBQWFOVE1GRXdIUVlEVlIwT0JCWUVGUElKCmp6ZWhaYW1nS0xPSkQyVitiU3VMaHFjU01COEdBMVVkSXdRWU1CYUFGUElKanplaFphbWdLTE9KRDJWK2JTdUwKaHFjU01BOEdBMVVkRXdFQi93UUZNQU1CQWY4d0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFIOVlPaGRMT3RXKwpxbkhnajRYMjcwSWRFNDNlc3JRRENEUnY4UGpRVmVwYytNUEdrMU10cFNsckgvTkNnc2puMzZ2RmpFeUJzcXFJCkh4QmhPdi9wR3NIUHdUa2p3bXNSYkdwWkliQTdRcGNKSTZlaEM4aFUwSmI2b3ZwSU9zZnR6SFF6SVA4NWRhOEsKWGptbVY2UzNLQnZtZlpKMU1WZzFuUFBGYnpBdVhoaXI0RmFvZ3AzL2lwNkVFdWtYNUYydnQvVDdSaC9XODFDNQphUFhpTDdSMTUxQm9aU3U2Y2ZUdGx2Y092cW9DSDFvaXlvWlJIV2dSeElPVTU2dXVuRXlUdVNoMjJnbGVSSlAyCk8xWk9rNEVBS3VNMEsra05SeEVvcXNmeFliYlZicENvbGVJRXlLUVhhNzJJU0RrdlVWRmhRMkxGZTJ1bmtvRDgKY2JZbVAxVU1tZ009Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
server: https://192.168.0.2:16443
name: microk8s-cluster
contexts:
- context:
cluster: microk8s-cluster
user: admin
name: microk8s
current-context: microk8s
kind: Config
preferences: {}
users:
- name: admin
user:
username: admin
password: S05BcnhqaWpCNzlRaWtDZEIzNHEzVU5qKzZCaERUbWxjQ2d6VTFmcjkrQT0K
microk8s dashboard-proxy (version 1.19+)
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:
Checking if Dashboard is running.
Waiting for Dashboard to come up.
Dashboard will be available at https://127.0.0.1:10443
Use the following token to login:
eyJhbGciOiKSUzI1NiIsImtpZCI6IkYtMzlhQzZFMjBtTU9zYWYteVgxWk9uekVlQ1JpQXAxanFjYWI3MEluWVEifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZWZhdWx0LXRva2VuLXNmNXc4Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImRlZmF1bHQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJiOGRjNmFjYi02NTA4LTQ1Y2YtYWE1Mi1iNTQ0NmY0ZDQ2YWIiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06ZGVmYXVsdCJ9.NS7sjzIlhN5zNivlQ5vpJdISf75wZfmxRj13CwhgZNhwxHtLDhV7QmpCbgT9D7qAOLbCdi1Xti2zsowkJ4x6E_IH3pM6I1rQ1rx0tPLSsbWXxUkCazcb_argaoJ4LY4MrgSbt0VtFS-6Ljiqh0f4jx8hTr5OTrMO9c_bSg0E-Km1AMRlZsl9-GTo4eLHznOXmsgrQRi5cPbj6zsSs_ckekTDbfn8vxZ35tM3qF4otdo7S9YbAyfiTnTIg6hIhNEzX_pYouOKo-Gz-zcO58ALFb1WRa9k3dfpuNHoR5q5vc-H2qX5Yt63TdU4DLdCHGNcpc8yvRWcqjUpnswSbS9RTQ```
microk8s dbctl
Usage: microk8s dbctl [-h] [--debug] {restore,backup}
Options:
-h, --help show this help message and exit
–debug print debug output
Sub-commands:
{restore,backup} backup and restore operations
Description:
Available on 1.19+ releases, this command allows for backing up and restoring the dqlite based MicroK8s datastore.
Examples:
- To take a backup:
microk8s dbctl backup [-o backup-file]
The -o backup-file
is optional. If not provided a backup file name using the current date and time will be produced.
- To restore dqlite from backup:
microk8s dbctl restore <backup-file.tar.gz>
microk8s ctr
Usage: microk8s ctr [command]
Options:
- any ctr command: see below
Description:
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
.
Examples:
microk8s ctr version
…will result in output similar to:
Client:
Version: v1.2.5
Revision: bb71b10fd8f58240ca47fbb579b9d1028eea7c84
microk8s disable
Usage: microk8s disable addon [addon ...]
Options:
- addon : The name of the addon to disable.
Description:
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.
Examples:
microk8s disable dns
…will usually result in output detailing what has been done. In this case,
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
microk8s enable
Usage: microk8s enable addon [addon ... ]
Options:
- addon : The name of the addon to enable.
Description:
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.
For a list of the current available addons, and whether or not they are enabled, run microk8s status
.
Examples:
microk8s enable storage
…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
microk8s images (version 1.25+)
Usage: microk8s images [OPTIONS] COMMAND [ARGS]...
Options:
Commands:
-
export-local
- Export OCI images from the local MicroK8s node -
import
- Import OCI images into the MicroK8s cluster
Description:
This command is used to import OCI images into a MicroK8s cluster, or export images from the local node.
For more details, see Image Side-Loading.
Examples:
microk8s images export-local > images.tar
…will export all images from the local MicroK8s node into images.tar
, and produce output similar to:
Checking docker.io/calico/cni:v3.21.4
Checking docker.io/calico/cni@sha256:36acb85e6080a3a894ea5f92f20dabd1179061f5ecb079a49913bbdfb714ad09
Checking docker.io/calico/kube-controllers:v3.21.4
Checking docker.io/calico/kube-controllers@sha256:f71a293e43f66c8f3d2435a3d56ed53cbb1bcf539dcfe7fe2cc64d4258f4f792
Checking docker.io/calico/node:v3.21.4
Checking docker.io/calico/node@sha256:acb402642ba8a9a28eda86d9cd3eef97976dd339c11e33863faeae4e00682e12
Checking docker.io/calico/pod2daemon-flexvol:v3.21.4
Checking docker.io/calico/pod2daemon-flexvol@sha256:baeaa86e59194d2707be3b708b5ef157fe09738605bdabffc5a4a7cc7560b7d7
Checking docker.io/library/nginx:latest
Checking docker.io/library/nginx@sha256:fd304ffea0c92df362f25021faf126d8307f52f352fe7635b7713e740388a3d7
Checking k8s.gcr.io/pause:3.7
Checking k8s.gcr.io/pause@sha256:bb6ed397957e9ca7c65ada0db5c5d1c707c9c8afc80a94acbe69f3ae76988f0c
microk8s images import < images.tar
…will import all images from the images.tar
file into all nodes of the MicroK8s cluster. For a 3-node cluster, the command output would look like this:
Pushing OCI images to 127.0.0.1:25000
Pushing OCI images to 192.168.1.101:25000
Pushing OCI images to 192.168.1.102:25000
microk8s inspect
Usage: microk8s inspect
Options:
Description:
This command creates a detailed profile of the current state of the running MicroK8s. This is primarily useful for troubleshooting and reporting bugs.
Examples:
microk8s inspect
…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
microk8s join
Usage: microk8s join [options] <master>:<port>/<token>
Options:
-
--worker
: Join as a worker only node. -
--controlplane
: Join running the control plane on HA clusters. This is the default behavior. -
--skip-verify
: Skip the certificate verification of the node we are joining to. -
--disable-low-memory-guard
: Disable the low memory guard.
Description:
Used to join the local MicroK8s node in to a remote cluster. An ‘invitation’ in
the form of a token is required, which is issued by running the
microk8s add-node
command on the master MicroK8s node.
Running microk8s add-node
will output a number of different commands which can
be used from the node wishing to join, taking into account different
network addressing. The microk8s join
command will need the address and port
number of the master node, as well as the token, in order for this command to
be successful.
Examples:
microk8s join 10.128.63.163:25000/JGoShFJfHtbieSOsMhmkgsOHrwtxDKRH
microk8s kubectl
Usage: microk8s kubectl [command]
Options:
- any
kubectl
command : See description.
Description:
This command runs the standard Kubernetes kubectl
which ships with MicroK8s.
Examples:
microk8s kubectl get all
…will result in output similar to:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 108m
microk8s leave
Usage: microk8s leave
Options:
Description:
When run on a node which has previously joined a cluster with microk8s join
,
this command will remove the current node from the cluster and return it to
single node operation.
Examples:
microk8s leave
microk8s refresh-certs (version 1.19+)
Usage: microk8s refresh-certs [</ca-path>] [-u] [-c] [-e]
Options:
- -c : Check the expiration time of the current certificates.
- -e : The certificate to be autogenerated, must be one of [‘ca.crt’, ‘server.crt’, ‘front-proxy-client.crt’]
- -u : Undo the last operation.
Description:
A self-signed CA is created by MicroK8s at install time. Starting from the 1.19 release, it is possible to refresh that CA as well as the server and the front proxy certificates signed by the CA.
Call microk8s refresh-certs
with the -e
flag to auto-generate any of the ‘ca.crt’, ‘server.crt’, ‘front-proxy-client.crt’ certificates or provide a </ca-path>
with the CA’s ca.crt
and ca.key
files.
On its own:
sudo microk8s refresh-certs -e ca.crt
…will generate and use a new CA.
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/
To undo the last operation you can use the -u
flag:
sudo microk8s refresh-certs -u
To check the expiration time of the installed CA:
sudo microk8s refresh-certs -c
Notes:
- The CA should not be updated in a cluster with running workloads. Auxiliary certificates and credentials make use of the CA, so updating the CA in a live cluster will have unpredictable effects.
- In a multi-node setup, nodes will need to leave and rejoin the cluster in order for new certificates to properly propagate.
microk8s remove-node
Usage: microk8s remove-node address
Options:
- address : The address of the node to be removed
Description:
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:
microk8s kubectl get nodes
This command only works on the master node of the cluster. To remove the local node from a remote cluster, see microk8s leave
.
Examples:
microk8s remove-node 10.128.63.163
microk8s reset
Usage: microk8s reset [--destroy-storage]
Options:
-
--destroy-storage
: Also deletes any files which may have been created by the storage addon.
Description:
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.
This commands makes it easy to revert your MicroK8s to an ‘install fresh’ state wihout having to reinstall anything.
Examples:
microk8s reset
…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
...
microk8s start
Usage: microk8s start
Options:
Description:
Will start MicroK8s, if the MicorK8s node has previously been halted with microk8s stop
.
Examples:
microk8s start
…will result in output similar to:
Started.
Enabling pod scheduling
node/ubuntu1804 already uncordoned
microk8s status
Usage: microk8s status
Options:
Description:
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.
Examples:
microk8s status
…will result in output similar to:
microk8s is running
high-availability: no
datastore master nodes: 127.0.0.1:19001
datastore standby nodes: none
addons:
enabled:
ha-cluster # (core) Configure high availability on the current node
disabled:
community # (core) The community addons repository
dashboard # (core) The Kubernetes dashboard
dns # (core) CoreDNS
gpu # (core) Automatic enablement of Nvidia CUDA
helm # (core) Helm 2 - the package manager for Kubernetes
helm3 # (core) Helm 3 - Kubernetes package manager
host-access # (core) Allow Pods connecting to Host services smoothly
hostpath-storage # (core) Storage class; allocates storage from host directory
ingress # (core) Ingress controller for external access
mayastor # (core) OpenEBS MayaStor
metallb # (core) Loadbalancer for your Kubernetes cluster
metrics-server # (core) K8s Metrics Server for API access to service metrics
prometheus # (core) Prometheus operator for monitoring and logging
rbac # (core) Role-Based Access Control for authorisation
registry # (core) Private image registry exposed on localhost:32000
storage # (core) Alias to hostpath-storage add-on, deprecated
microk8s stop
Usage: microk8s stop
Options:
Description:
Halts the current MicroK8s node.
Examples:
microk8s stop
…will result in output describing the shutdown process.
microk8s version (version 1.25+)
Usage: microk8s version
Options:
Description:
Prints the installed MicroK8s version and revision number.
Examples:
microk8s version
…will result in output similar to:
MicroK8s v1.25.3 revision 3608