Skip to content
Snippets Groups Projects
lxc_migration.md 3.52 KiB
Newer Older
  • Learn to ignore specific revisions
  • # LXC Based container migration
    SWMODD in release-6.5 branch based releases only has support for LXC based containers, but in devel now it has support support for OCI based containers and LXC based containers both.
    
    OCI based containers being preferred option for LCM in devel. This document aims to provide guidance for migrating LXC containers from release-6.5 to devel.
    
    ## Bit inside on lxc container handling
    1. LXC build root defined in '/etc/lxc/lxc.conf' with "lxc.lxcpath" option
    2. Each LXC container mapped to 'Device.SoftwareModules.ExecEnv.' datamodel parameter
    3. Additional Installed DU's installed in a container stored in `/etc/swmod/map_du_<container_name>` file
    
    ```bash
    config deployment
            option name 'bbk_cli'
            option version '7b810a69'
            option uuid '477a210f-9ed1-401a-b028-717a726e5296'
            option duid '9zz0000'
            option environment 'test'
            option eeid '1'
            list service 'bbk_cli'
            option description 'To measure connection speed in an environment that is missing a web browser, '
    ```
    
    4. Auto-start of LXC based containers managed with the help of `lxc-auto` package and is stored in `/etc/config/lxcauto` file
    5. LXC based container configuration stored in a `config` file inside build root path
    
    So, the information is bit scattered and had too many dependencies on external modules, also some information does not persists across factory reset.
    
    ## Bit inside on devel changes
    1. Defining the bundle root now moved to swmodd uci (In deployment, its a best practice use a non-root persistent storage path for this option)
    
    ```bash
    config globals 'globals'
            option lxc_bundle_root '/mnt/container/'
            option oci_bundle_root '/mnt/container/'
    ```
    
    - But it still has preference on `lxc.conf` configuration, it works like
      - If lxcpath is set in /etc/config/swmodd then swmodd configures the same in lxc.conf through uci-default script
      - If not defined in /etc/config/swmodd but lxcpath is present in lxc.conf then uci-default script writes the lxc_bundle_root with the same in swmodd uci
      - If not defined in /etc/config/swmodd and also in lxc.conf then uci-default set it with "/srv/" in both lxc.conf and /etc/config/swmodd
    
    2. LXC containers still mapped to `Device.SoftwareModules.ExecEnv.`, but it start with instance id 2
    3. `Device.SoftwareModules.ExecEnv.1` mapped to system and used for OCI based containers
    4. OCI containers mapped to `Device.SoftwareModules.DeploymentUnits.`
    5. To make the LXC and OCI containers information persistent across factory reset, now its stored in lxc_bundle_root path in "lxccontainer" (for lxc info) file.
    6. auto-boot dependency now moved to swmodd it self based on mappings present in "lxccontainer" uci file.
    
    ```bash
    config container
    	option name '<container_name>'
    	option type 'lxc'
       	option autostart '1'
    ```
    
    7. All DU and EU details are stored in lxccontainer uci file as well for LXC based containers
    
    ## Migration notes
    1. lxc-auto must not be present as now lxc containers handled by swmodd itself.
    2. uci-default script '02-migrate-lxc' added to migrate the lxcauto to new uci file
    
    
    ## Summary
    Moving forward lxc based container will be deprecated, so its good to update the lxc/config to oci/config.json, so that the lxc container can be run as oci containers.
    
    - [OCI runtime specs](https://github.com/opencontainers/runtime-spec/blob/main/config.md)
    - [LXC runtime specs](https://linuxcontainers.org/lxc/manpages/man5/lxc.container.conf.5.html)
    - [LXC config manpages](https://manpages.ubuntu.com/manpages/trusty/man5/lxc.container.conf.5.html)