Refactor Helm chart for API7EE: clarify gateway requirements, improve
ADC config templating, and enhance gateway health checks
This commit is contained in:
@@ -9,19 +9,21 @@ metadata:
|
||||
data:
|
||||
adc-config.yaml: |
|
||||
services:
|
||||
- name: apache-service
|
||||
# Web Frontend Service
|
||||
- name: {{ include "api7ee.fullname" . }}-web-service
|
||||
hosts:
|
||||
- {{ (first .Values.api7.hosts) | quote }}
|
||||
upstream:
|
||||
name: apache-upstream
|
||||
name: {{ include "api7ee.fullname" . }}-web-upstream
|
||||
scheme: http
|
||||
type: roundrobin
|
||||
nodes:
|
||||
- host: apache-service.{{ .Release.Namespace }}.svc.cluster.local
|
||||
port: 80
|
||||
- host: {{ include "api7ee.fullname" . }}-web.{{ .Release.Namespace }}.svc.cluster.local
|
||||
port: {{ .Values.web.service.port }}
|
||||
weight: 100
|
||||
routes:
|
||||
- name: apache-route
|
||||
# Route for web frontend (all paths except /api)
|
||||
- name: {{ include "api7ee.fullname" . }}-web-route
|
||||
uris:
|
||||
- /*
|
||||
vars:
|
||||
@@ -34,20 +36,31 @@ data:
|
||||
redirect:
|
||||
http_to_https: true
|
||||
{{- end }}
|
||||
{{- if .Values.api7.plugins.cors.enabled }}
|
||||
cors:
|
||||
allow_origins: {{ .Values.api7.plugins.cors.allowOrigins | toJson }}
|
||||
allow_methods: {{ .Values.api7.plugins.cors.allowMethods | toJson }}
|
||||
allow_headers: {{ .Values.api7.plugins.cors.allowHeaders | toJson }}
|
||||
expose_headers: {{ .Values.api7.plugins.cors.exposeHeaders | toJson }}
|
||||
max_age: {{ .Values.api7.plugins.cors.maxAge }}
|
||||
allow_credential: {{ .Values.api7.plugins.cors.allowCredentials }}
|
||||
{{- end }}
|
||||
|
||||
- name: nginx-api-service
|
||||
# API Backend Service
|
||||
- name: {{ include "api7ee.fullname" . }}-api-service
|
||||
hosts:
|
||||
- {{ (first .Values.api7.hosts) | quote }}
|
||||
upstream:
|
||||
name: nginx-upstream
|
||||
name: {{ include "api7ee.fullname" . }}-api-upstream
|
||||
scheme: http
|
||||
type: roundrobin
|
||||
nodes:
|
||||
- host: nginx-service.{{ .Release.Namespace }}.svc.cluster.local
|
||||
port: 80
|
||||
- host: {{ include "api7ee.fullname" . }}-api.{{ .Release.Namespace }}.svc.cluster.local
|
||||
port: {{ .Values.api.service.port }}
|
||||
weight: 100
|
||||
routes:
|
||||
- name: nginx-api-llm-route
|
||||
# High priority route for LLM endpoints with AI rate limiting
|
||||
- name: {{ include "api7ee.fullname" . }}-api-llm-route
|
||||
uris:
|
||||
- /api/llm
|
||||
- /api/llm/*
|
||||
@@ -57,6 +70,15 @@ data:
|
||||
redirect:
|
||||
http_to_https: true
|
||||
{{- end }}
|
||||
{{- if .Values.api7.plugins.cors.enabled }}
|
||||
cors:
|
||||
allow_origins: {{ .Values.api7.plugins.cors.allowOrigins | toJson }}
|
||||
allow_methods: {{ .Values.api7.plugins.cors.allowMethods | toJson }}
|
||||
allow_headers: {{ .Values.api7.plugins.cors.allowHeaders | toJson }}
|
||||
expose_headers: {{ .Values.api7.plugins.cors.exposeHeaders | toJson }}
|
||||
max_age: {{ .Values.api7.plugins.cors.maxAge }}
|
||||
allow_credential: {{ .Values.api7.plugins.cors.allowCredentials }}
|
||||
{{- end }}
|
||||
{{- if .Values.api7.plugins.aiRateLimit.enabled }}
|
||||
ai-rate-limiting:
|
||||
limit: {{ .Values.api7.plugins.aiRateLimit.limit }}
|
||||
@@ -65,7 +87,8 @@ data:
|
||||
limit_strategy: {{ .Values.api7.plugins.aiRateLimit.limitStrategy | quote }}
|
||||
{{- end }}
|
||||
|
||||
- name: nginx-api-route
|
||||
# Standard API route with request rate limiting
|
||||
- name: {{ include "api7ee.fullname" . }}-api-route
|
||||
uris:
|
||||
- /api
|
||||
- /api/*
|
||||
@@ -75,6 +98,15 @@ data:
|
||||
redirect:
|
||||
http_to_https: true
|
||||
{{- end }}
|
||||
{{- if .Values.api7.plugins.cors.enabled }}
|
||||
cors:
|
||||
allow_origins: {{ .Values.api7.plugins.cors.allowOrigins | toJson }}
|
||||
allow_methods: {{ .Values.api7.plugins.cors.allowMethods | toJson }}
|
||||
allow_headers: {{ .Values.api7.plugins.cors.allowHeaders | toJson }}
|
||||
expose_headers: {{ .Values.api7.plugins.cors.exposeHeaders | toJson }}
|
||||
max_age: {{ .Values.api7.plugins.cors.maxAge }}
|
||||
allow_credential: {{ .Values.api7.plugins.cors.allowCredentials }}
|
||||
{{- end }}
|
||||
{{- if .Values.api7.plugins.rateLimit.enabled }}
|
||||
limit-count:
|
||||
count: {{ .Values.api7.plugins.rateLimit.count }}
|
||||
@@ -85,6 +117,7 @@ data:
|
||||
{{- end }}
|
||||
|
||||
{{- if .Values.api7.plugins.auth.enabled }}
|
||||
# API Consumers for authentication
|
||||
consumers:
|
||||
{{- range .Values.api7.consumers }}
|
||||
- username: {{ .username }}
|
||||
@@ -94,6 +127,7 @@ data:
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
# Global Rules
|
||||
global_rules:
|
||||
{{- if .Values.api7.plugins.prometheus.enabled }}
|
||||
- id: prometheus-metrics
|
||||
|
||||
@@ -63,13 +63,26 @@ spec:
|
||||
echo "Waiting for API7 Gateway to be available..."
|
||||
MAX_RETRIES=30
|
||||
RETRY_COUNT=0
|
||||
{{- if eq .Values.api7.backend "api7ee" }}
|
||||
# For API7 EE, check the version endpoint
|
||||
HEALTH_ENDPOINT="${API7_ADMIN_URL}/version"
|
||||
{{- else }}
|
||||
# For Apache APISIX, check the admin routes endpoint
|
||||
HEALTH_ENDPOINT="${API7_ADMIN_URL}/apisix/admin/routes"
|
||||
{{- end }}
|
||||
|
||||
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
|
||||
if curl -s -o /dev/null -w "%{http_code}" ${API7_ADMIN_URL}/apisix/admin/routes \
|
||||
-H "X-API-KEY: ${API7_ADMIN_KEY}" | grep -q "200\|401"; then
|
||||
echo "API7 Gateway is ready!"
|
||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" ${HEALTH_ENDPOINT} \
|
||||
{{- if eq .Values.api7.backend "apisix" }}
|
||||
-H "X-API-KEY: ${API7_ADMIN_KEY}" \
|
||||
{{- end }}
|
||||
--max-time 5 || echo "000")
|
||||
|
||||
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "401" ]; then
|
||||
echo "API7 Gateway is ready! (HTTP $HTTP_CODE)"
|
||||
break
|
||||
fi
|
||||
echo "API7 Gateway not ready, retrying... ($RETRY_COUNT/$MAX_RETRIES)"
|
||||
echo "API7 Gateway not ready (HTTP $HTTP_CODE), retrying... ($RETRY_COUNT/$MAX_RETRIES)"
|
||||
RETRY_COUNT=$((RETRY_COUNT + 1))
|
||||
sleep 10
|
||||
done
|
||||
@@ -209,4 +222,4 @@ spec:
|
||||
secret:
|
||||
secretName: {{ .Values.api7.tls.secretName | default (printf "%s-tls" (include "api7ee.fullname" .)) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
Reference in New Issue
Block a user