1- IMG ?= linode/linode-cloud-controller-manager:canary
2- RELEASE_DIR ?= release
3- PLATFORM ?= linux/amd64
1+ IMG ?= linode/linode-cloud-controller-manager:canary
2+ RELEASE_DIR ?= release
3+ PLATFORM ?= linux/amd64
44
55# Use CACHE_BIN for tools that cannot use devbox and LOCALBIN for tools that can use either method
6- CACHE_BIN ?= $(CURDIR ) /bin
7- LOCALBIN ?= $(CACHE_BIN )
8-
9- DEVBOX_BIN ?= $(DEVBOX_PACKAGES_DIR ) /bin
6+ CACHE_BIN ?= $(CURDIR ) /bin
7+ LOCALBIN ?= $(CACHE_BIN )
8+
9+ DEVBOX_BIN ?= $(DEVBOX_PACKAGES_DIR ) /bin
10+
11+ # ####################################################################
12+ # Dev Setup
13+ # ####################################################################
14+ CLUSTER_NAME ?= ccm-$(shell git rev-parse --short HEAD)
15+ K8S_VERSION ?= "v1.29.1"
16+ CAPI_VERSION ?= "v1.6.3"
17+ HELM_VERSION ?= "v0.2.1"
18+ CAPL_VERSION ?= "v0.7.1"
19+ CONTROLPLANE_NODES ?= 1
20+ WORKER_NODES ?= 1
21+ LINODE_FIREWALL_ENABLED ?= true
22+ LINODE_REGION ?= us-lax
23+ KUBECONFIG_PATH ?= $(CURDIR ) /test-cluster-kubeconfig.yaml
1024
1125# if the $DEVBOX_PACKAGES_DIR env variable exists that means we are within a devbox shell and can safely
1226# use devbox's bin for our tools
@@ -88,9 +102,11 @@ docker-build: build-linux
88102.PHONY : docker-push
89103# must run the docker build before pushing the image
90104docker-push :
91- echo " [reminder] Did you run ` make docker-build` ?"
92105 docker push ${IMG}
93106
107+ .PHONY : docker-setup
108+ docker-setup : docker-build docker-push
109+
94110.PHONY : run
95111# run the ccm locally, really only makes sense on linux anyway
96112run : build
@@ -108,6 +124,66 @@ run-debug: build
108124 --kubeconfig=${KUBECONFIG} \
109125 --linodego-debug
110126
127+ # ####################################################################
128+ # E2E Test Setup
129+ # ####################################################################
130+
131+ .PHONY : mgmt-and-capl-cluster
132+ mgmt-and-capl-cluster : docker-setup mgmt-cluster capl-cluster
133+
134+ .PHONY : capl-cluster
135+ capl-cluster : generate-capl-cluster-manifests create-capl-cluster patch-linode-ccm
136+
137+ .PHONY : generate-capl-cluster-manifests
138+ generate-capl-cluster-manifests :
139+ # Create the CAPL cluster manifests without any CSI driver stuff
140+ LINODE_FIREWALL_ENABLED=$(LINODE_FIREWALL_ENABLED ) clusterctl generate cluster $(CLUSTER_NAME ) \
141+ --kubernetes-version $(K8S_VERSION ) \
142+ --infrastructure linode-linode:$(CAPL_VERSION ) \
143+ --control-plane-machine-count $(CONTROLPLANE_NODES ) --worker-machine-count $(WORKER_NODES ) > capl-cluster-manifests.yaml
144+
145+ .PHONY : create-capl-cluster
146+ create-capl-cluster :
147+ # Create a CAPL cluster with updated CCM and wait for it to be ready
148+ kubectl apply -f capl-cluster-manifests.yaml
149+ kubectl wait --for=condition=ControlPlaneReady cluster/$(CLUSTER_NAME ) --timeout=600s || (kubectl get cluster -o yaml; kubectl get linodecluster -o yaml; kubectl get linodemachines -o yaml)
150+ kubectl wait --for=condition=NodeHealthy=true machines -l cluster.x-k8s.io/cluster-name=$(CLUSTER_NAME ) --timeout=900s
151+ clusterctl get kubeconfig $(CLUSTER_NAME ) > $(KUBECONFIG_PATH )
152+ KUBECONFIG=$(KUBECONFIG_PATH ) kubectl wait --for=condition=Ready nodes --all --timeout=600s
153+ # Remove all taints so that pods can be scheduled anywhere (without this, some tests fail)
154+ KUBECONFIG=$(KUBECONFIG_PATH ) kubectl taint nodes -l node-role.kubernetes.io/control-plane node-role.kubernetes.io/control-plane-
155+
156+ .PHONY : patch-linode-ccm
157+ patch-linode-ccm :
158+ KUBECONFIG=$(KUBECONFIG_PATH ) kubectl patch -n kube-system daemonset ccm-linode --type=' json' -p=" [{'op': 'replace', 'path': '/spec/template/spec/containers/0/image', 'value': '${IMG} '}]"
159+ KUBECONFIG=$(KUBECONFIG_PATH ) kubectl rollout status -n kube-system daemonset/ccm-linode --timeout=600s
160+
161+ .PHONY : mgmt-cluster
162+ mgmt-cluster :
163+ # Create a mgmt cluster
164+ ctlptl apply -f e2e/setup/ctlptl-config.yaml
165+ clusterctl init \
166+ --wait-providers \
167+ --wait-provider-timeout 600 \
168+ --core cluster-api:$(CAPI_VERSION ) \
169+ --addon helm:$(HELM_VERSION ) \
170+ --infrastructure linode-linode:$(CAPL_VERSION )
171+
172+ .PHONY : cleanup-cluster
173+ cleanup-cluster :
174+ kubectl delete cluster --all
175+ kubectl delete linodefirewalls --all
176+ kubectl delete lvpc --all
177+ kind delete cluster -n caplccm
178+
179+ .PHONY : e2e-test
180+ e2e-test :
181+ $(MAKE ) -C e2e test LINODE_API_TOKEN=$(LINODE_TOKEN ) SUITE_ARGS=" --region=$( LINODE_REGION) --use-existing --timeout=5m --kubeconfig=$( KUBECONFIG_PATH) --image=$( IMG) --linode-url https://api.linode.com/"
182+
183+ # ####################################################################
184+ # OS / ARCH
185+ # ####################################################################
186+
111187# Set the host's OS. Only linux and darwin supported for now
112188HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
113189ifeq ($(filter darwin linux,$(HOSTOS ) ) ,)
0 commit comments