fix: load gateway services from yaml
parent
d4db24a8d8
commit
b297643ef7
|
|
@ -2,10 +2,11 @@
|
||||||
FROM python:3.13-alpine3.19
|
FROM python:3.13-alpine3.19
|
||||||
|
|
||||||
# Install the Kubernetes Python client
|
# 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 the controller script into the container
|
||||||
COPY node_external_ip_controller_async.py /app/node_external_ip_controller.py
|
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
|
# Set the working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,14 @@ from kubernetes_asyncio import client, config, watch
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
SERVICE_NAME = os.getenv(
|
import yaml
|
||||||
"SERVICE_NAME", "traefik-tcp"
|
|
||||||
) # service name for truechart traefik helm
|
with open("gateway_services.yaml", "r") as f:
|
||||||
SERVICE_NAME_LABEL_PATTERN = os.getenv(
|
gateway_services = yaml.safe_load(f)
|
||||||
"SERVICE_NAME_LABEL_PATTERN", "app.kubernetes.io/name=traefik"
|
|
||||||
)
|
SERVICE_NAME = gateway_services["gateway_services"][0]["name"].split("/")[1]
|
||||||
NAMESPACE = os.getenv("NAMESPACE", "kube-system")
|
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")
|
ANNOTATION_KEY = os.getenv("ANNOTATION_KEY", "kube-vip.io/loadbalancerIPs")
|
||||||
ZERO_GATEWAY_IP = os.getenv("ZERO_GATEWAY_IP", "172.28.10.1")
|
ZERO_GATEWAY_IP = os.getenv("ZERO_GATEWAY_IP", "172.28.10.1")
|
||||||
NODE_LABEL = os.getenv("NODE_LABEL", "svccontroller.k3s.cattle.io/enablelb=true")
|
NODE_LABEL = os.getenv("NODE_LABEL", "svccontroller.k3s.cattle.io/enablelb=true")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue