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
Kong Konnect
If you don’t have a Konnect account, you can get started quickly with our onboarding wizard.
- 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.
-
Set the personal access token as an environment variable:
export KONNECT_TOKEN='YOUR KONNECT TOKEN'
Kong Gateway Operator running
-
Add the Kong Helm charts:
helm repo add kong https://charts.konghq.com helm repo update
-
Create a
kong
namespace:kubectl create namespace kong --dry-run=client -o yaml | kubectl apply -f -
-
Install Kong Ingress Controller using Helm:
helm upgrade --install kgo kong/gateway-operator -n kong-system --create-namespace \ --set image.tag=1.5 \ --set kubernetes-configuration-crds.enabled=true \ --set env.ENABLE_CONTROLLER_KONNECT=true
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"
Configure PodTemplateSpec
The following example uses the
DataPlane
resource, but you can also configure yourGatewayConfiguration
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.10
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"