Skip to content

Commit a6979e0

Browse files
committed
make makefile target install-ccm-in-wl-cluster work again.
1 parent 4aea658 commit a6979e0

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,5 @@ watchall-output*
8383
/conditions*.txt
8484

8585
/.config
86+
87+
/.kube

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ install-cilium-in-wl-cluster:
192192
-f templates/cilium/cilium.yaml
193193

194194

195-
install-ccm-in-wl-cluster:
195+
install-ccm-in-wl-cluster: $(WORKER_CLUSTER_KUBECONFIG)
196196
ifeq ($(BUILD_IN_CONTAINER),true)
197197
docker run --rm \
198+
-e CLUSTER_NAME=$(CLUSTER_NAME) \
199+
-e KUBECONFIG=$(KUBECONFIG) \
198200
-v $(shell go env GOPATH)/pkg:/go/pkg$(MOUNT_FLAGS) \
199201
-v $(shell pwd):/src/cluster-api-provider-$(INFRA_PROVIDER)$(MOUNT_FLAGS) \
200202
$(BUILDER_IMAGE):$(BUILDER_IMAGE_VERSION) $@;
@@ -438,6 +440,7 @@ $(ARTIFACTS):
438440
$(MGT_CLUSTER_KUBECONFIG):
439441
./hack/get-kubeconfig-of-management-cluster.sh
440442

443+
.PHONY: $(WORKER_CLUSTER_KUBECONFIG)
441444
$(WORKER_CLUSTER_KUBECONFIG):
442445
./hack/get-kubeconfig-of-workload-cluster.sh
443446

controllers/hetznercluster_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ func reconcileOneWorkloadClusterSecret(ctx context.Context, clusterScope *scope.
595595
}
596596

597597
if clusterScope.HetznerCluster.Spec.HetznerSecret.Name != "hcloud" {
598-
notes = append(notes, fmt.Sprintf("We recommend to use 'hcloud' for hetznercluster.spec.hetznerSecret.name(not %q).",
598+
notes = append(notes, fmt.Sprintf("We recommend to use 'hcloud' for hetznercluster.spec.hetznerSecret.name (not %q).",
599599
clusterScope.HetznerCluster.Spec.HetznerSecret.Name))
600600
}
601601

hack/get-kubeconfig-of-workload-cluster.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,26 @@
1616

1717
set -euo pipefail
1818

19-
if [ -z "$CLUSTER_NAME" ]; then
19+
if [ -z "${CLUSTER_NAME:-}" ]; then
2020
echo "env var CLUSTER_NAME is missing. Failed to get kubeconfig of workload cluster"
2121
exit 1
2222
fi
23+
24+
if [ -z "${KUBECONFIG:-}" ]; then
25+
echo "env var KUBECONFIG (for mgt-cluster) is missing. Failed to get kubeconfig of workload cluster"
26+
exit 1
27+
fi
28+
29+
if [[ ! -e $KUBECONFIG ]]; then
30+
echo "KUBECONFIG=$KUBECONFIG file does not exist! Failed to get kubeconfig of workload cluster"
31+
exit 1
32+
fi
33+
2334
kubeconfig=".workload-cluster-kubeconfig.yaml"
24-
new_content="$(kubectl get secrets "${CLUSTER_NAME}-kubeconfig" -ojsonpath='{.data.value}' | base64 -d)"
35+
if ! new_content="$(kubectl get secrets "${CLUSTER_NAME}-kubeconfig" -ojsonpath='{.data.value}' 2>/dev/null | base64 -d)"; then
36+
echo "error: Failed to get kubeconfig of wl-cluster"
37+
exit 1
38+
fi
2539

2640
if [ -z "$new_content" ]; then
2741
echo "failed to get kubeconfig of workload cluster"

0 commit comments

Comments
 (0)