zalando / spilo

Highly available elephant herd: HA PostgreSQL cluster using Docker
Apache License 2.0
1.53k stars 382 forks source link

Allow to change kubernetes cluster domain on KUBE_API_URL #1002

Open PedroCapdevila opened 2 months ago

PedroCapdevila commented 2 months ago

Using an external etcd as the DCS instead of the native Kubernetes API, when the callback is performed to change the labels pointing to the master, it fails if you have configured a different cluster domain for the Kubernetes cluster, because KUBE_API_URL always points to cluster.local as the domain:

https://github.com/zalando/spilo/blob/5ddf59dbfa2c317e2eaa311e85ca52919d283207/postgres-appliance/scripts/callback_role.py#L17

Example log:

2024-07-10 16:22:18,822 WARNING: Exception when executing PATCH on https://kubernetes.default.svc.cluster.local/api/v1/namespaces/app-postgres/endpoints/primary-postgres-cluster: HTTPSConnectionPool(host='kubernetes.default.svc.cluster.local', port=443): Max retries exceeded with url: /api/v1/namespaces/app-postgres/endpoints/primary-postgres-cluster (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f9a632b2470>: Failed to establish a new connection: [Errno -2] Name or service not known'))

It should be possible to change the kubernetes cluster domain.