Skip to content

Commit 1f6ea11

Browse files
committed
create both keys in the secret: hcloud and token.
1 parent 2185a46 commit 1f6ea11

File tree

5 files changed

+37
-18
lines changed

5 files changed

+37
-18
lines changed

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,12 @@ ifeq ($(BUILD_IN_CONTAINER),true)
199199
-v $(shell pwd):/src/cluster-api-provider-$(INFRA_PROVIDER)$(MOUNT_FLAGS) \
200200
$(BUILDER_IMAGE):$(BUILDER_IMAGE_VERSION) $@;
201201
else
202-
helm repo add syself https://charts.syself.com
203-
helm repo update syself
204-
KUBECONFIG=$(WORKER_CLUSTER_KUBECONFIG) helm upgrade --install ccm syself/ccm-hetzner --version 2.0.1 \
205-
--namespace kube-system \
206-
--set privateNetwork.enabled=$(PRIVATE_NETWORK)
202+
helm repo add hcloud https://charts.hetzner.cloud
203+
helm repo update hcloud
204+
KUBECONFIG=$(WORKER_CLUSTER_KUBECONFIG) helm install hccm \
205+
hcloud/ cloud-cloud-controller-manager -n kube-system \
206+
--set privateNetwork.enabled=$(PRIVATE_NETWORK)
207+
--set robot.enabled=true
207208
@echo 'run "kubectl --kubeconfig=$(WORKER_CLUSTER_KUBECONFIG) ..." to work with the new target cluster'
208209
endif
209210

api/v1beta1/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ type HetznerSecretRef struct {
121121
type HetznerSecretKeyRef struct {
122122
// HCloudToken defines the name of the key where the token for the Hetzner Cloud API is stored.
123123
// +optional
124-
// +kubebuilder:default=hcloud-token
124+
// +kubebuilder:default=token
125125
HCloudToken string `json:"hcloudToken"`
126126
// HetznerRobotUser defines the name of the key where the username for the Hetzner Robot API is stored.
127127
// +optional
128-
// +kubebuilder:default=hetzner-robot-user
128+
// +kubebuilder:default=robot-user
129129
HetznerRobotUser string `json:"hetznerRobotUser"`
130130
// HetznerRobotPassword defines the name of the key where the password for the Hetzner Robot API is stored.
131131
// +optional
132-
// +kubebuilder:default=hetzner-robot-password
132+
// +kubebuilder:default=robot-password
133133
HetznerRobotPassword string `json:"hetznerRobotPassword"`
134134
// SSHKey defines the name of the ssh key.
135135
// +optional

config/crd/bases/infrastructure.cluster.x-k8s.io_hetznerclusters.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,17 +246,17 @@ spec:
246246
Need to specify either HCloudToken or both HetznerRobotUser and HetznerRobotPassword.
247247
properties:
248248
hcloudToken:
249-
default: hcloud-token
249+
default: token
250250
description: HCloudToken defines the name of the key where
251251
the token for the Hetzner Cloud API is stored.
252252
type: string
253253
hetznerRobotPassword:
254-
default: hetzner-robot-password
254+
default: robot-password
255255
description: HetznerRobotPassword defines the name of the
256256
key where the password for the Hetzner Robot API is stored.
257257
type: string
258258
hetznerRobotUser:
259-
default: hetzner-robot-user
259+
default: robot-user
260260
description: HetznerRobotUser defines the name of the key
261261
where the username for the Hetzner Robot API is stored.
262262
type: string
@@ -267,7 +267,13 @@ spec:
267267
type: object
268268
name:
269269
default: hetzner
270-
description: Name defines the name of the secret.
270+
description: |-
271+
Name defines the name of the secret. The name gets used for reading the credential in the
272+
mgt-cluster, and it gets used for creating a secret in the wl-cluster. About the secret in
273+
the wl-cluster: Attention, the upstream hcloud-ccm helm chart expects the name to be
274+
"hcloud". The Syself ccm defaults to "hetzner". The secret will be created in the namespace
275+
"mgt-system" of the workload-cluster. Set `spec.skipCreatingHetznerSecretInWorkloadCluster`,
276+
if you don't want that secret in the wl-cluster to be created.
271277
type: string
272278
required:
273279
- key

config/crd/bases/infrastructure.cluster.x-k8s.io_hetznerclustertemplates.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,18 +275,18 @@ spec:
275275
Need to specify either HCloudToken or both HetznerRobotUser and HetznerRobotPassword.
276276
properties:
277277
hcloudToken:
278-
default: hcloud-token
278+
default: token
279279
description: HCloudToken defines the name of the key
280280
where the token for the Hetzner Cloud API is stored.
281281
type: string
282282
hetznerRobotPassword:
283-
default: hetzner-robot-password
283+
default: robot-password
284284
description: HetznerRobotPassword defines the name
285285
of the key where the password for the Hetzner Robot
286286
API is stored.
287287
type: string
288288
hetznerRobotUser:
289-
default: hetzner-robot-user
289+
default: robot-user
290290
description: HetznerRobotUser defines the name of
291291
the key where the username for the Hetzner Robot
292292
API is stored.
@@ -298,7 +298,13 @@ spec:
298298
type: object
299299
name:
300300
default: hetzner
301-
description: Name defines the name of the secret.
301+
description: |-
302+
Name defines the name of the secret. The name gets used for reading the credential in the
303+
mgt-cluster, and it gets used for creating a secret in the wl-cluster. About the secret in
304+
the wl-cluster: Attention, the upstream hcloud-ccm helm chart expects the name to be
305+
"hcloud". The Syself ccm defaults to "hetzner". The secret will be created in the namespace
306+
"mgt-system" of the workload-cluster. Set `spec.skipCreatingHetznerSecretInWorkloadCluster`,
307+
if you don't want that secret in the wl-cluster to be created.
302308
type: string
303309
required:
304310
- key

controllers/hetznercluster_controller.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ func reconcileWorkloadClusterSecret(ctx context.Context, clusterScope *scope.Clu
533533
return fmt.Errorf("failed to acquire secret: %w", err)
534534
}
535535

536-
hetznerToken, keyExists := mgtSecret.Data[clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HCloudToken]
536+
hcloudToken, keyExists := mgtSecret.Data[clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HCloudToken]
537537
if !keyExists {
538538
return fmt.Errorf("error key %s does not exist in secret/%s: %w",
539539
clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HCloudToken,
@@ -546,7 +546,13 @@ func reconcileWorkloadClusterSecret(ctx context.Context, clusterScope *scope.Clu
546546
wlSecret.Data = make(map[string][]byte)
547547
}
548548

549-
wlSecret.Data[clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HCloudToken] = hetznerToken
549+
wlSecret.Data[clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HCloudToken] = hcloudToken
550+
551+
// upstream hcloud-ccm uses the secret key "token", while the old Syself ccm used "hcloud".
552+
// For compatibilty, we create always the other key, too.
553+
for _, key := range []string{"token", "hcloud"} {
554+
wlSecret.Data[key] = hcloudToken
555+
}
550556

551557
// Save robot credentials if available
552558
if clusterScope.HetznerCluster.Spec.HetznerSecret.Key.HetznerRobotUser != "" {

0 commit comments

Comments
 (0)