github.com/criteo/command-launcher@v0.0.0-20230407142452-fb616f546e98/gh-pages/content/en/docs/overview/enterprise.md (about)

     1  ---
     2  title: "Enterprise Setup Guide"
     3  description: "Setup command launcher for enterprise scenarios"
     4  lead: "Setup command launcher for enterprise scenarios"
     5  date: 2022-10-30T11:34:47+02:00
     6  lastmod: 2022-10-30T11:34:47+02:00
     7  draft: false
     8  images: []
     9  menu:
    10    docs:
    11      parent: "overview"
    12      identifier: "overview-enterprise-setup"
    13  weight: 245
    14  toc: true
    15  ---
    16  
    17  ## Setup remote configuration
    18  
    19  For enterprise use case, it is common to enforce some configurations for all users. For example, the remote registry to synchronise local commands. You can specify a remote configuration file using `COLA_REMOTE_CONFIG_URL` environment variable for this purpose.
    20  
    21  ```shell
    22  export COLA_REMOTE_CONFIG_URL=https://remote-server/remote-config.json
    23  ```
    24  
    25  The remote configuration is a JSON file contains the configuration items that you would like to enforce. Command launcher will override the local configuration item when the item is defined in the remote configuration.
    26  
    27  For example, you can setup `self_update_enabled` to `true` in the remote configuration file. This will ensure that all users get the latest version of command launcher automatically.
    28  
    29  ### Remote configuration synchronise cycle
    30  
    31  It is always nice to be able to change the configuration temporarily. Command launcher will check the remote configuration periodically. You can setup this check period from the configuration: `remote_config_check_cycle`.
    32  
    33  For example, the following configuration set up a 24-hour check period.
    34  
    35  ```json
    36  {
    37      ...
    38      "remote_config_check_cycle": 24,
    39      ...
    40  }
    41  ```
    42  
    43  > For the configuration items, which are missing from the remote configuration. The local value is always respected.
    44  
    45  ## Command auto-update: setup remote registry
    46  
    47  Another common use case for enterprise scenario is to ensure the same set and same version of commands available on a group of users. (For example, all engineers have the same version of build and test command).
    48  
    49  You can setup a remote package registry to list the available packages. Command launcher will synchronise with it at the end of each command call and make sure the local copy is synchronised with the remote package registry (always use the latest version available on the remote registry).
    50  
    51  Remote repository registry is a json file, which contains all available packages:
    52  
    53  The following example demonstrates a registry, which has three packages. Note that the package "hotfix" has two different versions, and the version `1.0.0-45149` targets to 30% of the user (partition 6, 7, and 8). More details about the partition see [Progressive Rollout](../provider-guide#progressive-rollout)
    54  
    55  ```json
    56  [
    57    {
    58      "name": "hotfix",
    59      "version": "1.0.0-44733",
    60      "checksum": "5f5f47e4966b984a4c7d33003dd2bbe8fff5d31bf2bee0c6db3add099e4542b3",
    61      "url": "https://the-url-of-the-env-package/any-name.zip",
    62      "startPartition": 0,
    63      "endPartition": 9
    64    },
    65    {
    66      "name": "hotfix",
    67      "version": "1.0.0-45149",
    68      "checksum": "773a919429e50346a7a002eb3ecbf2b48d058bae014df112119a67fc7d9a3598",
    69      "url": "https://the-url-of-the-env-package/hotfix-1.0.0-45149.zip",
    70      "startPartition": 6,
    71      "endPartition": 8
    72    },
    73    {
    74      "name": "env",
    75      "version": "0.0.1",
    76      "checksum": "c87a417cce3d26777bcc6b8b0dea2ec43a0d78486438b1bf3f3fbd2cafc2c7cc",
    77      "url": "https://the-url-of-the-env-package/package.zip",
    78      "startPartition": 0,
    79      "endPartition": 9
    80    }
    81  ]
    82  ```
    83  
    84  You can host this `index.json` file on an http server, for example: `https://my-company.com/cola-remote-registry/index.json`.
    85  
    86  To make command launcher be aware of the remote package registry, setup the configuration:
    87  
    88  ```shell
    89  cola config command_repository_base_url https://my-company.com/cola-remote-registry
    90  ```
    91  
    92  ## Use command launcher on CI
    93  
    94  Another use case of using command launcher is for Continuous Integration (CI). In this case, we would like to pin the version of command to have a deterministic behavior.
    95  
    96  Two configurations will help us achieve it: `ci_enabled` and `package_lock_file`.
    97  
    98  When enabled, the `ci_enabled` bool configuration tells command launcher to read a "lock" file to get the package version instead of using the latest one from remote registry. The lock file is specified in the `package_lock_file` configuration.
    99  
   100  When `ci_enabled` config set to `false`. The lock file is ignored by command launcher.
   101  
   102  ### Package lock JSON file
   103  
   104  Package lock file pins the package version in command launcher:
   105  
   106  ```json
   107  {
   108      "hotfix": "1.2.0",
   109      "infra-ops": "3.1.2",
   110      ...
   111  }
   112  ```
   113  
   114  The example above demonstrates a lock file, which pins the `hotfix` package version to `1.2.0`, and `infra-ops` package version to `3.1.2`
   115  
   116  > NOTE: please make sure the version pinned in lock file are available on the remote package registry.
   117  >
   118  > Partition will be ignored when the version is pinned in a lock file.
   119  
   120  ## Self Auto-update
   121  
   122  Command launcher looks for a version metadata endpoint to recognize its latest version, and download the binary follows a URL convention.
   123  
   124  The latest version endpoint is defined by `self_update_latest_version_url` configuration. It must return the latest command launcher version in JSON or YAML format:
   125  
   126  In JSON
   127  
   128  ```JSON
   129  {
   130      "version": "45861",
   131      "releaseNotes": "- feature 1\n-feature 2\nfeature 3",
   132      "startPartition": 0,
   133      "endPartition": 9
   134  }
   135  ```
   136  
   137  Or in YAML
   138  
   139  ```YAML
   140  version: "45861"
   141  releaseNotes: |
   142    * feature 1
   143    * feature 2
   144    * feature 3
   145  startPartition: 0
   146  endPartition: 9
   147  ```
   148  
   149  The binary download URL must follow the convention:
   150  
   151  ```text
   152  [SELF_UPDATE_BASE_URL]/{version}/{binaryName}_{OS}_{ARCH}_{version}{extension}
   153  ```
   154  
   155  The `[SELF_UPDATE_BASE_URL]` should be defined in `self_update_base_url` configuration. The latest `{version}` can be found in the version metadata from `self_update_latest_version_url` endpoint. `{binaryName}` is the short name when building command launcher (default `cola`). Pre-built `{OS}` and `{ARCH}` see following table:
   156  
   157  | OS      | Architecture | Pre-built  |
   158  |---------|--------------|------------|
   159  | windows | amd64        | yes        |
   160  | windows | arm64        | no         |
   161  | linux   | amd64        | yes        |
   162  | linux   | arm64        | no         |
   163  | darwin  | amd64        | yes        |
   164  | darwin  | arm64        | yes        |
   165  
   166  ## Custom command launcher with system package
   167  
   168  See [System Package](../system-package)