deploy-templates/templates/platform-gateway-public-api/KongRateLimitingPluginByHeaderSecretConfig.yaml (25 lines of code) (raw):
{{- $root := .Values }}
{{ if $root.publicApi }}
{{- range $publicEndpoints := $root.publicApi }}
{{ if and $publicEndpoints.enabled $publicEndpoints.limits }}
{{- $secret := (lookup "v1" "Secret" $root.namespace $root.kongRedis.secretName) }}
---
apiVersion: v1
kind: Secret
metadata:
name: public-{{ $publicEndpoints.name }}-rate-limiting
labels:
kong-plugin-conf: rate-limiting
stringData:
by-header: |
{{- $publicEndpoints.limits | toYaml | nindent 4 }}
policy: redis
limit_by: header
header_name: forwarded
redis_host: {{ $root.kongRedis.serviceName }}
redis_port: {{ $root.kongRedis.port }}
redis_password: {{ $secret.data.password | b64dec }}
type: Opaque
{{- end }}
{{- end }}
{{- end }}