Add Remotes and Manage Resources

steps to configure a remote and operations you can perform with a remote.

Steps to Configure a Remote in LXD

  1. Generate a Trust Token (if required):

    • If the remote server requires authentication, generate a trust token on the remote server:
      lxc config trust add
      
    • This will output a trust token that you can use to authenticate the client with the remote server.
  2. Add the Remote Server:

    • Use the lxc remote add command to add the remote server. Replace <remote_name> with a name for the remote and <server_address> with the IP address or hostname of the remote server:
      lxc remote add <remote_name> <server_address>:<port>
      
    • Example:
      lxc remote add syhydsrv001 172.21.0.20:7443
      
  3. Verify the Certificate Fingerprint:

    • When prompted, verify the certificate fingerprint of the remote server. Ensure it matches the fingerprint displayed by the remote server to avoid man-in-the-middle attacks.
    • Confirm by typing y or entering the fingerprint manually.
  4. Authenticate Using the Trust Token:

    • If the remote server requires a trust token, provide the token when prompted:
      Trust token for syhydsrv001: <paste_trust_token_here>
      
  5. Verify the Remote is Added:

    • List all configured remotes to confirm the remote has been added successfully:
      lxc remote list
      
    • The output should include the newly added remote.
  6. Set the Default Remote (Optional):

    • If you want to set the newly added remote as the default remote for commands:
      lxc remote switch <remote_name>
      

Operations You Can Perform with a Remote in LXD

Once the remote is configured, you can perform a variety of operations to manage containers, images, and configurations across multiple LXD servers. Below are some common operations:

1. Copying Containers Between Remotes

  • You can copy containers from one remote to another. This is useful for migrating workloads or creating backups.
    lxc copy <source_remote>:<container_name> <destination_remote>:<new_container_name>
    
  • Example:
    lxc copy local:pssb1alxc001 syhydsrv001:pssb1alxc002
    

2. Launching Containers from Remote Images

  • You can launch containers using images stored on a remote server:
    lxc launch <remote_name>:<image_alias> <container_name>
    
  • Example:
    lxc launch syhydsrv001:tech-stacked-pssb-image pssb1alxc003
    

3. Listing Containers on a Remote

  • To list all containers on a specific remote:
    lxc list <remote_name>:
    
  • Example:
    lxc list syhydsrv001:
    

4. Managing Snapshots Across Remotes

  • You can create, copy, and restore snapshots across remotes:
    • Create a snapshot:
      lxc snapshot <remote_name>:<container_name> <snapshot_name>
      
    • Copy a snapshot to another remote:
      lxc copy <source_remote>:<container_name>/<snapshot_name> <destination_remote>:<new_container_name>
      

5. Publishing Images to a Remote

  • You can publish a container or snapshot as an image on a remote server:
    lxc publish <remote_name>:<container_name> --alias <image_alias>
    
  • Example:
    lxc publish syhydsrv001:pssb1alxc001 --alias tech-stacked-pssb-image
    

6. Sharing Images Across Remotes

  • Once an image is published, you can use it on other remotes:
    lxc image copy <source_remote>:<image_alias> <destination_remote>: --copy-aliases
    
  • Example:
    lxc image copy syhydsrv001:tech-stacked-pssb-image local: --copy-aliases
    

7. Executing Commands on Remote Containers

  • You can execute commands directly on containers hosted on a remote server:
    lxc exec <remote_name>:<container_name> -- <command>
    
  • Example:
    lxc exec syhydsrv001:pssb1alxc001 -- apt update
    

8. Managing Storage Pools and Networks on Remotes

  • You can configure and manage storage pools and networks on remote servers:
    • List storage pools:
      lxc storage list <remote_name>:
      
    • List networks:
      lxc network list <remote_name>:
      

9. Deleting a Remote

  • If you no longer need a remote, you can remove it:
    lxc remote remove <remote_name>
    
  • Example:
    lxc remote remove syhydsrv001
    

Key Benefits of Using Remotes in LXD

  • Centralized Image Management: Share images across multiple LXD servers.
  • Workload Migration: Easily migrate containers between servers.
  • Collaboration: Allow teams to access shared resources on a central LXD server.
  • Scalability: Manage multiple LXD servers from a single client.

By following the steps above, you can configure and utilize remotes in LXD effectively. Let me know if you need further clarification or additional examples!

References