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

     1  # rkt configuration
     2  
     3  `rkt` reads configuration from two or three directories - a **system directory**, a **local directory** and, if provided, a **user directory**.
     4  The system directory defaults to `/usr/lib/rkt`, the local directory to `/etc/rkt`, and the user directory to an empty string.
     5  These locations can be changed with command line flags described below.
     6  
     7  The system directory should contain a configuration created by a vendor (e.g. distribution).
     8  The contents of this directory should not be modified - it is meant to be read only.
     9  
    10  The local directory keeps configuration local to the machine.
    11  It can be modified by the admin.
    12  
    13  The user directory may hold some user specific configuration.
    14  It may be useful for specifying credentials used for fetching images without spilling them to some directory readable by everyone.
    15  
    16  `rkt` looks for configuration files with the `.json` file name extension in subdirectories beneath the system and local directories.
    17  `rkt` does not recurse down the directory tree to search for these files.
    18  Users may therefore put additional appropriate files (e.g., documentation) alongside `rkt` configuration in these directories, provided such files are not named with the `.json` extension.
    19  
    20  Every configuration file has two common fields: `rktKind` and `rktVersion`.
    21  Both fields' values are strings, and the subsequent fields are specified by this pair.
    22  The currently supported kinds and versions are described below.
    23  These fields must be specified and cannot be empty.
    24  
    25  `rktKind` describes the type of the configuration.
    26  This is to avoid putting unrelated values into a single monolithic file.
    27  
    28  `rktVersion` allows configuration versioning for each kind of configuration.
    29  A new version should be introduced when doing some backward-incompatible changes: for example, when removing a field or incompatibly changing its semantics.
    30  When a new field is added, a default value should be specified for it, documented, and used when the field is absent in any configuration file.
    31  This way, an older version of `rkt` can work with newer-but-compatible versions of configuration files, and newer versions of `rkt` can still work with older versions of configuration files.
    32  
    33  Configuration values in the system directory are superseded by the value of the same field if it exists in the local directory.
    34  The same relationship exists between the local directory and the user directory if the user directory is provided.
    35  The semantics of overriding configuration in this manner are specific to the `kind` and `version` of the configuration, and are described below.
    36  File names are not examined in determining local overrides.
    37  Only the fields inside configuration files need to match.
    38  
    39  ## Command line flags
    40  
    41  To change the system configuration directory, use `--system-config` flag.
    42  To change the local configuration directory, use `--local-config` flag.
    43  To change the user configuration directory, use `--user-config` flag.
    44  
    45  ## Configuration kinds
    46  
    47  ### rktKind: `auth`
    48  
    49  The `auth` configuration kind is used to set up necessary credentials when downloading images and signatures.
    50  The configuration files should be placed inside the `auth.d` subdirectory (e.g., in the case of the default system/local directories, in `/usr/lib/rkt/auth.d` and/or `/etc/rkt/auth.d`).
    51  
    52  #### rktVersion: `v1`
    53  
    54  ##### Description and examples
    55  
    56  This version of the `auth` configuration specifies three additional fields: `domains`, `type` and `credentials`.
    57  
    58  The `domains` field is an array of strings describing hosts for which the following credentials should be used.
    59  Each entry must consist of a host/port combination in a URL as specified by RFC 3986.
    60  This field must be specified and cannot be empty.
    61  
    62  The `type` field describes the type of credentials to be sent.
    63  This field must be specified and cannot be empty.
    64  
    65  The `credentials` field is defined by the `type` field.
    66  It should hold all the data that are needed for successful authentication with the given hosts.
    67  
    68  This version of auth configuration supports three methods - basic HTTP authentication, OAuth Bearer Token, and AWS v4 authentication.
    69  
    70  Basic HTTP authentication requires two things - a user and a password.
    71  To use this type, define `type` as `basic` and the `credentials` field as a map with two keys - `user` and `password`.
    72  These fields must be specified and cannot be empty.
    73  For example:
    74  
    75  `/etc/rkt/auth.d/coreos-basic.json`:
    76  
    77  ```json
    78  {
    79  	"rktKind": "auth",
    80  	"rktVersion": "v1",
    81  	"domains": ["coreos.com", "tectonic.com"],
    82  	"type": "basic",
    83  	"credentials": {
    84  		"user": "foo",
    85  		"password": "bar"
    86  	}
    87  }
    88  ```
    89  
    90  OAuth Bearer Token authentication requires only a token.
    91  To use this type, define `type` as `oauth` and the `credentials` field as a map with only one key - `token`.
    92  This field must be specified and cannot be empty.
    93  For example:
    94  
    95  `/etc/rkt/auth.d/coreos-oauth.json`:
    96  
    97  ```json
    98  {
    99  	"rktKind": "auth",
   100  	"rktVersion": "v1",
   101  	"domains": ["coreos.com", "tectonic.com"],
   102  	"type": "oauth",
   103  	"credentials": {
   104  		"token": "sometoken"
   105  	}
   106  }
   107  ```
   108  
   109  AWS v4 authentication requires three things - an access key ID, a secret access key and an AWS region. If the region is left empty, it will be determined automatically from the URL/domain.
   110  To use this type, define `type` as `aws` and the `credentials` field as a map with two or three keys - `accessKeyID` and `secretAccessKey` are mandatory, whilst `awsRegion` is optional and can be left empty.
   111  For example:
   112  
   113  `/etc/rkt/auth.d/coreos-aws.json`:
   114  
   115  ```json
   116  {
   117  	"rktKind": "auth",
   118  	"rktVersion": "v1",
   119  	"domains": ["my-s3-bucket.s3.amazonaws.com"],
   120  	"type": "aws",
   121  	"credentials": {
   122  		"accessKeyID": "foo",
   123  		"secretAccessKey": "bar",
   124  		"awsRegion": "us-east-1"
   125  	}
   126  }
   127  ```
   128  
   129  ##### Override semantics
   130  
   131  Overriding is done for each domain.
   132  That means that the user can override authentication type and/or credentials used for each domain.
   133  As an example, consider this system configuration:
   134  
   135  `/usr/lib/rkt/auth.d/coreos.json`:
   136  
   137  ```json
   138  {
   139  	"rktKind": "auth",
   140  	"rktVersion": "v1",
   141  	"domains": ["coreos.com", "tectonic.com", "kubernetes.io"],
   142  	"type": "oauth",
   143  	"credentials": {
   144  		"token": "common-token"
   145  	}
   146  }
   147  ```
   148  
   149  If only this configuration file is provided, then when downloading data from either `coreos.com`, `tectonic.com` or `kubernetes.io`, `rkt` would send an HTTP header of: `Authorization: Bearer common-token`.
   150  
   151  But with additional configuration provided in the local configuration directory, this can be overridden.
   152  For example, given the above system configuration and the following local configuration:
   153  
   154  `/etc/rkt/auth.d/specific-coreos.json`:
   155  
   156  ```json
   157  {
   158  	"rktKind": "auth",
   159  	"rktVersion": "v1",
   160  	"domains": ["coreos.com"],
   161  	"type": "basic",
   162  	"credentials": {
   163  		"user": "foo",
   164  		"password": "bar"
   165  	}
   166  }
   167  ```
   168  
   169  `/etc/rkt/auth.d/specific-tectonic.json`:
   170  
   171  ```json
   172  {
   173  	"rktKind": "auth",
   174  	"rktVersion": "v1",
   175  	"domains": ["tectonic.com"],
   176  	"type": "oauth",
   177  	"credentials": {
   178  		"token": "tectonic-token"
   179  	}
   180  }
   181  ```
   182  
   183  The result is that when downloading data from `kubernetes.io`, `rkt` still sends `Authorization: Bearer common-token`, but when downloading from `coreos.com`, it sends `Authorization: Basic Zm9vOmJhcg==` (i.e. `foo:bar` encoded in base64).
   184  For `tectonic.com`, it will send `Authorization: Bearer tectonic-token`.
   185  
   186  Note that _within_ a particular configuration directory (either system or local), it is a syntax error for the same domain to be defined in multiple files.
   187  
   188  ##### Command line flags
   189  
   190  There are no command line flags for specifying or overriding the auth configuration.
   191  
   192  ### rktKind: `dockerAuth`
   193  
   194  The `dockerAuth` configuration kind is used to set up necessary credentials when downloading data from Docker registries.
   195  The configuration files should be placed inside `auth.d` subdirectory (e.g. in `/usr/lib/rkt/auth.d` or `/etc/rkt/auth.d`).
   196  
   197  #### rktVersion: `v1`
   198  
   199  ##### Description and examples
   200  
   201  This version of `dockerAuth` configuration specifies two additional fields: `registries` and `credentials`.
   202  
   203  The `registries` field is an array of strings describing Docker registries for which the associated credentials should be used.
   204  This field must be specified and cannot be empty.
   205  A short list of popular Docker registries is given below.
   206  
   207  The `credentials` field holds the necessary data to authenticate against the Docker registry.
   208  This field must be specified and cannot be empty.
   209  
   210  Currently, Docker registries only support basic HTTP authentication, so `credentials` has two subfields - `user` and `password`. These fields must be specified and cannot be empty. For registries like [AWS ECR](https://aws.amazon.com/ecr/) tools may be used to obtain credentials and registry endpoints. For example, use `aws ecr get-login` to fetch login credentials when using AWS. Please keep in mind that when using ECR the credentials will expire and will need to be refreshed.
   211  
   212  Some popular Docker registries:
   213  
   214  * registry-1.docker.io (Assumed as the default when no specific registry is named on the rkt command line, as in `docker:///redis`.)
   215  * quay.io
   216  * gcr.io
   217  * `<aws_account_id>`.dkr.ecr.`<region>`.amazonaws.com (AWS ECR)
   218  
   219  Example `dockerAuth` configuration:
   220  
   221  `/etc/rkt/auth.d/docker.json`:
   222  
   223  ```json
   224  {
   225  	"rktKind": "dockerAuth",
   226  	"rktVersion": "v1",
   227  	"registries": ["registry-1.docker.io", "quay.io"],
   228  	"credentials": {
   229  		"user": "foo",
   230  		"password": "bar"
   231  	}
   232  }
   233  ```
   234  
   235  ##### Override semantics
   236  
   237  Overriding is done for each registry.
   238  That means that the user can override credentials used for each registry.
   239  For example, given this system configuration:
   240  
   241  `/usr/lib/rkt/auth.d/docker.json`:
   242  
   243  ```json
   244  {
   245  	"rktKind": "dockerAuth",
   246  	"rktVersion": "v1",
   247  	"registries": ["registry-1.docker.io", "gcr.io", "quay.io"],
   248  	"credentials": {
   249  		"user": "foo",
   250  		"password": "bar"
   251  	}
   252  }
   253  ```
   254  
   255  If only this configuration file is provided, then when downloading images from either `registry-1.docker.io`, `gcr.io`, or `quay.io`, `rkt` would use user `foo` and password `bar`.
   256  
   257  But with additional configuration provided in the local configuration directory, this can be overridden.
   258  For example, given the above system configuration and the following local configuration:
   259  
   260  `/etc/rkt/auth.d/specific-quay.json`:
   261  
   262  ```json
   263  {
   264  	"rktKind": "dockerAuth",
   265  	"rktVersion": "v1",
   266  	"registries": ["quay.io"],
   267  	"credentials": {
   268  		"user": "baz",
   269  		"password": "quux"
   270  	}
   271  }
   272  ```
   273  
   274  `/etc/rkt/auth.d/specific-gcr.json`:
   275  
   276  ```json
   277  {
   278  	"rktKind": "dockerAuth",
   279  	"rktVersion": "v1",
   280  	"registries": ["gcr.io"],
   281  	"credentials": {
   282  		"user": "goo",
   283  		"password": "gle"
   284  	}
   285  }
   286  ```
   287  
   288  The result is that when downloading images from `registry-1.docker.io`, `rkt` still sends user `foo` and password `bar`, but when downloading from `quay.io`, it uses user `baz` and password `quux`; and for `gcr.io` it will use user `goo` and password `gle`.
   289  
   290  Note that _within_ a particular configuration directory (either system or local), it is a syntax error for the same Docker registry to be defined in multiple files.
   291  
   292  ##### Command line flags
   293  
   294  There are no command line flags for specifying or overriding the docker auth configuration.
   295  
   296  ### rktKind: `paths`
   297  
   298  The `paths` configuration kind is used to customize the various paths that rkt uses.
   299  The configuration files should be placed inside the `paths.d` subdirectory (e.g., in the case of the default system/local directories, in `/usr/lib/rkt/paths.d` and/or `/etc/rkt/paths.d`).
   300  
   301  #### rktVersion: `v1`
   302  
   303  ##### Description and examples
   304  
   305  This version of the `paths` configuration specifies two additional fields: `data` and `stage1-images`.
   306  
   307  The `data` field is a string that defines where image data and running pods are stored.
   308  This field is optional.
   309  
   310  The `stage1-images` field is a string that defines where are the stage1 images are stored, so rkt can search for them when using the `--stage1-from-dir` flag.
   311  This field is optional.
   312  
   313  Example `paths` configuration:
   314  
   315  `/etc/rkt/paths.d/paths.json`:
   316  
   317  ```json
   318  {
   319  	"rktKind": "paths",
   320  	"rktVersion": "v1",
   321  	"data": "/home/me/rkt/data",
   322  	"stage1-images": "/home/me/rkt/stage1-images"
   323  }
   324  ```
   325  
   326  ##### Override semantics
   327  
   328  Overriding is done for each path.
   329  For example, given this system configuration:
   330  
   331  `/usr/lib/rkt/paths.d/data.json`:
   332  
   333  ```json
   334  {
   335  	"rktKind": "paths",
   336  	"rktVersion": "v1",
   337  	"data": "/opt/rkt-stuff/data"
   338  }
   339  ```
   340  
   341  If only this configuration file is provided, then rkt will store images and pods in the `/opt/rkt-stuff/data` directory.
   342  Also, when user passes `--stage1-from-dir=stage1.aci` to rkt, rkt will search for this file in the directory specified at build time (usually `/usr/lib/rkt/stage1-images`).
   343  
   344  But with additional configuration provided in the local configuration directory, this can be overridden.
   345  For example, given the above system configuration and the following local configuration:
   346  
   347  `/etc/rkt/paths.d/paths.json`:
   348  
   349  ```json
   350  {
   351  	"rktKind": "paths",
   352  	"rktVersion": "v1",
   353  	"data": "/home/me/rkt"
   354  }
   355  ```
   356  
   357  Now rkt will store the images and pods in the `/home/me/rkt` directory.
   358  It will not know about any other data directory.
   359  Also, rkt will still search for the stage1 images in the directory specified at build time for the `--stage1-from-dir` flag.
   360  
   361  To override the stage1 images directory:
   362  
   363  `/etc/rkt/paths.d/stage1.json`:
   364  
   365  ```json
   366  {
   367  	"rktKind": "paths",
   368  	"rktVersion": "v1",
   369  	"stage1-images": "/home/me/stage1-images"
   370  }
   371  ```
   372  
   373  Now rkt will search in the `/home/me/stage1/images` directory, not in the directory specified at build time.
   374  
   375  ##### Command line flags
   376  
   377  The `data` field can be overridden with the `--dir` flag.
   378  The `stage1-images` field cannot be overridden with a command line flag.
   379  
   380  ### rktKind: `stage1`
   381  
   382  The `stage1` configuration kind is used to set up a default stage1 image.
   383  The configuration files should be placed inside the `stage1.d` subdirectory (e.g., in the case of the default system/local directories, in `/usr/lib/rkt/stage1.d` and/or `/etc/rkt/stage1.d`).
   384  
   385  #### rktVersion: `v1`
   386  
   387  ##### Description and examples
   388  
   389  This version of the `stage1` configuration specifies three additional fields: `name`, `version` and `location`.
   390  
   391  The `name` field is a string specifying a name of a default stage1 image.
   392  This field is optional.
   393  If specified, the `version` field must be specified too.
   394  
   395  The `version` field is a string specifying a version of a default stage1 image.
   396  This field is optional.
   397  If specified, the `name` field must be specified too.
   398  
   399  The `location` field is a string describing the location of a stage1 image file.
   400  This field is optional.
   401  
   402  The `name` and `version` fields are used by `rkt` (unless overridden with a run-time flag or left empty) to search for the stage1 image in the image store.
   403  If it is not found there then `rkt` will use a value from the `location` field (again, unless overridden or empty) to fetch the stage1 image.
   404  
   405  If the `name`, `version` and `location` fields are specified then it is expected that the file in `location` is a stage1 image with the same name and version in manifest as values of the `name` and `version` fields, respectively.
   406  Note that this is not enforced in any way.
   407  
   408  The `location` field can be:
   409  
   410  - a `file://` URL
   411  - a `http://` URL
   412  - a `https://` URL
   413  - a `docker://` URL
   414  - an absolute path (basically the same as a `file://` URL)
   415  
   416  An example:
   417  
   418  ```json
   419  {
   420  	"rktKind": "stage1",
   421  	"rktVersion": "v1",
   422  	"name": "example.com/rkt/stage1",
   423  	"version": "1.2.3",
   424  	"location": "https://example.com/download/stage1-1.2.3.aci"
   425  }
   426  ```
   427  
   428  ##### Override semantics
   429  
   430  Overriding is done separately for the name-and-version pairs and for the locations.
   431  That means that the user can override either both a name and a version or a location.
   432  As an example, consider this system configuration:
   433  
   434  `/usr/lib/rkt/stage1.d/coreos.json`:
   435  
   436  ```json
   437  {
   438  	"rktKind": "stage1",
   439  	"rktVersion": "v1",
   440  	"name": "coreos.com/rkt/stage1-coreos",
   441  	"version": "0.15.0+git",
   442  	"location": "/usr/libexec/rkt/stage1-coreos.aci"
   443  }
   444  ```
   445  
   446  If only this configuration file is provided then `rkt` will check if `coreos.com/rkt/stage1-coreos` with version `0.15.0+git` is in image store.
   447  If it is absent then it would fetch it from `/usr/libexec/rkt/stage1-coreos.aci`.
   448  
   449  But with additional configuration provided in the local configuration directory, this can be overridden.
   450  For example, given the above system configuration and the following local configurations:
   451  
   452  `/etc/rkt/stage1.d/specific-coreos.json`:
   453  
   454  ```json
   455  {
   456  	"rktKind": "stage1",
   457  	"rktVersion": "v1",
   458  	"location": "https://example.com/coreos-stage1.aci"
   459  }
   460  ```
   461  
   462  The result is that `rkt` will still look for `coreos.com/rkt/stage1-coreos` with version `0.15.0+git` in the image store, but if it is not found, it will fetch it from `https://example.com/coreos-stage1.aci`.
   463  
   464  To continue the example, we can also override name and version with an additional configuration file like this:
   465  
   466  `/etc/rkt/stage1.d/other-name-and-version.json`:
   467  
   468  ```json
   469  {
   470  	"rktKind": "stage1",
   471  	"rktVersion": "v1",
   472  	"name": "example.com/rkt/stage1",
   473  	"version": "1.2.3"
   474  }
   475  ```
   476  
   477  Now `rkt` will search for `example.com/rkt/stage1` with version `1.2.3` in the image store before trying to fetch the image from `https://example.com/coreos-stage1.aci`.
   478  
   479  Note that _within_ a particular configuration directory (either system or local), it is a syntax error for the name, version or location to be defined in multiple files.
   480  
   481  ##### Command line flags
   482  
   483  The `name`, `version` and `location` fields are ignored in favor of a value coming from `--stage1-url`, `--stage1-path`, `--stage1-name`, `--stage1-hash`, or `--stage1-from-dir` flags.