github.com/rkt/rkt@v1.30.1-0.20200224141603-171c416fac02/Documentation/pod-manifest.md (about)

     1  # Pod manifest walkthrough
     2  
     3  The flag `--pod-manifest` can be passed to rkt's [run][run] and [prepare][prepare] subcommands.
     4  It allows users to specify a *[runtime manifest][runtime-manifest]* to run as a pod.
     5  A pod manifest completely specifies how the pod will be run, **overriding** any configuration present in the individual images of the apps in the pod.
     6  
     7  Thus, by encoding how a rkt pod should be executed in a file, it can then be saved in version control and users don't need to deal with very long CLI arguments everytime they want to run a complicated pod.
     8  
     9  ## Generating a pod manifest
    10  
    11  The most convenient way to generate a pod manifest is running a pod by using the rkt CLI (without `--pod-manifest`), exporting the resulting pod manifest, and then tweaking it until satisfied with it.
    12  
    13  For example:
    14  
    15  ```bash
    16  $ sudo rkt run coreos.com/etcd:v2.0.10 --- kinvolk.io/aci/busybox:1.24 -- -c 'while true; do date; sleep 1; done'
    17  ...
    18  ^]^]Container rkt-07f1cfdc-950b-4b6e-a2c0-8fb1ed37f98b terminated by signal KILL.
    19  $ rkt cat-manifest 07f1cfdc > pod-manifest.json
    20  ```
    21  
    22  The resulting pod manifest file is:
    23  
    24  ```json
    25  {
    26  	"acVersion": "1.30.0",
    27  	"acKind": "PodManifest",
    28  	"apps": [
    29  		{
    30  			"name": "etcd",
    31  			"image": {
    32  				"name": "coreos.com/etcd",
    33  				"id": "sha512-c03b055d02e51e36f44a2be436eb77d5b0fbbbe37c00851188d8798912e8508a",
    34  				"labels": [
    35  					{
    36  						"name": "os",
    37  						"value": "linux"
    38  					},
    39  					{
    40  						"name": "arch",
    41  						"value": "amd64"
    42  					},
    43  					{
    44  						"name": "version",
    45  						"value": "v2.0.10"
    46  					}
    47  				]
    48  			},
    49  			"app": {
    50  				"exec": [
    51  					"/etcd"
    52  				],
    53  				"user": "0",
    54  				"group": "0"
    55  			}
    56  		},
    57  		{
    58  			"name": "busybox",
    59  			"image": {
    60  				"name": "kinvolk.io/aci/busybox",
    61  				"id": "sha512-140375b2a2bd836559a7c978f36762b75b80a7665e5d922db055d1792d6a4182",
    62  				"labels": [
    63  					{
    64  						"name": "version",
    65  						"value": "1.24"
    66  					},
    67  					{
    68  						"name": "os",
    69  						"value": "linux"
    70  					},
    71  					{
    72  						"name": "arch",
    73  						"value": "amd64"
    74  					}
    75  				]
    76  			},
    77  			"app": {
    78  				"exec": [
    79  					"sh",
    80  					"-c",
    81  					"while true; do date; sleep 1; done"
    82  				],
    83  				"user": "0",
    84  				"group": "0",
    85  				"ports": [
    86  					{
    87  						"name": "nc",
    88  						"protocol": "tcp",
    89  						"port": 1024,
    90  						"count": 1,
    91  						"socketActivated": false
    92  					}
    93  				]
    94  			}
    95  		}
    96  	],
    97  	"volumes": null,
    98  	"isolators": null,
    99  	"annotations": [
   100  		{
   101  			"name": "coreos.com/rkt/stage1/mutable",
   102  			"value": "false"
   103  		}
   104  	],
   105  	"ports": []
   106  }
   107  ```
   108  
   109  From there, you can edit the pod manifest following its [schema][pod-manifest-schema].
   110  
   111  For example, we can add a memory isolator to etcd:
   112  
   113  ```json
   114  ...
   115  				"exec": [
   116  					"/etcd"
   117  				],
   118  				"isolators": [
   119  					{
   120  						"name": "resource/memory",
   121  						"value": {"limit": "1G"}
   122  					}
   123  				],
   124  ...
   125  ```
   126  
   127  Then, we can just run rkt with that pod manifest:
   128  
   129  ```
   130  $ sudo rkt run --pod-manifest=pod-manifest.json
   131  ...
   132  ```
   133  
   134  **Note** Images used by a pod manifest must be store in the local store, `--pod-manifest` won't do discovery or fetching.
   135  
   136  Another option is running rkt with different CLI arguments until we have a configuration we like, and then just save the resulting pod manifest to use it later.
   137  
   138  [run]: subcommands/run.md
   139  [prepare]: subcommands/prepare.md
   140  [runtime-manifest]: https://github.com/appc/spec/blob/v0.8.11/spec/pods.md#app-container-pods-pods
   141  [pod-manifest-schema]: https://github.com/appc/spec/blob/v0.8.11/spec/pods.md#pod-manifest-schema