# Manage virtual machines with VM Service

VM service controls how [`machine`](https://circleci.com/docs/reference/configuration-reference/#machine) executor and [Remote Docker](https://circleci.com/docs/guides/execution-managed/building-docker-images/) jobs are run.

This section describes the available configuration options for VM service. Refer to the default `values.yaml` file for details on how to pre-scale virtual machines.

We recommend that you leave these options at their defaults until you have successfully configured and verified the core and build services of your server installation. Steps to set up VM service are provided in the installation guide for [AWS](https://circleci.com/docs/server-admin/server-4.2/installation/phase-3-execution-environments/#aws-vm-service) and [GCP](https://circleci.com/docs/server-admin/server-4.2/installation/phase-3-execution-environments/#gcp-authentication).

## VM provider

The following configuration options are for the VM provider: either AWS or GCP.

### AWS

Configure VM Service to work with AWS EC2 in your `values.yml`. During installation you will have set up a security group and authentication. See the [Installation Phase 3 - Execution Environments](https://circleci.com/docs/server-admin/server-4.2/installation/phase-3-execution-environments/#aws-vm-service) page for more information.

The information in this section describes post-installation configuration options for VM service.

#### Windows image

If you require Windows executors, you can supply an AMI ID in your `values.yaml` file. To create a Windows image, use the [CircleCI server Windows image builder](https://github.com/CircleCI-Public/circleci-server-windows-image-builder).

`````````
vm_service:
  providers:
    ec2:
      ...
      windowsAMI: "<my-windows-ami>"
`````````

#### Alternative Linux VM image

If you wish to provide a custom AMI for Linux machine executors, you can supply an AMI ID in your `values.yaml` file. To create a Linux image, use the [CircleCI server Linux image builder](https://github.com/CircleCI-Public/circleci-server-linux-image-builder).

`````````
vm_service:
  providers:
    ec2:
      ...
      linuxAMI: "<my-linux-ami>"
`````````

#### Default AWS AMI lists

The default AMIs for server v4.2 are based on Ubuntu 22.04.

Table 1. x86 AMI list  

Region

AMI

`us-east-1`

`ami-03dc54f7559144972`

`ca-central-1`

`ami-0575d605472840942`

`ap-south-1`

`ami-047ef6196620f56ca`

`ap-southeast-2`

`ami-0521f8d70ef9dbd24`

`ap-southeast-1`

`ami-0ef0354f4eb3b7428`

`eu-central-1`

`ami-0a8286fff7b5ed33a`

`eu-west-1`

`ami-093618a1d0185f9e8`

`eu-west-2`

`ami-08f00d41b17d3ea0a`

`sa-east-1`

`ami-064b0bfe97e6ec04c`

`us-east-2`

`ami-068cb131f91632f12`

`us-west-1`

`ami-0a4b7cf088a798be3`

`us-west-2`

`ami-018e05f98628cf5e5`

`ap-northeast-1`

`ami-06f32ec6aeecbeaa6`

`ap-northeast-2`

`ami-084c1abb1e8dabffd`

`eu-west-3`

`ami-09b3e24bccae3252f`

`us-gov-east-1`

`ami-0de525cac9ac9bea8`

`us-gov-west-1`

`ami-02abf947586cae56b`

Table 2. Arm AMI list  

Region

AMI

`us-east-1`

`ami-0b11ce74f44e45578`

`ca-central-1`

`ami-07400e987dd82901d`

`ap-south-1`

`ami-072fe819d7b94b095`

`ap-southeast-2`

`ami-0510826f7f3a83b3e`

`ap-southeast-1`

`ami-0e5b703665f3e4517`

`eu-central-1`

`ami-045ea67b0f35ef1ef`

`eu-west-1`

`ami-044ac39c87438d89d`

`eu-west-2`

`ami-0a399817fbbb240e4`

`sa-east-1`

`ami-0ebc0e64fb943e191`

`us-east-2`

`ami-01f7dc2f8590b1611`

`us-west-1`

`ami-085fb1dd323aa02c7`

`us-west-2`

`ami-0e5ea38c131f05c8f`

`ap-northeast-1`

`ami-02c8fac0dbbbad74f`

`ap-northeast-2`

`ami-022e2eacee7328cca`

`us-gov-east-1`

`ami-0bb797dcfa52ce04d`

`us-gov-west-1`

`ami-0ab175883ff460b17`

### GCP

Configure VM Service to work with GCP in your `values.yml` file. During installation you will have set up a security group and authentication. See the [Installation Phase 3 - Execution Environments](https://circleci.com/docs/server-admin/server-4.2/installation/phase-3-execution-environments/#aws-vm-service) page for more information.

The information in this section describes post-installation configuration options for VM service.

#### Windows image

If you require Windows executors, you can supply an AMI ID in your `values.yaml` file. To create a Windows image, use the [CircleCI server Windows image builder](https://github.com/CircleCI-Public/circleci-server-windows-image-builder).

`````````
vm_service:
  providers:
    gcp:
      ...
      windowsImage: "<my-windows-image>"
`````````

#### Alternative Linux VM image

If you wish to provide a custom AMI for Linux machine executors, you can supply an AMI ID in your `values.yaml` file. To create a Linux image, use the [CircleCI server Linux image builder](https://github.com/CircleCI-Public/circleci-server-linux-image-builder).

`````````
vm_service:
  providers:
    gcp:
      ...
      linuxImage: "<my-linux-image>"
`````````

## Instance preallocation

If [Docker Layer Caching (DLC)](https://circleci.com/docs/guides/optimize/docker-layer-caching/) is used, VM Service instances need to be spun up on demand. For this to happen, **either** ensure any preallocated instances are in use, **or** set both remote Docker and `machine` preallocated instance fields to `0`.

When using preallocated instances be aware that a cron job is scheduled to cycle through these instances once per day to ensure they do not end up in an unworkable state.

To configure server to keep instances preallocated, use the keys shown in the following `values.yaml` examples:

For a full list of options, see the [Installation Reference](https://circleci.com/docs/server-admin/server-4.2/installation/installation-reference/#all-values-yaml-options) page.

`````````
vm_scaler:
  # -- Number of replicas to deploy for the vm-scaler deployment.
  replicas: 1
  # -- Configuration options for, and numbers of, prescaled instances for remote Docker jobs.
  prescaled:
    - type: l1.medium
      image: docker-default
      docker-engine: true # remote Docker environment
      cron: ""
      count: 2
`````````

`````````
vm_scaler:
  # -- Number of replicas to deploy for the vm-scaler deployment.
  replicas: 1
  # -- Configuration options for, and numbers of, prescaled instances for remote Docker jobs.
  prescaled:
    - type: l1.medium
      image: default
      docker-engine: false # machine execution environment
      cron: ""
      count: 2
`````````

## Apply changes

Apply the changes made to your `values.yaml` file:

`````````
namespace=<your-namespace>
helm upgrade circleci-server oci://cciserver.azurecr.io/circleci-server -n $namespace --version 4.2.7 -f <path-to-values.yaml>
`````````