Skip to content

Commit c814e14

Browse files
committed
add tilt for local dev env
Signed-off-by: Artem Bortnikov <[email protected]>
1 parent bfcf533 commit c814e14

16 files changed

+244
-181
lines changed

.github/workflows/make-test-e2e.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- uses: actions/[email protected]
2727
- uses: actions/[email protected]
2828
with:
29-
go-version: 1.22.4
29+
go-version: 1.23.4
3030
- uses: docker/[email protected]
3131
- uses: tale/[email protected]
3232
with:

.github/workflows/make-test.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- uses: actions/[email protected]
2727
- uses: actions/[email protected]
2828
with:
29-
go-version: 1.22.4
29+
go-version: 1.23.4
3030
- run: |
3131
if [ "${{ matrix.k8s.version }}" = "default" ]; then
3232
# For latest version use default from Makefile

.github/workflows/nilaway-lint.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ jobs:
1010
- uses: actions/[email protected]
1111
- uses: actions/[email protected]
1212
with:
13-
go-version: 1.22.4
13+
go-version: 1.23.4
1414
- run: make nilaway-lint

.github/workflows/pre-commit.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ jobs:
1010
- uses: actions/[email protected]
1111
- uses: actions/[email protected]
1212
with:
13-
go-version: 1.22.4
13+
go-version: 1.23.4
1414
- uses: pre-commit/[email protected]

.github/workflows/release-assets.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/[email protected]
1818
- uses: actions/[email protected]
1919
with:
20-
go-version: 1.22.4
20+
go-version: 1.23.4
2121
- name: Get tag from current run
2222
run: |
2323
TAG=${{ github.ref_name }}

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.22.4 AS builder
2+
FROM golang:1.23.4 AS builder
33
ARG TARGETOS TARGETARCH
44

55
WORKDIR /workspace

Makefile

+35-3
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,17 @@ HELM ?= $(LOCALBIN)/helm
248248
HELM_DOCS ?= $(LOCALBIN)/helm-docs
249249
YQ = $(LOCALBIN)/yq
250250
CRD_REF_DOCS ?= $(LOCALBIN)/crd-ref-docs
251+
CTLPTL ?= $(LOCALBIN)/ctlptl
252+
TILT ?= $(LOCALBIN)/tilt
251253

252254
## Tool Versions
253255
# renovate: datasource=github-tags depName=kubernetes-sigs/kustomize
254-
KUSTOMIZE_VERSION ?= v5.3.0
256+
KUSTOMIZE_VERSION ?= v5.5.0
255257
# renovate: datasource=github-tags depName=kubernetes-sigs/controller-tools
256-
CONTROLLER_TOOLS_VERSION ?= v0.15.0
258+
CONTROLLER_TOOLS_VERSION ?= v0.16.5
257259
ENVTEST_VERSION ?= latest
258260
# renovate: datasource=github-tags depName=golangci/golangci-lint
259-
GOLANGCI_LINT_VERSION ?= v1.59.1
261+
GOLANGCI_LINT_VERSION ?= v1.62.2
260262
# renovate: datasource=github-tags depName=kubernetes-sigs/kind
261263
KIND_VERSION ?= v0.23.0
262264
# renovate: datasource=github-tags depName=helm/helm
@@ -268,6 +270,9 @@ HELM_DOCS_VERSION ?= v1.13.1
268270
# renovate: datasource=github-tags depName=mikefarah/yq
269271
YQ_VERSION ?= v4.44.1
270272

