Enable Kubernetes Service Discovery for API7 Gateway upstreams
All checks were successful
Helm Chart Build / lint-only (push) Has been skipped
Helm Chart Build / build-helm (push) Successful in 9s
Build and Deploy / build-api (push) Successful in 43s
Build and Deploy / build-web (push) Successful in 1m1s

Configured API7 Gateway to use Kubernetes Service Discovery instead of
static upstream nodes. This enables dynamic discovery of backend Pods
through the Kubernetes API.

Benefits:
- Automatic scaling: New Pods are automatically added to upstream pool
- Health checks: Only healthy Pods receive traffic
- Zero downtime: Automatic updates during deployments and rollouts
- No manual upstream configuration needed

Changes:
- Updated configmap-adc.yaml to use discovery_type: kubernetes
- Service discovery queries Kubernetes API for Pod endpoints
- Falls back to static nodes if serviceDiscovery.enabled is false
- Added documentation in values.yaml explaining the feature

The RBAC permissions (services, endpoints watch) were already configured
in rbac-adc.yaml, so no additional permissions are needed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
d.viti
2025-10-09 15:24:29 +02:00
parent f04862f6f7
commit e995482bfd
2 changed files with 29 additions and 0 deletions

View File

@@ -17,10 +17,22 @@ data:
name: {{ include "api7ee.fullname" . }}-web-upstream
scheme: http
type: roundrobin
{{- if .Values.api7.serviceDiscovery.enabled }}
# Use Kubernetes Service Discovery
discovery_type: kubernetes
service_name: {{ include "api7ee.fullname" . }}-web
{{- if .Values.api7.serviceDiscovery.namespace }}
namespace_id: {{ .Values.api7.serviceDiscovery.namespace }}
{{- else }}
namespace_id: {{ .Release.Namespace }}
{{- end }}
{{- else }}
# Static nodes configuration
nodes:
- host: {{ include "api7ee.fullname" . }}-web.{{ .Release.Namespace }}.svc.cluster.local
port: {{ .Values.web.service.port }}
weight: 100
{{- end }}
routes:
# Route for web frontend (all paths except /api)
- name: {{ include "api7ee.fullname" . }}-web-route
@@ -54,10 +66,22 @@ data:
name: {{ include "api7ee.fullname" . }}-api-upstream
scheme: http
type: roundrobin
{{- if .Values.api7.serviceDiscovery.enabled }}
# Use Kubernetes Service Discovery
discovery_type: kubernetes
service_name: {{ include "api7ee.fullname" . }}-api
{{- if .Values.api7.serviceDiscovery.namespace }}
namespace_id: {{ .Values.api7.serviceDiscovery.namespace }}
{{- else }}
namespace_id: {{ .Release.Namespace }}
{{- end }}
{{- else }}
# Static nodes configuration
nodes:
- host: {{ include "api7ee.fullname" . }}-api.{{ .Release.Namespace }}.svc.cluster.local
port: {{ .Values.api.service.port }}
weight: 100
{{- end }}
routes:
# High priority route for LLM endpoints with AI rate limiting
- name: {{ include "api7ee.fullname" . }}-api-llm-route

View File

@@ -258,6 +258,11 @@ api7:
key: ""
# Service Discovery
# When enabled, API7 Gateway dynamically discovers backend Pods through Kubernetes API
# instead of using static upstream nodes. This provides:
# - Automatic scaling: New Pods are automatically added to the upstream pool
# - Health checks: Only healthy Pods receive traffic
# - Zero downtime: Automatic updates during deployments and rollouts
serviceDiscovery:
enabled: true # Use Kubernetes service discovery
namespace: "" # Leave empty to use release namespace