Container Redeploy Algorithm
The platform provides a quick and reliable container redeploy flow to update your applications based on the Docker containers to a new version (tag). Below, we’ll overview internal steps of the implementation:
1. A new container based on the redeployment target template is created. System files from this container will be used to update the original node, which is just about 300-600 MB of data to copy.
2. A list of paths to user data and some of the system-related files (iptables configuration, NFS service configuration, etc.) is gathered in the initial container.
3. A snapshot of the initial container is created via the ploop management utility.
Prior to this point, the initial container is unaffected yet. Afterward, the changes are applied to the snapshot, merging changes only in case all the configurations are successful. In other words, the platform creates a return point, allowing to discard changes and return to the initial state upon failure.
4. The initial container is stopped and its file system is mounted.
5. A temporary folder is created in the root of the mounted filesystem. Next, user data (from the second step) is moved under this directory and all other files are erased.
These operations are performed inside of a single filesystem and are relatively fast.
6. System files of the redeploy target template (from the first step) are copied into our mostly empty snapshot with just user data in the temporary folder. Next, container is initiated with the jem docker setup and jem docker aftercreate commands.
At this point, we have a clean working container based on the new Docker tag with user data in temporary directory.
7. Now, user data is restored to the original location, and the container is started via the jelinit process.
If everything is OK, the snapshot is merged, completing the redeployment process.