From 634396e8286aa418a096497e509fe44ab3f497a9 Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Mon, 30 Sep 2024 10:38:31 +1000 Subject: [PATCH 1/4] refactor:(make) dont download binaries if theyre already present --- Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 18ce32909f..c517bc8e0a 100644 --- a/Makefile +++ b/Makefile @@ -414,10 +414,12 @@ ifeq ($(KUBECTL_VERSION), $(shell kubectl version --short --client 2>/dev/null | $(info linking local kubectl version $(KUBECTL_VERSION)) ln -sf $(shell command -v kubectl) ./local-dev/kubectl else +ifeq ($(KUBECTL_VERSION), $(shell kubectl version --short --client 2>/dev/null | sed -E 's/Client Version: v([0-9.]+).*/\1/')) $(info downloading kubectl version $(KUBECTL_VERSION) for $(ARCH)) curl -sSLo local-dev/kubectl https://storage.googleapis.com/kubernetes-release/release/$(KUBECTL_VERSION)/bin/$(ARCH)/amd64/kubectl chmod a+x local-dev/kubectl endif +endif # Symlink the installed helm client if the correct version is already # installed, otherwise downloads it. @@ -427,10 +429,12 @@ ifeq ($(HELM_VERSION), $(shell helm version --short --client 2>/dev/null | sed - $(info linking local helm version $(HELM_VERSION)) ln -sf $(shell command -v helm) ./local-dev/helm else +ifneq ($(HELM_VERSION), v$(shell ./local-dev/helm version --short --client 2>/dev/null | sed -nE 's/v([0-9.]+).*/\1/p')) $(info downloading helm version $(HELM_VERSION) for $(ARCH)) curl -sSL https://get.helm.sh/helm-$(HELM_VERSION)-$(ARCH)-amd64.tar.gz | tar -xzC local-dev --strip-components=1 $(ARCH)-amd64/helm chmod a+x local-dev/helm endif +endif # Symlink the installed k3d client if the correct version is already # installed, otherwise downloads it. @@ -440,10 +444,12 @@ ifeq ($(K3D_VERSION), $(shell k3d version 2>/dev/null | sed -nE 's/k3d version ( $(info linking local k3d version $(K3D_VERSION)) ln -sf $(shell command -v k3d) ./local-dev/k3d else +ifneq ($(K3D_VERSION), $(shell ./local-dev/k3d version 2>/dev/null | sed -nE 's/k3d version (v[0-9.]+).*/\1/p')) $(info downloading k3d version $(K3D_VERSION) for $(ARCH)) curl -sSLo local-dev/k3d https://github.com/k3d-io/k3d/releases/download/$(K3D_VERSION)/k3d-$(ARCH)-amd64 chmod a+x local-dev/k3d endif +endif # Symlink the installed jq client if the correct version is already # installed, otherwise downloads it. @@ -453,6 +459,7 @@ ifeq ($(GOJQ_VERSION), $(shell jq -v 2>/dev/null | sed -nE 's/gojq ([0-9.]+).*/v $(info linking local jq version $(GOJQ_VERSION)) ln -sf $(shell command -v jq) ./local-dev/jq else +ifneq ($(GOJQ_VERSION), $(shell ./local-dev/jq -v 2>/dev/null | sed -nE 's/gojq ([0-9.]+).*/v\1/p')) $(info downloading gojq version $(GOJQ_VERSION) for $(ARCH)) ifeq ($(ARCH), darwin) TMPDIR=$$(mktemp -d) \ @@ -464,6 +471,7 @@ else endif chmod a+x local-dev/jq endif +endif # Symlink the installed stern client if the correct version is already # installed, otherwise downloads it. @@ -473,10 +481,12 @@ ifeq ($(STERN_VERSION), $(shell stern --version 2>/dev/null | sed -nE 's/stern v $(info linking local stern version $(STERN_VERSION)) ln -sf $(shell command -v stern) ./local-dev/stern else +ifneq ($(STERN_VERSION), v$(shell ./local-dev/stern --version 2>/dev/null | sed -nE 's/stern version //p')) $(info downloading stern version $(STERN_VERSION) for $(ARCH)) curl -sSLo local-dev/stern https://github.com/derdanne/stern/releases/download/$(STERN_VERSION)/stern_$(ARCH)_amd64 chmod a+x local-dev/stern endif +endif .PHONY: helm/repos helm/repos: local-dev/helm @@ -760,4 +770,4 @@ k3d/clean: local-dev/k3d $(K3D) cluster delete $(CI_BUILD_TAG) ifeq ($(ARCH), darwin) docker rm --force $(CI_BUILD_TAG)-k3d-proxy-32080 || true -endif +endif \ No newline at end of file From c33440d69253b3a995c5a4d951c3f88f01fe311a Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Mon, 30 Sep 2024 10:38:54 +1000 Subject: [PATCH 2/4] chore:(make) add commands to clean up unused charts and config references --- Makefile | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c517bc8e0a..c5dfde5dbb 100644 --- a/Makefile +++ b/Makefile @@ -770,4 +770,23 @@ k3d/clean: local-dev/k3d $(K3D) cluster delete $(CI_BUILD_TAG) ifeq ($(ARCH), darwin) docker rm --force $(CI_BUILD_TAG)-k3d-proxy-32080 || true -endif \ No newline at end of file +endif + +# clean up any old charts to prevent bloating of old charts from running k3d stacks regularly +.PHONY: k3d/clean-charts +k3d/clean-charts: + @for chart in $$(ls -1 | grep lagoon-charts | egrep -v "lagoon-charts.k3d|$$(ls -l | grep -o "lagoon-charts.k3d.lagoon.*" | awk '{print $$3}' | cut -c 3-)") ; do \ + echo removing chart directory $$chart ; \ + rm -rf $$chart ; \ + done + +# clean up any old k3d kubeconfigs +.PHONY: k3d/clean-k3dconfigs +k3d/clean-k3dconfigs: + @for kubeconfig in $$(ls -1 | grep k3dconfig) ; do \ + echo removing k3dconfig $$kubeconfig ; \ + rm $$kubeconfig ; \ + done + +.PHONY: k3d/clean-all +k3d/clean-all: k3d/clean k3d/clean-k3dconfigs k3d/clean-charts \ No newline at end of file From a9c48c78b4a2a2b3abcb1f6621b5df5a7d4f67e4 Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Mon, 30 Sep 2024 10:59:17 +1000 Subject: [PATCH 3/4] fix: local-dev/kubectl checks --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c5dfde5dbb..d61479a633 100644 --- a/Makefile +++ b/Makefile @@ -410,11 +410,11 @@ DOCKER_NETWORK = k3d # installed, otherwise downloads it. .PHONY: local-dev/kubectl local-dev/kubectl: -ifeq ($(KUBECTL_VERSION), $(shell kubectl version --short --client 2>/dev/null | sed -E 's/Client Version: v([0-9.]+).*/\1/')) +ifeq ($(KUBECTL_VERSION), $(shell kubectl version --client 2>/dev/null | grep Client | sed -E 's/Client Version: v([0-9.]+).*/\1/')) $(info linking local kubectl version $(KUBECTL_VERSION)) ln -sf $(shell command -v kubectl) ./local-dev/kubectl else -ifeq ($(KUBECTL_VERSION), $(shell kubectl version --short --client 2>/dev/null | sed -E 's/Client Version: v([0-9.]+).*/\1/')) +ifneq ($(KUBECTL_VERSION), v$(shell ./local-dev/kubectl version --client 2>/dev/null | grep Client | sed -E 's/Client Version: v([0-9.]+).*/\1/')) $(info downloading kubectl version $(KUBECTL_VERSION) for $(ARCH)) curl -sSLo local-dev/kubectl https://storage.googleapis.com/kubernetes-release/release/$(KUBECTL_VERSION)/bin/$(ARCH)/amd64/kubectl chmod a+x local-dev/kubectl From 89f634ca86937872d52a1cdafb0d3871eb7db053 Mon Sep 17 00:00:00 2001 From: Toby Bellwood Date: Mon, 14 Oct 2024 10:58:49 +1100 Subject: [PATCH 4/4] chore: more compatibility fixes --- Makefile | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index d61479a633..92849952d3 100644 --- a/Makefile +++ b/Makefile @@ -394,7 +394,7 @@ compose-api-logs-development: KUBECTL_VERSION := v1.31.0 HELM_VERSION := v3.16.1 -K3D_VERSION = v5.7.4 +K3D_VERSION = v5.7.3 GOJQ_VERSION = v0.12.16 STERN_VERSION = v2.6.1 CHART_TESTING_VERSION = v3.11.0 @@ -410,12 +410,13 @@ DOCKER_NETWORK = k3d # installed, otherwise downloads it. .PHONY: local-dev/kubectl local-dev/kubectl: -ifeq ($(KUBECTL_VERSION), $(shell kubectl version --client 2>/dev/null | grep Client | sed -E 's/Client Version: v([0-9.]+).*/\1/')) +ifeq ($(KUBECTL_VERSION), $(shell kubectl version --client 2>/dev/null | grep Client | sed -E 's/Client Version: (v[0-9.]+).*/\1/')) $(info linking local kubectl version $(KUBECTL_VERSION)) ln -sf $(shell command -v kubectl) ./local-dev/kubectl else -ifneq ($(KUBECTL_VERSION), v$(shell ./local-dev/kubectl version --client 2>/dev/null | grep Client | sed -E 's/Client Version: v([0-9.]+).*/\1/')) +ifneq ($(KUBECTL_VERSION), v$(shell ./local-dev/kubectl version --client 2>/dev/null | grep Client | sed -E 's/Client Version: (v[0-9.]+).*/\1/')) $(info downloading kubectl version $(KUBECTL_VERSION) for $(ARCH)) + rm local-dev/kubectl || true curl -sSLo local-dev/kubectl https://storage.googleapis.com/kubernetes-release/release/$(KUBECTL_VERSION)/bin/$(ARCH)/amd64/kubectl chmod a+x local-dev/kubectl endif @@ -425,12 +426,13 @@ endif # installed, otherwise downloads it. .PHONY: local-dev/helm local-dev/helm: -ifeq ($(HELM_VERSION), $(shell helm version --short --client 2>/dev/null | sed -nE 's/v([0-9.]+).*/\1/p')) +ifeq ($(HELM_VERSION), $(shell helm version --short --client 2>/dev/null | sed -nE 's/(v[0-9.]+).*/\1/p')) $(info linking local helm version $(HELM_VERSION)) ln -sf $(shell command -v helm) ./local-dev/helm else -ifneq ($(HELM_VERSION), v$(shell ./local-dev/helm version --short --client 2>/dev/null | sed -nE 's/v([0-9.]+).*/\1/p')) +ifneq ($(HELM_VERSION), v$(shell ./local-dev/helm version --short --client 2>/dev/null | sed -nE 's/(v[0-9.]+).*/\1/p')) $(info downloading helm version $(HELM_VERSION) for $(ARCH)) + rm local-dev/helm || true curl -sSL https://get.helm.sh/helm-$(HELM_VERSION)-$(ARCH)-amd64.tar.gz | tar -xzC local-dev --strip-components=1 $(ARCH)-amd64/helm chmod a+x local-dev/helm endif @@ -446,6 +448,7 @@ ifeq ($(K3D_VERSION), $(shell k3d version 2>/dev/null | sed -nE 's/k3d version ( else ifneq ($(K3D_VERSION), $(shell ./local-dev/k3d version 2>/dev/null | sed -nE 's/k3d version (v[0-9.]+).*/\1/p')) $(info downloading k3d version $(K3D_VERSION) for $(ARCH)) + rm local-dev/k3d || true curl -sSLo local-dev/k3d https://github.com/k3d-io/k3d/releases/download/$(K3D_VERSION)/k3d-$(ARCH)-amd64 chmod a+x local-dev/k3d endif @@ -455,16 +458,17 @@ endif # installed, otherwise downloads it. .PHONY: local-dev/jq local-dev/jq: -ifeq ($(GOJQ_VERSION), $(shell jq -v 2>/dev/null | sed -nE 's/gojq ([0-9.]+).*/v\1/p')) - $(info linking local jq version $(GOJQ_VERSION)) - ln -sf $(shell command -v jq) ./local-dev/jq +ifeq ($(GOJQ_VERSION), $(shell gojq -v 2>/dev/null | sed -nE 's/gojq ([0-9.]+).*/v\1/p')) + $(info linking local gojq version $(GOJQ_VERSION)) + ln -sf $(shell command -v gojq) ./local-dev/jq else ifneq ($(GOJQ_VERSION), $(shell ./local-dev/jq -v 2>/dev/null | sed -nE 's/gojq ([0-9.]+).*/v\1/p')) $(info downloading gojq version $(GOJQ_VERSION) for $(ARCH)) + rm local-dev/jq || true ifeq ($(ARCH), darwin) TMPDIR=$$(mktemp -d) \ - && curl -sSL https://github.com/itchyny/gojq/releases/download/$(GOJQ_VERSION)/gojq_$(GOJQ_VERSION)_$(ARCH)_amd64.zip -o $$TMPDIR/gojq.zip \ - && (cd $$TMPDIR && unzip gojq.zip) && cp $$TMPDIR/gojq_$(GOJQ_VERSION)_$(ARCH)_amd64/gojq ./local-dev/jq && rm -rf $$TMPDIR + && curl -sSL https://github.com/itchyny/gojq/releases/download/$(GOJQ_VERSION)/gojq_$(GOJQ_VERSION)_$(ARCH)_arm64.zip -o $$TMPDIR/gojq.zip \ + && (cd $$TMPDIR && unzip gojq.zip) && cp $$TMPDIR/gojq_$(GOJQ_VERSION)_$(ARCH)_arm64/gojq ./local-dev/jq && rm -rf $$TMPDIR else curl -sSL https://github.com/itchyny/gojq/releases/download/$(GOJQ_VERSION)/gojq_$(GOJQ_VERSION)_$(ARCH)_amd64.tar.gz | tar -xzC local-dev --strip-components=1 gojq_$(GOJQ_VERSION)_$(ARCH)_amd64/gojq mv ./local-dev/{go,}jq @@ -483,6 +487,7 @@ ifeq ($(STERN_VERSION), $(shell stern --version 2>/dev/null | sed -nE 's/stern v else ifneq ($(STERN_VERSION), v$(shell ./local-dev/stern --version 2>/dev/null | sed -nE 's/stern version //p')) $(info downloading stern version $(STERN_VERSION) for $(ARCH)) + rm local-dev/stern || true curl -sSLo local-dev/stern https://github.com/derdanne/stern/releases/download/$(STERN_VERSION)/stern_$(ARCH)_amd64 chmod a+x local-dev/stern endif @@ -789,4 +794,4 @@ k3d/clean-k3dconfigs: done .PHONY: k3d/clean-all -k3d/clean-all: k3d/clean k3d/clean-k3dconfigs k3d/clean-charts \ No newline at end of file +k3d/clean-all: k3d/clean k3d/clean-k3dconfigs k3d/clean-charts