Varnish Controller



The binaries for Varnish Controller support three types of configuration: Passing the configuration flags as arguments to the binary, from the configuration file or by environment variables.

The precedence of these has the following order:

  1. Argument to binary
  2. Environment variable
  3. Configuration file

The name of the environment variables can be seen in the help (-h) for the binaries. Configuration flags are aligned between all binaries except for binary-specific configuration flags.

Example of output from the help flag, showing environment variable names:

varnish-controller-agent -h
Usage of varnish-controller-agent:
  -agent-name string
    	 Name of the agent, must be system wide unique.
    	 [ENV: VARNISH_CONTROLLER_AGENT_NAME] (default "agent1")
  -base-dir string
         Absolute path to base dir for generated files of the agent.
    	 [ENV: VARNISH_CONTROLLER_BASE_DIR] (default "/var/lib/varnish-controller/varnish-controller-agent/")
  -config string
    	 Configuration file.

Shared Configuration Files

Configuration files generated with -generate-config can be combined into one configuration file used by brainz, agents, routers and api-gw. The configuration file can be structured in the following way (supported from Varnish Controller 3.0.0).

# Configuration shared by all components
nats-server = localhost:4222
nats-ping-interval = 2s

# brainz specific configuration
# Overriding nats-ping-interval for brainz.
nats-ping-interval = 5s

# api-gw specific configuration
http-port = 8002

# agent specific configuration
name = "agent1"

# router specific configuration
name = "router1"

A configuration file can be generated from the binary with the flag -generate-config. This will output a valid configuration file to stdout. Any other argument/environment variable given at the time of generation will be included as the value in the configuration file. Otherwise the default values will be used. The generated configuration can be output to a file and then be used as an argument with -config <file>.

Shared Directories

The agent and Varnish can run on different servers as long as they have access to the same folder where the agent places the VCL files in (-base-dir). The agent must also be able to reach the varnishadm port on the Varnish server. The agent will also need to know about the Varnish secret in order to communicate via varnishadm.

Agent/Router Names

All agents and routers need to have unique names (-agent-name or -router-name). The name is used with NATS and requires an alphanumeric name.

Varnish CLI Logging

The agent in Varnish Controller is using the varnishadm rather intensively. This generates quite a lot CLI logging.

To disable CLI logging, change the parameter syslog_cli_traffic from on to off for varnishd.