filter based on node label being set to enablelb
parent
dfb89f1608
commit
17b90e18ca
|
|
@ -11,7 +11,7 @@ v1 = client.CoreV1Api()
|
||||||
SERVICE_NAME = "traefik"
|
SERVICE_NAME = "traefik"
|
||||||
NAMESPACE = "kube-system"
|
NAMESPACE = "kube-system"
|
||||||
ANNOTATION_KEY = "kube-vip.io/loadbalancerIPs"
|
ANNOTATION_KEY = "kube-vip.io/loadbalancerIPs"
|
||||||
NODE_ANNOTATION_KEY = "svccontroller.k3s.cattle.io/enablelb"
|
NODE_LABEL = "svccontroller.k3s.cattle.io/enablelb=true"
|
||||||
|
|
||||||
|
|
||||||
def update_service_annotation(external_ip):
|
def update_service_annotation(external_ip):
|
||||||
|
|
@ -31,12 +31,11 @@ def main():
|
||||||
w = watch.Watch()
|
w = watch.Watch()
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
for event in w.stream(v1.list_node, _request_timeout=300):
|
for event in w.stream(
|
||||||
|
v1.list_node, label_selector=NODE_LABEL, _request_timeout=300
|
||||||
|
):
|
||||||
node = event["object"]
|
node = event["object"]
|
||||||
node_name = node.metadata.name
|
node_name = node.metadata.name
|
||||||
print(f"Node annotations: {node.metadata.annotations}")
|
|
||||||
is_gateway = node.metadata.annotations.get(NODE_ANNOTATION_KEY, False)
|
|
||||||
print(f"{node_name} is gateway?: {is_gateway}, type:{type(is_gateway)}")
|
|
||||||
|
|
||||||
# Extract the external IP if it exists
|
# Extract the external IP if it exists
|
||||||
external_ip = None
|
external_ip = None
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue