|  | 
| 3 | 3 | KUBEBUILDER_VERSION ?= 2.3.1 | 
| 4 | 4 | KUBEBUILDER ?= /usr/local/kubebuilder/bin/kubebuilder | 
| 5 | 5 | 
 | 
|  | 6 | +CERTMANAGER_URL ?= https://github.com/jetstack/cert-manager/releases/download/v0.14.1/cert-manager.yaml | 
|  | 7 | + | 
| 6 | 8 | GIT_VERSION?=$(shell git log -1 --format="%h") | 
| 7 | 9 | RELEASE_TAG ?= $(shell git tag --points-at HEAD) | 
| 8 | 10 | 
 | 
|  | 
| 56 | 58 | GOBIN=$(shell go env GOBIN) | 
| 57 | 59 | endif | 
| 58 | 60 | 
 | 
|  | 61 | +# where we store downloaded core | 
|  | 62 | +COREPATH ?= out/core | 
|  | 63 | +CORE_VERSION ?= v0.3.5 | 
|  | 64 | +CORE_API ?= https://api.github.com/repos/kubernetes-sigs/cluster-api/releases | 
|  | 65 | +CORE_URL ?= https://github.com/kubernetes-sigs/cluster-api/releases/download/$(CORE_VERSION) | 
|  | 66 | + | 
| 59 | 67 | # useful function | 
| 60 | 68 | word-dot = $(word $2,$(subst ., ,$1)) | 
| 61 | 69 | 
 | 
| @@ -222,3 +230,20 @@ $(MANAGERLESS_CLUSTERCTLYAML): $(MANAGERLESS_BASE) | 
| 222 | 230 | 	@cat $(CLUSTERCTL_TEMPLATE) | sed 's%URL%$(FULL_MANAGERLESS_MANIFEST)%g' > $@ | 
| 223 | 231 | 	@echo "managerless ready, command-line is:" | 
| 224 | 232 | 	@echo "	clusterctl --config=$@ <commands>" | 
|  | 233 | + | 
|  | 234 | +$(COREPATH): | 
|  | 235 | +	mkdir -p $@ | 
|  | 236 | + | 
|  | 237 | +$(COREPATH)/%: | 
|  | 238 | +	curl -s -L -o $@ $(CORE_URL)/$* | 
|  | 239 | + | 
|  | 240 | +core: $(COREPATH) | 
|  | 241 | +	# download from core | 
|  | 242 | +	@$(eval YAMLS := $(shell curl -s -L $(CORE_API) | jq -r '[.[] | select(.tag_name == "$(CORE_VERSION)").assets[] | select(.name | contains("yaml")) | .name] | join(" ")')) | 
|  | 243 | +	@if [ -n "$(YAMLS)" ]; then $(MAKE) $(addprefix $(COREPATH)/,$(YAMLS)); fi | 
|  | 244 | + | 
|  | 245 | +cluster-init: core managerless | 
|  | 246 | +	kubectl apply --validate=false -f $(CERTMANAGER_URL) | 
|  | 247 | +	# because of dependencies, this is allowed to fail once or twice | 
|  | 248 | +	kubectl apply -f $(COREPATH) || kubectl apply -f $(COREPATH) || kubectl apply -f $(COREPATH) | 
|  | 249 | +	kubectl apply -f $(FULL_MANAGERLESS_MANIFEST) | 
0 commit comments