Description
If you have servers in several locations, and you do not specifiy load-balancer.hetzner.cloud/node-selector
for a Service of type LoadBalancer, you get an error like this:
Warning SyncLoadBalancerFailed service-controller
Error syncing load balancer: failed to ensure load balancer: hcloud/loadBalancers.EnsureLoadBalancer: hcops/LoadBalancerOps.ReconcileHCLBTargets: target ...: servers and load balancers needs to be in the same network zone, cross network zone is not supported (unsupported_error, ea128263a919e24)
After adding load-balancer.hetzner.cloud/node-selector
it works.
We should either provide a better error message, or skip all nodes which do not fit to the region.
Here are files to reproduce it:
deployment-ash.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: region-test-ash
spec:
replicas: 1
selector:
matchLabels:
app: region-test-ash
template:
metadata:
labels:
app: region-test-ash
spec:
nodeSelector:
topology.kubernetes.io/region: ash
initContainers:
- name: init-html
image: busybox
command: ["sh", "-c"]
args:
- |
echo "<html><body>
<h1>Test Page</h1>
<p>Pod: $(hostname)</p>
</body></html>" > /usr/share/nginx/html/index.html
volumeMounts:
- name: html
mountPath: /usr/share/nginx/html
containers:
- name: web
image: nginx:1.25
ports:
- containerPort: 80
volumeMounts:
- name: html
mountPath: /usr/share/nginx/html
volumes:
- name: html
emptyDir: {}
service-ash.yaml:
apiVersion: v1
kind: Service
metadata:
name: region-test-ash
annotations:
load-balancer.hetzner.cloud/location: ash
load-balancer.hetzner.cloud/node-selector: topology.kubernetes.io/region=ash ### <<< fails without that
spec:
selector:
app: region-test-ash
type: LoadBalancer
ports:
- port: 80
targetPort: 80
With other words: Why is node-selector needed, when "location" is defined in the service?