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+ HELM ?= $(LOCALBIN ) /helm
11+ HELM_VERSION ?= v3.16.3
12+
13+ # ####################################################################
14+ # Dev Setup
15+ # ####################################################################
16+ CLUSTER_NAME ?= ccm-$(shell git rev-parse --short HEAD)
17+ K8S_VERSION ?= "v1.31.2"
18+ CAPI_VERSION ?= "v1.6.3"
19+ CAAPH_VERSION ?= "v0.2.1"
20+ CAPL_VERSION ?= "v0.7.1"
21+ CONTROLPLANE_NODES ?= 1
22+ WORKER_NODES ?= 1
23+ LINODE_FIREWALL_ENABLED ?= true
24+ LINODE_REGION ?= us-lax
25+ LINODE_OS ?= linode/ubuntu22.04
26+ KUBECONFIG_PATH ?= $(CURDIR ) /test-cluster-kubeconfig.yaml
1027
1128# if the $DEVBOX_PACKAGES_DIR env variable exists that means we are within a devbox shell and can safely
1229# use devbox's bin for our tools
@@ -41,10 +58,15 @@ vet: fmt
4158
4259.PHONY : lint
4360lint :
44- docker run --rm -v " $( shell pwd) :/var/work:ro" -w /var/work \
45- golangci/golangci-lint:v1.57.2 golangci-lint run -v --timeout=5m
46- docker run --rm -v " $( shell pwd) :/var/work:ro" -w /var/work/e2e \
47- golangci/golangci-lint:v1.57.2 golangci-lint run -v --timeout=5m
61+ docker run --rm -v " $( PWD) :/var/work:ro" -w /var/work \
62+ golangci/golangci-lint:latest golangci-lint run -v --timeout=5m
63+ docker run --rm -v " $( PWD) :/var/work:ro" -w /var/work/e2e \
64+ golangci/golangci-lint:latest golangci-lint run -v --timeout=5m
65+
66+ .PHONY : gosec
67+ gosec : # # Run gosec against code.
68+ docker run --rm -v " $( PWD) :/var/work:ro" -w /var/work securego/gosec:2.19.0 \
69+ -exclude-dir=bin -exclude-generated ./...
4870
4971.PHONY : fmt
5072fmt :
@@ -88,9 +110,11 @@ docker-build: build-linux
88110.PHONY : docker-push
89111# must run the docker build before pushing the image
90112docker-push :
91- echo " [reminder] Did you run ` make docker-build` ?"
92113 docker push ${IMG}
93114
115+ .PHONY : docker-setup
116+ docker-setup : docker-build docker-push
117+
94118.PHONY : run
95119# run the ccm locally, really only makes sense on linux anyway
96120run : build
@@ -108,6 +132,66 @@ run-debug: build
108132 --kubeconfig=${KUBECONFIG} \
109133 --linodego-debug
110134
135+ # ####################################################################
136+ # E2E Test Setup
137+ # ####################################################################
138+
139+ .PHONY : mgmt-and-capl-cluster
140+ mgmt-and-capl-cluster : docker-setup mgmt-cluster capl-cluster
141+
142+ .PHONY : capl-cluster
143+ capl-cluster : generate-capl-cluster-manifests create-capl-cluster patch-linode-ccm
144+
145+ .PHONY : generate-capl-cluster-manifests
146+ generate-capl-cluster-manifests :
147+ # Create the CAPL cluster manifests without any CSI driver stuff
148+ LINODE_FIREWALL_ENABLED=$(LINODE_FIREWALL_ENABLED ) LINODE_OS=$(LINODE_OS ) clusterctl generate cluster $(CLUSTER_NAME ) \
149+ --kubernetes-version $(K8S_VERSION ) --infrastructure linode-linode:$(CAPL_VERSION ) \
150+ --control-plane-machine-count $(CONTROLPLANE_NODES ) --worker-machine-count $(WORKER_NODES ) > capl-cluster-manifests.yaml
151+
152+ .PHONY : create-capl-cluster
153+ create-capl-cluster :
154+ # Create a CAPL cluster with updated CCM and wait for it to be ready
155+ kubectl apply -f capl-cluster-manifests.yaml
156+ 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)
157+ kubectl wait --for=condition=NodeHealthy=true machines -l cluster.x-k8s.io/cluster-name=$(CLUSTER_NAME ) --timeout=900s
158+ clusterctl get kubeconfig $(CLUSTER_NAME ) > $(KUBECONFIG_PATH )
159+ KUBECONFIG=$(KUBECONFIG_PATH ) kubectl wait --for=condition=Ready nodes --all --timeout=600s
160+ # Remove all taints from control plane node so that pods scheduled on it by tests can run (without this, some tests fail)
161+ KUBECONFIG=$(KUBECONFIG_PATH ) kubectl taint nodes -l node-role.kubernetes.io/control-plane node-role.kubernetes.io/control-plane-
162+
163+ .PHONY : patch-linode-ccm
164+ patch-linode-ccm :
165+ 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} '}]"
166+ KUBECONFIG=$(KUBECONFIG_PATH ) kubectl rollout status -n kube-system daemonset/ccm-linode --timeout=600s
167+ KUBECONFIG=$(KUBECONFIG_PATH ) kubectl -n kube-system get daemonset/ccm-linode -o yaml
168+
169+ .PHONY : mgmt-cluster
170+ mgmt-cluster :
171+ # Create a mgmt cluster
172+ ctlptl apply -f e2e/setup/ctlptl-config.yaml
173+ clusterctl init \
174+ --wait-providers \
175+ --wait-provider-timeout 600 \
176+ --core cluster-api:$(CAPI_VERSION ) \
177+ --addon helm:$(CAAPH_VERSION ) \
178+ --infrastructure linode-linode:$(CAPL_VERSION )
179+
180+ .PHONY : cleanup-cluster
181+ cleanup-cluster :
182+ kubectl delete cluster -A --all --timeout=180s
183+ kubectl delete linodefirewalls -A --all --timeout=60s
184+ kubectl delete lvpc -A --all --timeout=60s
185+ kind delete cluster -n caplccm
186+
187+ .PHONY : e2e-test
188+ e2e-test :
189+ $(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/"
190+
191+ # ####################################################################
192+ # OS / ARCH
193+ # ####################################################################
194+
111195# Set the host's OS. Only linux and darwin supported for now
112196HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
113197ifeq ($(filter darwin linux,$(HOSTOS ) ) ,)
@@ -121,9 +205,6 @@ else ifeq ($(ARCH_SHORT),aarch64)
121205ARCH_SHORT := arm64
122206endif
123207
124- HELM ?= $(LOCALBIN ) /helm
125- HELM_VERSION ?= v3.9.1
126-
127208.PHONY : helm
128209helm : $(HELM ) # # Download helm locally if necessary
129210$(HELM ) : $(LOCALBIN )
0 commit comments