Skip to content

Commit 7106ebb

Browse files
mhmxsRichard Kovacs
and
Richard Kovacs
authored
Introduce Tilt for local development (#32)
Co-authored-by: Richard Kovacs <[email protected]>
1 parent 75b969f commit 7106ebb

File tree

6 files changed

+48
-2
lines changed

6 files changed

+48
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.idea
33
bin/*
44
cover.out
5+
kubeconfig

Makefile

+22
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
125125
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
126126
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
127127

128+
.PHONY: tilt-cluster
129+
tilt-cluster: ctlptl tilt
130+
ctlptl apply -f ctlptl-config.yaml
131+
tilt up
132+
128133
##@ Build Dependencies
129134

130135
## Location to install dependencies to
@@ -135,12 +140,16 @@ $(LOCALBIN):
135140
## Tool Binaries
136141
KUBECTL ?= kubectl
137142
KUSTOMIZE ?= $(LOCALBIN)/kustomize
143+
CTLPTL ?= $(LOCALBIN)/ctlptl
138144
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
145+
TILT ?= $(LOCALBIN)/tilt
139146
ENVTEST ?= $(LOCALBIN)/setup-envtest
140147

141148
## Tool Versions
142149
KUSTOMIZE_VERSION ?= v5.1.1
150+
CTLPTL_VERSION ?= v0.8.22
143151
CONTROLLER_TOOLS_VERSION ?= v0.13.0
152+
TILT_VERSION ?= 0.33.6
144153

145154
.PHONY: kustomize
146155
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
@@ -151,12 +160,25 @@ $(KUSTOMIZE): $(LOCALBIN)
151160
fi
152161
test -s $(LOCALBIN)/kustomize || GOBIN=$(LOCALBIN) GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v5@$(KUSTOMIZE_VERSION)
153162

163+
.PHONY: ctlptl
164+
ctlptl: $(CTLPTL) ## Download ctlptl locally if necessary. If wrong version is installed, it will be overwritten.
165+
$(CTLPTL): $(LOCALBIN)
166+
test -s $(LOCALBIN)/ctlptl && $(LOCALBIN)/ctlptl version | grep -q $(CTLPTL_VERSION) || \
167+
GOBIN=$(LOCALBIN) go install github.com/tilt-dev/ctlptl/cmd/ctlptl@$(CTLPTL_VERSION)
168+
169+
154170
.PHONY: controller-gen
155171
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
156172
$(CONTROLLER_GEN): $(LOCALBIN)
157173
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
158174
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
159175

176+
.PHONY: tilt
177+
tilt: $(TILT) ## Download tilt locally if necessary. If wrong version is installed, it will be overwritten.
178+
$(TILT): $(LOCALBIN)
179+
test -s $(LOCALBIN)/tilt && $(LOCALBIN)/tilt version | grep -q $(TILT_VERSION) || \
180+
(cd $(LOCALBIN) ; curl -fsSL https://github.com/tilt-dev/tilt/releases/download/v$(TILT_VERSION)/tilt.$(TILT_VERSION).linux.x86_64.tar.gz | tar -xzv tilt)
181+
160182
.PHONY: envtest
161183
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
162184
$(ENVTEST): $(LOCALBIN)

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
# Cluster API Provider Linode
2-
A [Cluster API](https://cluster-api.sigs.k8s.io/) implementation for the [Linode](https://www.linode.com/) to create kubernetes clusters.
2+
A [Cluster API](https://cluster-api.sigs.k8s.io/) implementation for the [Linode](https://www.linode.com/) to create kubernetes clusters.
3+
4+
### Local development with Tilt
5+
6+
For local development execute the following `make` target:
7+
8+
```bash
9+
make tilt-cluster
10+
```
11+
12+
This command creates a Kind cluster, and deploys resources via Tilt. You can freely change the code and wait for Tilt to update provider.

Tiltfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
docker_build("controller", ".")
2+
3+
k8s_yaml(kustomize('config/default'))

cmd/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ package main
1818

1919
import (
2020
"flag"
21-
controller2 "github.com/linode/cluster-api-provider-linode/controller"
2221
"os"
2322

23+
controller2 "github.com/linode/cluster-api-provider-linode/controller"
24+
2425
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
2526
// to ensure that exec-entrypoint and run can make use of them.
2627
_ "k8s.io/client-go/plugin/pkg/client/auth"

ctlptl-config.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
apiVersion: ctlptl.dev/v1alpha1
3+
kind: Cluster
4+
product: kind
5+
kindV1Alpha4Cluster:
6+
name: tilt
7+
nodes:
8+
- role: control-plane
9+
image: kindest/node:v1.28.0

0 commit comments

Comments
 (0)