Varnish Helm Chart

Using CLI command file for multi-tenant deployment


In many cases, it may be necessary to host multiple vhosts in the same Varnish Enterprise instance. Varnish Enterprise provides a VCL label as a way to dispatch each vhosts to a separate VCL file. Then, a CLI command file can be used to automate the labeling and loading of tenant VCLs.

In this setup, in additional to tenant VCLs, an entrypoint is also required to dispatch traffic to a separate VCL file. In the below example, we’ll use main.vcl as an entrypoint. Either server.vclConfigs or an external ConfigMap could be used for the VCLs.

Configuring VCL

To setup multi-tenant VCL and entrypoint VCL with server.vclConfigs, configure the following:

    # We need an entrypoint VCL separately from default.vcl (which is now used as a fallback VCL)
    main.vcl: |
      vcl 4.1

      import std;

      sub vcl_recv {
        set = std.tolower(;
        if ( ~ "(^|\.)example\.com(\:[0-9]+)?$") {
          return (vcl(label_example));
        } elseif ( ~ "(^|\.)home\.arpa(\:[0-9]+)?$") {
          return (vcl(label_home));

    # Define VCL for each domains
    example.vcl: |
      # ...

    home.vcl: |
      # ...

Alternatively, an external ConfigMap could also be used (see also Using an external VCL ConfigMap):

    - name: example
        name: example-vcl

    - name: home
        name: home-vcl

    - name: example
      mountPath: /etc/varnish/example.vcl
      subPath: example.vcl

    - name: home
      mountPath: /etc/varnish/home.vcl
      subPath: home.vcl

Configuring CLI command file

Once VCL files are configured, configure server.cmdfileConfig for each tenant:

  cmdfileConfig: |
    vcl.load vcl_example /etc/varnish/example.vcl
    vcl.label label_example
    vcl.load vcl_home /etc/varnish/home.vcl
    vcl.label label_home
    vcl.load vcl_main /etc/varnish/main.vcl
    vcl.use vcl_main