diff --git a/Makefile b/Makefile index 18ce32909f..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,27 +410,33 @@ 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 +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 +endif # Symlink the installed helm client if the correct version is already # 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')) $(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 +endif # Symlink the installed k3d client if the correct version is already # installed, otherwise downloads it. @@ -440,30 +446,36 @@ 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)) + 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 +endif # Symlink the installed jq client if the correct version is already # 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 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 +485,13 @@ 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)) + 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 +endif .PHONY: helm/repos helm/repos: local-dev/helm @@ -761,3 +776,22 @@ k3d/clean: local-dev/k3d ifeq ($(ARCH), darwin) docker rm --force $(CI_BUILD_TAG)-k3d-proxy-32080 || true 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