Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap kind for k3d #426

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
COCKROACH_BIN ?= https://binaries.cockroachdb.com/cockroach-v23.2.0.linux-amd64.tgz
HELM_BIN ?= https://get.helm.sh/helm-v3.14.0-linux-amd64.tar.gz
KIND_BIN ?= https://kind.sigs.k8s.io/dl/v0.21.0/kind-linux-amd64
K3D_BIN ?= https://github.com/k3d-io/k3d/releases/download/v5.7.4/k3d-linux-amd64
KUBECTL_BIN ?= https://dl.k8s.io/release/v1.29.1/bin/linux/amd64/kubectl
YQ_BIN ?= https://github.com/mikefarah/yq/releases/download/v4.31.2/yq_linux_amd64
JQ_BIN ?= https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
Expand All @@ -12,15 +12,15 @@ endif
ifeq ($(UNAME_S),Darwin)
COCKROACH_BIN ?= https://binaries.cockroachdb.com/cockroach-v23.2.0.darwin-10.9-amd64.tgz
HELM_BIN ?= https://get.helm.sh/helm-v3.14.0-darwin-amd64.tar.gz
KIND_BIN ?= https://kind.sigs.k8s.io/dl/v0.21.0/kind-darwin-amd64
K3D_BIN ?= https://github.com/k3d-io/k3d/releases/download/v5.7.4/k3d-darwin-arm64
KUBECTL_BIN ?= https://dl.k8s.io/release/v1.29.1/bin/darwin/amd64/kubectl
YQ_BIN ?= https://github.com/mikefarah/yq/releases/download/v4.31.2/yq_darwin_amd64
JQ_BIN ?= https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64
OPM_TAR ?= https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/latest-4.8/opm-mac-4.8.57.tar.gz
OPM_BIN ?= darwin-amd64-opm
endif

KIND_CLUSTER ?= chart-testing
K3D_CLUSTER ?= chart-testing
REPOSITORY ?= gcr.io/cockroachlabs-helm-charts/cockroach-self-signer-cert

export BUNDLE_IMAGE ?= cockroach-operator-bundle
Expand Down Expand Up @@ -73,26 +73,31 @@ dev/clean: ## remove built artifacts
@rm -r build/artifacts/

##@ Test
test/cluster: bin/k3d test/cluster_up ## start a local k3d cluster for testing

test/cluster: bin/kind ## start a local kind cluster for testing
@bin/kind get clusters -q | grep $(KIND_CLUSTER) || bin/kind create cluster --name $(KIND_CLUSTER)
test/cluster_up: bin/k3d
@bin/k3d cluster list | grep $(K3D_CLUSTER) || bin/k3d cluster create $(K3D_CLUSTER)

test/cluster_down: bin/k3d
bin/k3d cluster delete $(K3D_CLUSTER)

test/e2e/%: PKG=$*
test/e2e/%: bin/cockroach bin/kubectl bin/helm build/self-signer test/publish-images-to-kind ## run e2e tests for package (e.g. install or rotate)
test/e2e/%: bin/cockroach bin/kubectl bin/helm build/self-signer test/publish-images-to-k3d ## run e2e tests for package (e.g. install or rotate)
@PATH="$(PWD)/bin:${PATH}" go test -timeout 30m -v ./tests/e2e/$(PKG)/...

test/lint: bin/helm ## lint the helm chart
@build/lint.sh && bin/helm lint cockroachdb

IMAGE_LIST = cockroachdb/cockroach:v23.2.0 quay.io/jetstack/cert-manager-cainjector:v1.11.0 quay.io/jetstack/cert-manager-webhook:v1.11.0 quay.io/jetstack/cert-manager-controller:v1.11.0 quay.io/jetstack/cert-manager-ctl:v1.11.0
test/publish-images-to-kind: bin/yq test/cluster ## publish signer and cockroach image to local kind registry
test/publish-images-to-k3d: bin/yq test/cluster ## publish signer and cockroach image to local k3d registry
for i in $(IMAGE_LIST); do \
docker pull $$i; \
bin/kind load docker-image $$i --name $(KIND_CLUSTER); \
bin/k3d image import $$i -c $(K3D_CLUSTER); \
done
@bin/kind load docker-image \
docker pull ${REPOSITORY}:$(shell bin/yq '.tls.selfSigner.image.tag' ./cockroachdb/values.yaml); \
bin/k3d image import \
${REPOSITORY}:$(shell bin/yq '.tls.selfSigner.image.tag' ./cockroachdb/values.yaml) \
--name $(KIND_CLUSTER)
-c $(K3D_CLUSTER)

test/template: bin/cockroach bin/helm ## Run template tests
@PATH="$(PWD)/bin:${PATH}" go test -v ./tests/template/...
Expand All @@ -101,7 +106,7 @@ test/units: bin/cockroach ## Run unit tests in ./pkg/...
@PATH="$(PWD)/bin:${PATH}" go test -v ./pkg/...

##@ Binaries
bin: bin/cockroach bin/helm bin/kind bin/kubectl bin/yq ## install all binaries
bin: bin/cockroach bin/helm bin/k3d bin/kubectl bin/yq ## install all binaries

bin/cockroach: ## install cockroach
@mkdir -p bin
Expand All @@ -113,10 +118,10 @@ bin/helm: ## install helm
@curl -L $(HELM_BIN) | tar -xzf - -C bin/ --strip-components 1
@rm -f bin/README.md bin/LICENSE

bin/kind: ## install kind
bin/k3d: ## install k3d
@mkdir -p bin
@curl -Lo bin/kind $(KIND_BIN)
@chmod +x bin/kind
@curl -Lo bin/k3d $(K3D_BIN)
@chmod +x bin/k3d

bin/kubectl: ## install kubectl
@mkdir -p bin
Expand Down
Loading