Search
Varnish Helm Chart

Setting up Varnish Clustering with Helm

Introduction

Varnish Cluster is a solution for increasing cache hit rate in a Varnish Enterprise deployment and reducing load on the origin service. It’s dynamic, scalable, and can be enabled with just a few lines of VCL.

This guide covers how to enable a dynamic cluster using the official Varnish Enterprise Helm chart.

Before we begin

The Varnish Enterprise Installation Guide and the official Varnish Enterprise Helm chart must be used to install and deploy Varnish Enterprise.

Configuration

Set cluster.enabled

The official Varnish Enterprise Helm charts now provide the simplest way to activate clustering. There is no longer a requirement to generate a cluster token or manually configure an override file. Simply setting cluster.enabled to true in your values.yaml file will automatically handle the configurations:

cluster:
  enabled: true # false by default; turns on clustering
  # trace: true # false by default; temporarily set to true for debugging

This enables clustering and allows pods to shard requests between each other. For further details, refer to the Helm configuration API.

Deploy or Upgrade

Apply the changes defined in the override file on top of the chart defaults:

helm upgrade varnish-enterprise varnish/varnish-enterprise -f values.yaml

Validation

Check cluster metrics

The following command displays metrics such as cluster_stats.error_token and cluster_stats.self_identified:

kubectl exec -it <any-pod-name> -- varnishstat -1 -f 'KVSTORE.cluster_stats.*'

Refer to the cluster observability section for more details about the metrics.

List backends

Run the following command to verify you have one backend entry per peer (including self).

kubectl exec -it <any-pod-name> -- varnishadm backend.list '*.*'

Check varnishlog

Cluster logs are prefixed with Cluster: and are logged with the VCL_Log tag. They can be observed with the following varnishlog command:

$ kubectl exec -it <any-pod-name> -- varnishlog -g raw -q 'VCL_Log ~ "^Cluster:"' -i VCL_Log
       146 VCL_Log        b Cluster: Not self-routing, this is a primary node
       ...
        18 VCL_Log        b Cluster: Self-routing to primary node

®Varnish Software, Wallingatan 12, 111 60 Stockholm, Organization nr. 556805-6203