273+
CTLPTL_VERSION ?= v0.8.36
274+
TILT_VERSION ?= 0.33.21
275+
271276
## Tool install scripts
272277
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
273278
HELM_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3"
@@ -330,3 +335,30 @@ helm-docs: $(LOCALBIN)
330335
yq: $(LOCALBIN)
331336
@test -x $(YQ) && $(YQ) version | grep -q $(YQ_VERSION) || \
332337
GOBIN=$(LOCALBIN) go install github.com/mikefarah/yq/v4@$(YQ_VERSION)
338+
339+
.PHONY: ctlptl
340+
ctlptl: $(LOCALBIN)
341+
@test -x $(CTLPTL) && $(CTLPTL) version | grep -q $(CTLPTL_VERSION) || \
342+
GOBIN=$(LOCALBIN) go install github.com/tilt-dev/ctlptl/cmd/ctlptl@$(CTLPTL_VERSION)
343+
344+
ifeq (darwin,$(shell go env GOOS))
345+
TILT_OS=mac
346+
else
347+
TILT_OS=$(shell go env GOOS)
348+
endif
349+
350+
TILT_ARCH ?= $(shell go env GOARCH)
351+
352+
TILT_ARCHIVE=tilt.$(TILT_VERSION).$(TILT_OS).$(TILT_ARCH).tar.gz
353+
.PHONY: tilt
354+
tilt: $(LOCALBIN)
355+
@test -x $(TILT) && $(TILT) version | grep -q $(TILT_VERSION) || \
356+
rm -f $(TILT) && \
357+
curl -sL https://github.com/tilt-dev/tilt/releases/download/v$(TILT_VERSION)/$(TILT_ARCHIVE) -o /tmp/$(TILT_ARCHIVE) && \
358+
tar xzf /tmp/$(TILT_ARCHIVE) -C $(LOCALBIN) && \
359+
rm -f /tmp/$(TILT_ARCHIVE)
360+
361+
.PHONY: tilt-up
362+
tilt-up: kustomize kind ctlptl tilt
363+
$(CTLPTL) apply -f config/dev/ctlptl-kind.yaml
364+
$(TILT) up

Tiltfile

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
update_settings(k8s_upsert_timeout_secs=60) # on first tilt up, often can take longer than 30 seconds
4+
5+
# tilt settings
6+
settings = {
7+
"allowed_contexts": [
8+
"kind-etcd-operator-dev"
9+
],
10+
"kubectl": "/usr/local/bin/kubectl",
11+
"kustomize": "./bin/kustomize",
12+
"cert_manager_version": "v1.15.3",
13+
}
14+
15+
# define variables and functions
16+
kubectl = settings.get("kubectl")
17+
kustomize_binary = settings.get("kustomize")
18+
19+
if "allowed_contexts" in settings:
20+
allow_k8s_contexts(settings.get("allowed_contexts"))
21+
22+
def deploy_cert_manager():
23+
version = settings.get("cert_manager_version")
24+
print("Installing cert-manager")
25+
local("{} apply -f https://github.com/cert-manager/cert-manager/releases/download/{}/cert-manager.yaml".format(kubectl, version), quiet=True, echo_off=True)
26+
27+
print("Waiting for cert-manager to start")
28+
local("{} wait --for=condition=Available --timeout=300s -n cert-manager deployment/cert-manager".format(kubectl), quiet=True, echo_off=True)
29+
local("{} wait --for=condition=Available --timeout=300s -n cert-manager deployment/cert-manager-cainjector".format(kubectl), quiet=True, echo_off=True)
30+
local("{} wait --for=condition=Available --timeout=300s -n cert-manager deployment/cert-manager-webhook".format(kubectl), quiet=True, echo_off=True)
31+
32+
def waitforsystem():
33+
print("Waiting for metal-operator to start")
34+
local("{} wait --for=condition=ready --timeout=300s -n etcd-operator-system pod --all".format(kubectl), quiet=False, echo_off=True)
35+
36+
# deploy everything
37+
deploy_cert_manager()
38+
39+
docker_build('ghcr.io/aenix-io/etcd-operator', '.')
40+
41+
yaml = kustomize("./config/dev", kustomize_bin=kustomize_binary)
42+
43+
k8s_yaml(yaml)

0 commit comments

Comments
 (0)