Skip to content

Commit 94fdbf5

Browse files
committed
Create Makefile target for a fresh kind cluster
1 parent b2bee1d commit 94fdbf5

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

workspaces/controller/Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,37 @@ vet: ## Run go vet against code.
6363
test: manifests generate fmt vet envtest ## Run tests.
6464
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out
6565

66+
# Creates a local Kubernetes cluster named kind-notebooks. By default, it proceeds to install essential cluster components: cert-manager and metrics-server.
67+
# Metrics Server installation can be optionally skipped via a flag.
68+
# - INSTALL_METRICS_SERVER=false
69+
# Override cluster name with:
70+
# - CLUSTER_NAME=<your-custom-name>
71+
CLUSTER_NAME ?= kind-notebooks
72+
INSTALL_METRICS_SERVER ?= true
73+
74+
.PHONY: kind-notebooks
75+
kind-notebooks:
76+
KIND_EXPERIMENTAL_PROVIDER=$(CONTAINER_TOOL) kind delete cluster --name $(CLUSTER_NAME) || true
77+
KIND_EXPERIMENTAL_PROVIDER=$(CONTAINER_TOOL) kind create cluster --name $(CLUSTER_NAME)
78+
79+
@echo "--- Installing cert-manager ---"
80+
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/latest/download/cert-manager.yaml
81+
82+
kubectl wait --for=condition=Available deployment/cert-manager -n cert-manager --timeout=300s
83+
@echo "Cert Manager installed. Version: $$(bash -c "kubectl get deployment cert-manager -n cert-manager -o jsonpath='{.spec.template.spec.containers[0].image}' | cut -d: -f2")"
84+
ifeq ($(INSTALL_METRICS_SERVER),true)
85+
@echo "--- Installing metrics-server ---"
86+
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
87+
kubectl patch deployment metrics-server --namespace kube-system --type='json' --patch='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--kubelet-insecure-tls"}]'
88+
89+
kubectl wait --for=condition=Available deployment/metrics-server -n kube-system --timeout=300s
90+
@echo "Metrics Server installed. Version: $$(bash -c "kubectl get deployment metrics-server -n kube-system -o jsonpath='{.spec.template.spec.containers[0].image}' | cut -d: -f2")"
91+
else
92+
@echo "--- Skipping metrics-server installation (INSTALL_METRICS_SERVER set to $(INSTALL_METRICS_SERVER)) ---"
93+
endif
94+
@echo "--- Setting the current context to $(CLUSTER_NAME) cluster ---"
95+
kubectl config set-context kind-$(CLUSTER_NAME) --namespace=workspace-controller-system
96+
6697
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
6798
# Prometheus and CertManager are installed by default; skip with:
6899
# - PROMETHEUS_INSTALL_SKIP=true

0 commit comments

Comments
 (0)