fix: load gateway services from yaml

main
Malar Invention 2025-01-12 13:13:39 +05:30
parent d4db24a8d8
commit b297643ef7
2 changed files with 10 additions and 8 deletions

View File

@ -2,10 +2,11 @@
FROM python:3.13-alpine3.19
# Install the Kubernetes Python client
RUN pip install kubernetes kubernetes_asyncio
RUN pip install kubernetes kubernetes_asyncio PyYAML
# Copy the controller script into the container
COPY node_external_ip_controller_async.py /app/node_external_ip_controller.py
COPY gateway_services.yaml /app/gateway_services.yaml
# Set the working directory
WORKDIR /app

View File

@ -3,13 +3,14 @@ from kubernetes_asyncio import client, config, watch
import os
# Configuration
SERVICE_NAME = os.getenv(
"SERVICE_NAME", "traefik-tcp"
) # service name for truechart traefik helm
SERVICE_NAME_LABEL_PATTERN = os.getenv(
"SERVICE_NAME_LABEL_PATTERN", "app.kubernetes.io/name=traefik"
)
NAMESPACE = os.getenv("NAMESPACE", "kube-system")
import yaml
with open("gateway_services.yaml", "r") as f:
gateway_services = yaml.safe_load(f)
SERVICE_NAME = gateway_services["gateway_services"][0]["name"].split("/")[1]
SERVICE_NAME_LABEL_PATTERN = gateway_services["gateway_services"][0]["label_pattern"]
NAMESPACE = gateway_services["gateway_services"][0]["name"].split("/")[0]
ANNOTATION_KEY = os.getenv("ANNOTATION_KEY", "kube-vip.io/loadbalancerIPs")
ZERO_GATEWAY_IP = os.getenv("ZERO_GATEWAY_IP", "172.28.10.1")
NODE_LABEL = os.getenv("NODE_LABEL", "svccontroller.k3s.cattle.io/enablelb=true")