In this setup, you need to designate one backup node.
The backup node must have read and write access to the S3 bucket, and the Data Plane nodes that are provisioned must have read access to the same S3 bucket.
The backup node is responsible for communicating the state of the Kong Gateway kong.conf
configuration file from the Control Plane to the S3 bucket.
Nodes are initialized with fallback configs via environment variables, including AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
, and AWS_DEFAULT_REGION
.
If you’re associating this with an IAM role and if the backup node doesn’t reside on the AWS platform, you may also need to use the AWS_SESSION_TOKEN
environment variable.
We don’t recommend using backup nodes to proxy traffic. The backup job enlarges the attack surface of a proxying Data Plane and contributes significantly to the P99 delay. You need to know the risk if you want to deploy a node this way:
- The Data Plane needs to be at least
3.6.0.0
to be provisioned with backup configuration when it’s configured as a backup node. Although a single backup node is sufficient for all deployments, you can also configure additional backup nodes. A leader election algorithm selects one node from the group of designated backup nodes to do the backup job.
- In Kong Gateway 3.5 or earlier, a Data Plane acting as a backup node cannot be provisioned with backup configurations.
For more information about the data that is set in the environment variables, see the AWS environment variable configuration documentation.
Using Docker Compose, you can configure the backup nodes:
kong-exporter:
image: 'kong/kong-gateway:latest'
ports:
- '8000:8000'
- '8443:8443'
environment:
<<: *other-kong-envs
AWS_REGION: 'us-east-2'
AWS_ACCESS_KEY_ID: $ACCESS_KEY_WRITE
AWS_SECRET_ACCESS_KEY: $SECRET_ACCESS_KEY_WRITE
KONG_CLUSTER_FALLBACK_CONFIG_STORAGE: s3://test-bucket/test-prefix
KONG_CLUSTER_FALLBACK_CONFIG_EXPORT: "on"
All the object keynames/prefixes mentioned in the following paragraphs are parameterized with the prefix given in the config and the Kong Gateway version. For example, let’s say the node has a version of 3.6.0.0
. The backup nodes will create registering files to run the leader election with a prefix test-prefix/3.6.0.0/election/
. You can set up a lifecycle rule to delete objects with this prefix if it’s not updated for days. The selected node is responsible for writing to the S3 bucket when it receives new configuration. The file structure is automatically created inside of the bucket and shouldn’t be created manually. The key name is test-prefix/3.6.0.0/config.json
.
In Kong Gateway 3.5 or earlier, this node is responsible for writing to the S3 bucket when it receives new configuration. The file structure is automatically created inside of the bucket and should not be created manually. If the node version is 3.2.0.0
, using the example above, the key name will be test-prefix/3.2.0.0/config.json
.
Both the Control Plane and Data Plane can be configured to export configurations.
You can configure new Data Planes to load a configuration from the S3 bucket if the Control Plane is unreachable using the following environment variables:
kong-dp-importer:
image: 'kong/kong-gateway:latest'
ports:
- '8000:8000'
- '8443:8443'
environment:
<<: *other-kong-envs
AWS_REGION: 'us-east-2'
AWS_ACCESS_KEY_ID: $ACCESS_KEY_READ
AWS_SECRET_ACCESS_KEY: $SECRET_ACCESS_KEY_READ
KONG_CLUSTER_FALLBACK_CONFIG_STORAGE: s3://test-bucket/test-prefix
KONG_CLUSTER_FALLBACK_CONFIG_IMPORT: "on"