Deploy sidecars

Uses: Kong Gateway Operator
Related Documentation
TL;DR

Use PodTemplateSpec to customize the spec and specify an additional container in spec.containers.

Prerequisites

If you don’t have a Konnect account, you can get started quickly with our onboarding wizard.

  1. The following Konnect items are required to complete this tutorial:
    • Personal access token (PAT): Create a new personal access token by opening the Konnect PAT page and selecting Generate Token.
  2. Set the personal access token as an environment variable:

    export KONNECT_TOKEN='YOUR KONNECT TOKEN'
    
    Copied to clipboard!

Deploy Sidecar

Kong Gateway Operator uses PodTemplateSpec to customize deployments.

Here is an example that deploys a Vector sidecar alongside the proxy containers.

Configure vector.dev

apiVersion: v1
kind: ConfigMap
metadata:
  name: sidecar-vector-config
data:
  vector.toml: |
    [sources.proxy_access_log_source]
    type = "file"
    include = [ "/etc/kong/log/proxy_access.log" ]
    [sinks.proxy_access_log_sink]
    type = "console"
    inputs = [ "proxy_access_log_source" ]
    encoding.codec = "json"
Copied to clipboard!

Configure PodTemplateSpec

The following example uses the DataPlane resource, but you can also configure your GatewayConfiguration resource as needed. For more information see the PodTemplateSpec page.

apiVersion: gateway-operator.konghq.com/v1beta1
kind: DataPlane
metadata:
  name: dataplane-example
  namespace: kong
spec:
  deployment:
    podTemplateSpec:
      metadata:
        labels:
          dataplane-pod-label: example
        annotations:
          dataplane-pod-annotation: example
      spec:
        volumes:
        - name: cluster-certificate
        - name: sidecar-vector-config-volume
          configMap:
            name: sidecar-vector-config
        - name: proxy-logs
          emptyDir:
            sizeLimit: 128Mi
        containers:
        - name: sidecar
          image: timberio/vector:0.31.0-debian
          volumeMounts:
          - name: sidecar-vector-config-volume
            mountPath: "/etc/vector"
          - name: proxy-logs
            mountPath: "/etc/kong/log/"
          readinessProbe:
            initialDelaySeconds: 1
            periodSeconds: 1
        - name: proxy
          image: kong/kong-gateway:3.11
          volumeMounts:
          - name: proxy-logs
            mountPath: "/etc/kong/log/"
          env:
          - name: KONG_LOG_LEVEL
            value: debug
          - name: KONG_PROXY_ACCESS_LOG
            value: "/etc/kong/log/proxy_access.log"
Copied to clipboard!

Did this doc help?

Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!