> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-integration/3.0/use-harness-ci/use-harness-ci/set-up-build-infrastructure/vm-build-infrastructure/high-availability.md).

# High Availability (HA)

### Minimum version <a href="#minimum-version" id="minimum-version"></a>

To use this feature, use [drone runner](https://github.com/drone-runners/drone-runner-aws/tree/v1.0.0-rc.187?tab=readme-ov-file#high-availablity) version [`v1.0.0-rc.187`](https://github.com/drone-runners/drone-runner-aws/releases/tag/v1.0.0-rc.187) or later.

### Architecture <a href="#architecture" id="architecture"></a>

### Set up high availability <a href="#setup" id="setup"></a>

When using VM build infrastructure, you can deploy multiple runner replicas to ensure high availability. The following deployment YAML creates two runner replicas behind a load balancer.

```yaml
---
apiVersion: v1
kind: Namespace
metadata:
  name: harness-delegate-ng
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: drone-runner
  namespace: harness-delegate-ng
spec:
  replicas: 2
  selector:
    matchLabels:
      app: drone-runner
  template:
    metadata:
      labels:
        app: drone-runner
    spec:
      containers:
        - name: drone-runner
          image: drone/drone-runner-aws:v1.0.0-rc.187
          args: ["delegate", "--pool", "/runner/pool.yml"]
          env:
            - name: DRONE_RUNNER_HA
              value: "true"
            - name: DRONE_DATABASE_DRIVER
              value: postgres
            - name: DRONE_DATABASE_DATASOURCE
              value: host=runnerha-postgres-service.harness-delegate-ng.svc.cluster.local port=5431 user=admin password=password dbname=dlite sslmode=disable
          ports:
            - containerPort: 3000
          volumeMounts:
            - name: config-volume
              mountPath: /runner
              readOnly: true
      volumes:
        - name: config-volume
          projected:
            sources:
              - configMap:
                  name: drone-runner-config
              - secret:
                  name: drone-runner-secret
---
apiVersion: v1
kind: Service
metadata:
  name: drone-runner-lb
  namespace: harness-delegate-ng
spec:
  type: LoadBalancer
  selector:
    app: drone-runner
  ports:
    - port: 3000
      targetPort: 3000
      protocol: TCP
```

Configure the preceding YAML:

* Populate `DRONE_DATABASE_DATASOURCE` according to your database infrastructure.
* The `RUNNER_URL` environment variable points to the machine where Harness Runner runs. Use the load balancer IP for `RUNNER_URL` in the delegate. For example, when installing the delegate:
  * Add `-e RUNNER_URL=http://<LOAD_BALANCER_IP>:3000`
* The preceding YAML mounts the `config-volume` volume at `/runner`. Map the required `pool.yml` file and secrets. The following GCP-specific `pool.yaml` file is used in the deployment.

```yaml
version: "1"
instances:
  - name: linux-amd64
    type: google
    pool: 2
    limit: 10
    platform:
      os: linux
      arch: amd64 
    spec:
      hibernate: false
      privateIP: true
      account:
        project_id: projectname
        json_path: runner/gcp-secret.json
      image: projects/projectname/global/images/hosted-vm-64
      machine_type: e2-medium
      zones:
        - us-central1-a
      disk:
        size: 100
```
