15 lines
749 B
Python
15 lines
749 B
Python
"""Wait for distinct ready replicas through verified HTTPS ingress."""
|
|
import argparse,ssl,time,urllib.request
|
|
p=argparse.ArgumentParser();p.add_argument('--replicas',type=int,default=2);args=p.parse_args()
|
|
ctx=ssl.create_default_context(cafile='.secrets/ca.crt');seen=set()
|
|
for attempt in range(120):
|
|
try:
|
|
with urllib.request.urlopen('https://localhost:8443/health/ready',context=ctx,timeout=4) as r:
|
|
if r.status==200:
|
|
seen.add(r.headers['X-Instance-Id'])
|
|
if len(seen)>=args.replicas:
|
|
print(f'HTTPS ready: {len(seen)} distinct replicas; CA and hostname verified');break
|
|
except Exception:pass
|
|
time.sleep(.5)
|
|
else:raise SystemExit('HTTPS replica readiness timeout')
|