Skip to content

Commit ab0284c

Browse files
Merge pull request sonic-net#64 from Kalimuthu-Velappan/master
Updated TPCM document
2 parents 830624f + ed88128 commit ab0284c

File tree

1 file changed

+84
-35
lines changed

1 file changed

+84
-35
lines changed

system/tpcm.md

+84-35
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ This document describes the high level design details of Third Party Container M
6767

6868
# Requirements Overview
6969

70-
This document describes mechanisms for Third Party Container Management(TPCM) in the SONiC environment. The TPCM allows the user to Install and Manage the custom container into the SONiC.
70+
This document describes mechanisms for Third Party Container Management(TPCM) in the SONiC environment. The TPCM allows the user to Install and Manage the TPC docker into the SONiC.
7171

7272
SONiC is a network operating system based on the Debian distribution. The SONiC components are tightly integrated with the installation image that are created during the build time itself. It allows the user to install the additional tools from the standard Debian repo, but any addition of new components to the SONiC system requires the rebuilding of the SONiC binary image. This feature allows user to install the third party components in the form of containers and that can be loaded and integrated as part of the SONiC system independently without rebuilding of SONiC image.
7373

@@ -174,6 +174,7 @@ By default, for each TPC docker, the CPU resource limit is restricted to 20%. Me
174174
- SFTP SERVER - Copied from a remote server through sftp protcol.
175175
- MEDIA PATH - Copied from a local media folder.
176176
- DOCKER HUB - Downloaded from remote Docker registry.
177+
- LOCAL IMAGE - Use one of the existing docker image.
177178

178179
- One or more TPC images can be installed on the SONiC system. Once the SONiC OS is up, the TPC instance can be brought up into SONiC by running tpcm install command.
179180

@@ -197,7 +198,7 @@ By default, for each TPC docker, the CPU resource limit is restricted to 20%. Me
197198

198199
- Example:
199200
200-
tpcm uninstall \<tpc-name\> -y
201+
tpcm uninstall <tpc-name> -y
201202
202203
- During the uninstallation process, the following steps get executed.
203204

@@ -222,92 +223,137 @@ By default, for each TPC docker, the CPU resource limit is restricted to 20%. Me
222223
223224
## TPC Docker Upgrade
224225

225-
- The TPCM framework allows the user to upgrade the running TPC Dockers. The tcpm framework upgrade option allows the user to upgrade an existing TPC docker with a new one. During the upgrade process, TPCM provides the interface to run the pre/post script of a container if it is present inside the TPC container. These hook allows the user to take the backup of data from existing container and restore it back to the upgraded Docker. The pre hook is executed as part of running container and the post hook is executed as part of the upgraded container. The hook scripts should be placed in a fixed folder in the TPC container with the name as /tpc/hook/pre.sh' and 'tpc/hook/post.sh'. The pre script should create a backup file with the name as '/tpc/backup/data.tar.gz' and the post script should restore the contents from the data file. For each TPC, the volume '/tpc/' is mounted from host partition '/host/tpc/\<tpc-name\>'.
226+
- The TPCM framework allows the user to upgrade the running TPC Dockers. The tcpm framework upgrade option allows the user to upgrade an existing TPC docker with a new one. During the upgrade process, TPCM provides the interface to run the pre/post script present in the container. These hook allow the user to take the backup of data from existing TPC container and restore it back into the upgraded TPC Docker. Each TPC is provided with private data volume for storing the container data which will presist across docker upgrade. The pre/post hook is an optional script that should be added by the user and it will be based on the user needs on what data to be backed up during the upgrade. If all the TPC's data is already stored on the private volume or user doesnt want to take data backup during upgrade then this script is optional.
227+
228+
- The pre hook is executed as part of running container and the post hook is executed as part of the upgraded container.
229+
- These scripts are optional and it get executed only if it is present in the container. It skips the script execution if it is not present.
230+
- Two level of hook script is supported.
231+
1. Internal hook scripts
232+
- These scripts are prepared by the user and it should come along with the container.
233+
- The internal hook scripts should be placed in a fixed folder in the TPC container with the name as /tpc/scripts/pre.sh' and '/tpc/scripts/post.sh'.
234+
- These scriptes get executed only if it is present inside the container.
235+
236+
2. External hook scripts
237+
- These scripts are prepared by the user and stored in the host folder and volume mount into TPC.
238+
- It will presist across TPC upgrade.
239+
- It should be placed in a fixed folder in the Host with the name as /tpcm/tpc/<tpc-name>/pdata/scripts/pre.sh' and '/tpcm/tpc/<tpc-name>/pdata/scripts/post.sh'.
240+
- As part of volume mount, it automatically get mapped into the TPC with the name as /tpc/pdata/scripts/pre.sh' and '/tpc/pdata/scripts/post.sh'.
241+
- The pre script should create a backup data file and store them into '/tpc/pdata/' folder inside the container, and the post script should restore the contents from the data file.
242+
- For each TPC, a private volume '/tpc/pdata' is mounted from host partition '/tpcm/tpc/\<tpc-name\>' for saving the data across TPC upgrade.
226243

227244
- Example:
228245

229-
# tpcm upgrade \<tpc-name\> \<tpc-image source\> -y
246+
# tpcm upgrade name <tpc-name> <tpc-image source> -y
230247

231-
- It executes the following sequence to upgrade the running Docker.
232-
1. Run the TPC pre hook script
233-
3. It stops the already running TPC container
234-
4. Remove the existing TPC container
248+
- It executes the following sequence to upgrade the running TPC Docker.
249+
1. Run the TPC internal pre hook script.
250+
2. Run the TPC external pre hook script.
251+
3. It stops the already running TPC container.
252+
4. Remove the existing TPC container.
235253
5. Loads the new TPC image into the Docker image list.
236-
6. Create the new TPC container from newly loaded TPC image
237-
7. Run the newly created container
238-
8. Execute the TPC post script
239-
9. Remove the old TPC image.
254+
6. Create the new TPC container from newly loaded TPC image.
255+
7. Run the newly created container.
256+
8. Execute the TPC external post script.
257+
9. Execute the TPC internal post script.
258+
10. Remove the old TPC image.
259+
260+
- During the TPC upgrade if any these operation fails, it will rollback to old container.
261+
240262

241263
# CLI:
242264

243265
## 1. Installing the TPC image
244266

245-
TPC image can be loaded and installed in two forms:
267+
TPC image can be loaded and installed in three forms:
246268

247269
#### TPC image from a file:
248270
It uses the download protocol to download the TPC image into a temporary path and then that gets loaded into Docker image filesystem.
249271
1. Load the TPC image file from a external http/https server
250272

251273
- Syntax:
252-
#### tpcm install name \<tpc-container-name\> [--args \<container args\>] \<URL\> [-y]
274+
#### tpcm install name <tpc-container-name> url <URL> [-y] [--args <container args>]
253275
where:
254-
\<tpc-container-name\> => Name of the TPC container to be loaded.
255-
--args => It specifies the additional container creation parameters.
256-
\<URL\> => It is http/https web url from which the TPC image can be downloaded.
276+
<tpc-container-name> => Name of the TPC container to be loaded.
277+
<URL> => It is http/https web url from which the TPC image can be downloaded.
257278
[-y] => User confirmation
279+
--args => It specifies the additional container parameters.
258280
- Example:
259-
tpcm install name mydocker http://myserver/path/mydocker.tar.gz -y
281+
tpcm install name mydocker url http://myserver/path/mydocker.tar.gz -y
260282

261283
2. Load the image file from a external server through scp/sftp
262284

263285
- Syntax:
264-
#### tpcm install name \<tpc-container-name\> --protocol \<scp/sftp\> --server \<server name\> --username \<username\> [--password \<password\>] \<TPC image path\> [--args \<container args\>] [-y]
286+
#### tpcm install name <tpc-container-name> scp <server name> --username <username> [--password <password>] --filename <TPC image path> [-y] [--args <container args>]
287+
#### tpcm install name <tpc-container-name> sftp <server name> --username <username> [--password <password>] --filename <TPC image path> [-y] [--args <container args>]
265288
where:
266-
\<tpc-container-name\> => Name of the TPC container to be loaded.
267-
--protocol => It specifies the protocol through which it downloads the image and it can be either scp or sftp.
268-
--server => Specifies the remote server name from which image is being download.
289+
<tpc-container-name> => Name of the TPC container to be loaded.
290+
<server name> => Specifies the remote server name from which image is being download.
269291
--username => Specifies the remote server user credentials.
270292
--password => Specifies the remote server user's password. If passwd is not given, prompted passwd for during the image download.
271-
--args => It specifies the additional container creation parameters.
272-
\<TPC image path\> => Path on the remote server where the TPC image is located.
293+
--filename => Path on the remote server where the TPC image is located.
273294
[-y] => User confirmation
295+
--args => It specifies the additional container parameters.
274296
- Example:
275297

276-
tpcm install name mydocker --protocol scp --server myserver --username myuser /path/mydocker.tar.gz -y
298+
tpcm install name mydocker scp myserver --username myuser --filename /path/mydocker.tar.gz -y
277299
Password:
278300

279301
3. Load the image file from a local media path
280302
- Syntax:
281-
#### tpcm install name \<tpc-container-name\> \<TPC image path\> [--args \<container args\>] [-y]
303+
#### tpcm install name <tpc-container-name> file <TPC image path> [-y] [--args <container args>]
282304
where:
283-
\<TPC image path\> => Local media path where the TPC image is located.
284-
--args => It specifies the additional container creation parameters.
305+
<TPC image path> => Local media path where the TPC image is located.
285306
[-y] => User confirmation
307+
--args => It specifies the additional container parameters.
286308
- Example:
287309

288-
tpcm install name mydocker /media/usb/path/mydocker.tar.gz -y
310+
tpcm install name mydocker file /media/usb/path/mydocker.tar.gz -y
289311

290312
291313
#### Load the TPC image from a external Docker repo
292314
It loads the TPC image directly from external Docker registry into local Docker image filesystem.
293315

294316
- Syntax:
295-
#### tpcm install name \<tpc-container-name\> \<Image name\>[:\<Tagname\>] [--args \<container args\>] [-y]
317+
#### tpcm install name <tpc-container-name> pull <Image name>[:<Tagname>] [-y] [--args <container args>]
296318

297319
- where
298-
\<tpc-container-name\> => Name of the TPC container to be loaded.
299-
\<Image name\> => Name of the image to be downloaded.
320+
<tpc-container-name> => Name of the TPC container to be loaded.
321+
<Image name> => Name of the image to be downloaded.
300322
[Tagname] => Optional, Tagname of the image, by default 'latest' would be taken.
301-
--args => It specifies the additional container creation parameters.
302323
[-y] => User confirmation
324+
--args => It specifies the additional container parameters.
325+
- Example:
326+
327+
tpcm install name mydocker pull ubuntu:latest -y
328+
329+
#### Use one of the existing docker image
330+
It uses one of the exising docker images installed in the system. It simply creates the service file and takes care of TPC and migration feature across the image upgrade. This allows the user to use the regular docker commands to create the TPC images. Once the image is ready, user can associate TPCM management feature to it.
331+
332+
- Syntax:
333+
#### tpcm install name <tpc-container-name> image <Image name>[:<Tagname>] [-y] [--args <container args>]
334+
335+
- where
336+
<tpc-container-name> => Name of the TPC container to be created.
337+
<Image name> => Name of the docker image in the local system.
338+
Tagname => Optional, Tagname of the image, by default 'latest' would be taken.
339+
[-y] => User confirmation
340+
--args => It specifies the additional container parameters.
341+
342+
- Example:
343+
344+
tpcm install name mydocker image ubuntu:latest -y
303345

304346
## 2. Uninstalling the TPC image
305347

306-
#### tpcm uninstall name \<container-name\> [-y]
348+
#### tpcm uninstall name \<container-name\> [-y] [--clean_data]
307349

308350
- where
309351
\<tpc-container-name\> => Name of the TPC container to be removed.
352+
--clean_data => It removes all the container specific data which includes config file, service file and container private data.
310353
[-y] => User confirmation
354+
- Example:
355+
356+
tpcm uninstall name mydocker -y
311357

312358
## 3. Upgrading the TPC image
313359

@@ -316,6 +362,9 @@ By default, for each TPC docker, the CPU resource limit is restricted to 20%. Me
316362
- where
317363
--skip_data_migration => If yes, container data is not migrated or retained, else data is migrated and retained.
318364
All other options are same as install command.
365+
- Example:
366+
367+
tpcm upgrade name mydocker image ubuntu:latest -y
319368

320369

321370
## 4. List the TPC images
@@ -475,7 +524,7 @@ By default, for each TPC docker, the CPU resource limit is restricted to 20%. Me
475524
1. All Dockers in SONiC run on host IP stack (Default VRF)
476525
2. There is no option to run specific Dockers under Management VRF
477526
3. The following ip rule should be added to allow access to ‘eth0’ for all Dockers
478-
# sudo ip rule add pref 32768 from all lookup mgmt
527+
### sudo ip rule add pref 32768 from all lookup mgmt
479528

480529

481530
## SONiC image NetInstall

0 commit comments

Comments
 (0)