flush logs
parent
148190ab02
commit
1880f8ce54
|
|
@ -23,7 +23,9 @@ def update_service_annotation(external_ip):
|
|||
current_annotation = service.metadata.annotations.get(ANNOTATION_KEY)
|
||||
ipam_address = service.spec.load_balancer_ip
|
||||
if ipam_address:
|
||||
print(f"service {SERVICE_NAME} has existing ipam IP: {ipam_address}")
|
||||
print(
|
||||
f"service {SERVICE_NAME} has existing ipam IP: {ipam_address}", flush=True
|
||||
)
|
||||
target_annotation = ",".join({ipam_address, external_ip})
|
||||
else:
|
||||
target_annotation = external_ip
|
||||
|
|
@ -32,7 +34,8 @@ def update_service_annotation(external_ip):
|
|||
body = {"metadata": {"annotations": {ANNOTATION_KEY: target_annotation}}}
|
||||
v1.patch_namespaced_service(SERVICE_NAME, NAMESPACE, body)
|
||||
print(
|
||||
f"Updated service {SERVICE_NAME} with new external IPs: {target_annotation}"
|
||||
f"Updated service {SERVICE_NAME} with new external IPs: {target_annotation}",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -54,15 +57,18 @@ def main():
|
|||
break
|
||||
|
||||
if external_ip:
|
||||
print(f"Detected external IP {external_ip} for node {node_name}")
|
||||
print(
|
||||
f"Detected external IP {external_ip} for node {node_name}",
|
||||
flush=True,
|
||||
)
|
||||
update_service_annotation(external_ip)
|
||||
|
||||
except client.exceptions.ApiException as e:
|
||||
print(f"API Exception: {e}")
|
||||
print(f"API Exception: {e}", flush=True)
|
||||
time.sleep(5) # Wait before retrying
|
||||
|
||||
except Exception as e:
|
||||
print(f"Unexpected error: {e}")
|
||||
print(f"Unexpected error: {e}", flush=True)
|
||||
time.sleep(5)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue