Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/guides/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ In this folder, you should find guides for you to accomplish specific tasks with
- [Load Balancer](load-balancer/README.md)
- [Robot](robot/README.md)
- [Address Family](address-family.md)
- [Zone Label](zone-label.md)
- [Troubleshooting](troubleshooting.md)
44 changes: 44 additions & 0 deletions docs/guides/zone-label.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Zone Label

When a node is initialized, the hcloud-cloud-controller-manager sets these topology labels on it:

| Label | Value | Example |
| --------------------------------------------------------------------------- | ------------------------------------ | ----------- |
| `topology.kubernetes.io/region`, `failure-domain.beta.kubernetes.io/region` | Location of the Server | `fsn1` |
| `topology.kubernetes.io/zone`, `failure-domain.beta.kubernetes.io/zone` | Legacy datacenter name of the Server | `fsn1-dc14` |

The zone label can be disabled by setting `HCLOUD_INSTANCES_ZONE_LABEL_ENABLED` to `false`. By default, the value is set to `true`.

**We recommend disabling the zone label for new clusters.** Datacenters are deprecated in the Hetzner Cloud API, and the legacy datacenter names the label uses are only known for a fixed set of older locations. For any newer location, the label falls back to the location name and is therefore identical to the region label. The location is the failure domain you actually want to spread workloads over, and it is already available via `topology.kubernetes.io/region`. We plan to remove the zone label entirely in the next major version.

The label remains enabled by default because disabling it on a running cluster changes node labels, which existing workloads may depend on. See [Existing clusters](#existing-clusters) below.

## Configuration via Helm

```yaml
# values.yaml
---
env:
HCLOUD_INSTANCES_ZONE_LABEL_ENABLED:
value: "false"
```

## Existing clusters

Topology labels are only applied while a node is being initialized. Changing `HCLOUD_INSTANCES_ZONE_LABEL_ENABLED` does not relabel nodes that are already part of the cluster, so after disabling it you end up with a mixed cluster: existing nodes keep their zone label, and nodes joining afterwards do not get one. Anything that selects on the zone label — `nodeSelector`, node affinities, `topologySpreadConstraints`, or the node affinity of already-provisioned `PersistentVolume`s — will treat these two groups differently.

Before disabling the label, check whether anything in your cluster relies on it:

```sh
kubectl get pods,pv --all-namespaces -o yaml | grep -c 'topology.kubernetes.io/zone\|failure-domain.beta.kubernetes.io/zone'
```

To reach a consistent state afterwards, either recreate your nodes, or remove the labels from the existing ones:

```sh
kubectl label nodes --all topology.kubernetes.io/zone- failure-domain.beta.kubernetes.io/zone-
```

## Robot servers

This setting only affects Hetzner Cloud Servers. [Robot](robot/README.md) servers are always labeled with their datacenter (e.g. `fsn1-dc14`).
1 change: 1 addition & 0 deletions hcloud/cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func newTestEnv() testEnv {

cfg := config.HCCMConfiguration{}
cfg.Instance.AddressFamily = config.AddressFamilyIPv4
cfg.Instance.ZoneLabelEnabled = true

return testEnv{
Server: server,
Expand Down
13 changes: 10 additions & 3 deletions hcloud/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,23 @@ func (s hcloudServer) IsShutdown() (bool, error) {
}

func (s hcloudServer) Metadata(networkID int64, _ *corev1.Node, cfg config.HCCMConfiguration) (*cloudprovider.InstanceMetadata, error) {
return &cloudprovider.InstanceMetadata{
metadata := &cloudprovider.InstanceMetadata{
ProviderID: providerid.FromCloudServerID(s.ID),
InstanceType: s.ServerType.Name,
NodeAddresses: hcloudNodeAddresses(networkID, s.Server, cfg),
Zone: legacydatacenter.NameFromLocation(s.Location.Name),
Region: s.Location.Name,
AdditionalLabels: map[string]string{
ProvidedBy: "cloud",
},
}, nil
}

// By default, we continue to configure a zone label. The user
// can configure this behavior. We can drop this entirely in a v2.
if cfg.Instance.ZoneLabelEnabled {
metadata.Zone = legacydatacenter.NameFromLocation(s.Location.Name)
}

return metadata, nil
}

type robotServer struct {
Expand Down
15 changes: 11 additions & 4 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ const (
robotRateLimitWaitTime = "ROBOT_RATE_LIMIT_WAIT_TIME"
robotForwardInternalIPs = "ROBOT_FORWARD_INTERNAL_IPS"

hcloudInstancesAddressFamily = "HCLOUD_INSTANCES_ADDRESS_FAMILY"
hcloudServerCacheMode = "HCLOUD_SERVER_CACHE_MODE"
hcloudServerCacheMaxAge = "HCLOUD_SERVER_CACHE_MAX_AGE"
hcloudInstancesZoneLabelEnabled = "HCLOUD_INSTANCES_ZONE_LABEL_ENABLED"
hcloudInstancesAddressFamily = "HCLOUD_INSTANCES_ADDRESS_FAMILY"
hcloudServerCacheMode = "HCLOUD_SERVER_CACHE_MODE"
hcloudServerCacheMaxAge = "HCLOUD_SERVER_CACHE_MAX_AGE"

// Disable the "master/server is attached to the network" check against the metadata service.
hcloudNetworkDisableAttachedCheck = "HCLOUD_NETWORK_DISABLE_ATTACHED_CHECK"
Expand Down Expand Up @@ -73,7 +74,8 @@ const (
const ServerCacheDefaultMaxAge time.Duration = 10 * time.Second

type InstanceConfiguration struct {
AddressFamily AddressFamily
AddressFamily AddressFamily
ZoneLabelEnabled bool
}

type ServerCacheConfiguration struct {
Expand Down Expand Up @@ -185,6 +187,11 @@ func Read() (HCCMConfiguration, error) {
cfg.Instance.AddressFamily = AddressFamilyIPv4
}

cfg.Instance.ZoneLabelEnabled, err = getEnvBool(hcloudInstancesZoneLabelEnabled, true)
if err != nil {
errs = append(errs, err)
}

// ---- Server Cache ----

cfg.ServerCache = ServerCacheConfiguration{
Expand Down
Loading
Loading