How to work with MicroCloud (command cheat sheet)¶
This guide lists the commands you need to know to do common operations in MicroCloud. This command list is not meant to be exhaustive, but it gives a general overview and serves as an entry point to working with MicroCloud.
Make sure to also check the LXD documentation. Most commands you use in MicroCloud are actually LXD client commands and are documented in more detail in the LXD documentation. There, you can also find the man pages for the lxc command.
The sections of the command list provide direct links to specific pages containing more information about the respective topics.
Create and manage instances¶
See Instances.
Check available images¶
List remotes |
lxc remote list |
Switch remotes |
lxc remote switch <remote> |
List images |
lxc image list [<remote>:] |
Create instances¶
See How to create instances and How to access the console.
Create a container (without starting it) |
lxc init [<remote>:]<image> [<name>] [flags] |
Create and start a container |
lxc launch [<remote>:]<image> [<name>] [flags] |
Create a VM (without starting it) |
lxc init [<remote>:]<image> [<name>] --vm [flags] |
Create and start a VM and connect to its VGA console |
lxc launch [<remote>:]<image> [<name>] --vm --console=vga [flags] |
Manage instances¶
List instances |
lxc list |
Show status information about an instance |
lxc info <instance> |
Start an instance |
lxc start <instance> [flags] |
Stop an instance |
lxc stop <instance> [flags] |
Force-stop an instance |
lxc stop <instance> --force |
Delete an instance |
lxc delete <instance> [--force|--interactive] |
Copy an instance |
lxc copy <instance> <new_name> [flags] |
Access instances¶
See How to run commands in an instance, How to access the console, and How to access files in an instance.
Run a command inside an instance |
lxc exec <instance> -- <command> |
Get shell access to an instance (if bash is installed) |
lxc exec <instance> -- bash |
Get console access to an instance |
lxc console <instance> [flags] |
Pull a file from an instance |
lxc file pull <instance>/<instance_filepath> <local_filepath> |
Push a file to an instance |
lxc file pull <local_filepath> <instance>/<instance_filepath> |
Configure instances¶
See How to configure instances, How to use profiles, and Instance configuration (and sub-pages).
Show the configuration of an instance |
lxc config show <instance> |
Show the configuration of an instance, including configurations inherited from a profile |
lxc config show <instance> --expanded |
Set some configuration options for an instance (this example limits memory and CPU usage) |
lxc config set <instance> limits.memory=8GiB limits.cpu=4 Tip See Instance options for all available instance options. |
Override some device options for an instance (this example sets the root disk size) |
lxc config device override <instance> root size=10GiB Tip See Devices for the device options that are available for each device type. |
Edit the full configuration of an instance |
lxc config edit <instance> |
Apply a profile to an instance |
lxc profile add <instance> <profile> |
Use cloud-init
¶
For example, to import an SSH key:
Create a profile: lxc profile create <profile>
Run lxc profile edit <profile> and add the following configuration to the profile:
config: cloud-init.user-data: | #cloud-config ssh_authorized_keys: - <public_key>
Launch the instance using that profile (in addition to the
default
profile): lxc launch <image> [<name>] --profile default --profile <profile>
Manage instance snapshots¶
See Use snapshots for instance backup.
Create a snapshot |
lxc snapshot <instance> [<snapshot_name>] [flags] |
View information about a snapshot |
lxc config show <instance>/<snapshot_name> |
View all snapshots of an instance |
lxc info <instance> |
Restore a snapshot |
lxc restore <instance> <snapshot_name> [--stateful] |
Delete a snapshot |
lxc delete <instance>/<snapshot_name> |
Create an instance from a snapshot |
lxc copy <instance>/<snapshot_name> <new_instance> |
Configure storage¶
See How to manage storage volumes.
To create a storage pool, see How to manage storage pools.
However, keep in mind that for MicroCloud to be able to use the storage pool, it must be created for the cluster and not only for one machine.
Therefore, the following example commands use the remote
storage pool that is automatically set up in MicroCloud.
Create a custom storage volume of content type |
lxc storage volume create remote <volume> |
Create a custom storage volume of content type |
lxc storage volume create remote <volume> --type=block |
Attach a custom storage volume of content type |
lxc storage volume attach remote <volume> <instance> <location> |
Attach a custom storage volume of content type |
lxc storage volume attach remote <volume> <instance> |
Configure networking¶
See Networking (and sub-pages).
Create a network |
lxc network create <network> --type=<type> [options] Tip See How to create a network for detailed information. |
Attach an instance to a network |
lxc network attach <network> <instance> [<device>] [<interface>] Tip See Attach a network to an instance for detailed information. |
Create and apply a network ACL to an instance |
lxc network acl rule add <ACL> ingress|egress [properties] lxc network set <network> security.acls="<ACL>" Tip See How to configure network ACLs for detailed information. |
Expose an instance on an external IP |
lxc network forward <network> create <external_IP> target_address=<instance_IP> Tip See How to configure network forwards for detailed information. |
Use projects¶
See About projects and Projects (and sub-pages).
Create a project |
lxc project create <project> [--config <option>] |
Configure a project |
lxc project set <project> <option> |
Switch to a project |
lxc project switch <project> |
Configure the LXD server¶
See How to configure the LXD server.
Configure server options |
lxc config set <key> <value> Tip See Server configuration for all available server options. |
Enable GUI access to the LXD cluster |
lxc config set core.https_address :8443 Then enable the UI on the snap and reload the snap: snap set lxd ui.enable=true
sudo systemctl reload snap.lxd.daemon
Tip See How to access the LXD web UI for detailed information. |
Manage the MicroCloud cluster¶
See How to manage instances in a cluster and Evacuate and restore cluster members.
Inspect the cluster status for all services at once |
:command: |
Inspect the cluster status for each service |
microcloud cluster list lxc cluster list microceph cluster list microovn cluster list |
Move an instance to a different cluster member |
lxc move <instance> --target <member> |
Copy an instance from a different LXD server |
Add one of the MicroCloud cluster members as a remote on the different LXD server and copy or move the instance from that server. lxc copy <instance> <remote> Tip See How to move existing LXD instances between servers for details. |
Evacuate a cluster member |
lxc cluster evacuate <member> |
Restore a cluster member |
lxc cluster restore <member> |