Skip to content

Commit f2be041

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

File tree

9 files changed

+202
-119
lines changed

9 files changed

+202
-119
lines changed

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

+34-2
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
256258
CONTROLLER_TOOLS_VERSION ?= v0.15.0
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_ARH=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_ARH) -o /tmp/$(TILT_ARH) && \
358+
tar xzf /tmp/$(TILT_ARH) -C $(LOCALBIN) && \
359+
rm -f /tmp/$(TILT_ARH)
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)

config/dev/ctlptl-kind.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: ctlptl.dev/v1alpha1
2+
kind: Registry
3+
name: registry
4+
port: 5000
5+
---
6+
apiVersion: ctlptl.dev/v1alpha1
7+
kind: Cluster
8+
product: kind
9+
registry: registry
10+
kindV1Alpha4Cluster:
11+
name: etcd-operator-dev
12+
networking:
13+
kubeProxyMode: "ipvs"

config/dev/kustomization.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resources:
2+
- local-registry-configmap.yaml
3+
- ../default
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: local-registry-hosting
6+
namespace: kube-public
7+
data:
8+
localRegistryHosting.v1: |
9+
host: "localhost:5000"

go.mod

+32-31
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,98 @@
11
module github.com/aenix-io/etcd-operator
22

3-
go 1.22.4
3+
go 1.23.4
44

55
require (
66
github.com/dustin/go-humanize v1.0.1
77
github.com/go-logr/logr v1.4.2
88
github.com/google/uuid v1.6.0
99
github.com/onsi/ginkgo/v2 v2.19.0
1010
github.com/onsi/gomega v1.33.1
11-
github.com/spf13/cobra v1.7.0
11+
github.com/spf13/cobra v1.8.1
1212
github.com/spf13/pflag v1.0.5
1313
github.com/spf13/viper v1.19.0
1414
go.etcd.io/etcd/client/v3 v3.5.14
15-
k8s.io/api v0.30.2
16-
k8s.io/apimachinery v0.30.2
17-
k8s.io/client-go v0.30.2
18-
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
19-
sigs.k8s.io/controller-runtime v0.18.4
15+
k8s.io/api v0.31.0
16+
k8s.io/apimachinery v0.31.0
17+
k8s.io/client-go v0.31.0
18+
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
19+
sigs.k8s.io/controller-runtime v0.19.0
2020
)
2121

2222
require (
2323
github.com/beorn7/perks v1.0.1 // indirect
24-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
24+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2525
github.com/coreos/go-semver v0.3.1 // indirect
2626
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
2727
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2828
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
29-
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
29+
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
3030
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
3131
github.com/fsnotify/fsnotify v1.7.0 // indirect
32+
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
3233
github.com/go-logr/zapr v1.3.0 // indirect
3334
github.com/go-openapi/jsonpointer v0.19.6 // indirect
3435
github.com/go-openapi/jsonreference v0.20.2 // indirect
35-
github.com/go-openapi/swag v0.22.3 // indirect
36+
github.com/go-openapi/swag v0.22.4 // indirect
3637
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
3738
github.com/gogo/protobuf v1.3.2 // indirect
3839
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
3940
github.com/golang/protobuf v1.5.4 // indirect
4041
github.com/google/gnostic-models v0.6.8 // indirect
4142
github.com/google/go-cmp v0.6.0 // indirect
4243
github.com/google/gofuzz v1.2.0 // indirect
43-
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
44+
github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af // indirect
4445
github.com/gorilla/websocket v1.5.0 // indirect
4546
github.com/hashicorp/hcl v1.0.0 // indirect
46-
github.com/imdario/mergo v0.3.6 // indirect
47+
github.com/imdario/mergo v0.3.16 // indirect
4748
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4849
github.com/josharian/intern v1.0.0 // indirect
4950
github.com/json-iterator/go v1.1.12 // indirect
5051
github.com/magiconair/properties v1.8.7 // indirect
5152
github.com/mailru/easyjson v0.7.7 // indirect
52-
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
5353
github.com/mitchellh/mapstructure v1.5.0 // indirect
54-
github.com/moby/spdystream v0.2.0 // indirect
54+
github.com/moby/spdystream v0.4.0 // indirect
5555
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5656
github.com/modern-go/reflect2 v1.0.2 // indirect
5757
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
5858
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
5959
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
6060
github.com/pkg/errors v0.9.1 // indirect
61-
github.com/prometheus/client_golang v1.18.0 // indirect
62-
github.com/prometheus/client_model v0.5.0 // indirect
63-
github.com/prometheus/common v0.45.0 // indirect
64-
github.com/prometheus/procfs v0.12.0 // indirect
61+
github.com/prometheus/client_golang v1.19.1 // indirect
62+
github.com/prometheus/client_model v0.6.1 // indirect
63+
github.com/prometheus/common v0.55.0 // indirect
64+
github.com/prometheus/procfs v0.15.1 // indirect
6565
github.com/sagikazarmark/locafero v0.4.0 // indirect
6666
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
6767
github.com/sourcegraph/conc v0.3.0 // indirect
6868
github.com/spf13/afero v1.11.0 // indirect
6969
github.com/spf13/cast v1.6.0 // indirect
7070
github.com/subosito/gotenv v1.6.0 // indirect
71+
github.com/x448/float16 v0.8.4 // indirect
7172
go.etcd.io/etcd/api/v3 v3.5.14 // indirect
7273
go.etcd.io/etcd/client/pkg/v3 v3.5.14 // indirect
7374
go.uber.org/multierr v1.11.0 // indirect
7475
go.uber.org/zap v1.27.0 // indirect
7576
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
76-
golang.org/x/net v0.25.0 // indirect
77-
golang.org/x/oauth2 v0.18.0 // indirect
78-
golang.org/x/sys v0.20.0 // indirect
79-
golang.org/x/term v0.20.0 // indirect
80-
golang.org/x/text v0.15.0 // indirect
77+
golang.org/x/net v0.26.0 // indirect
78+
golang.org/x/oauth2 v0.21.0 // indirect
79+
golang.org/x/sys v0.21.0 // indirect
80+
golang.org/x/term v0.21.0 // indirect
81+
golang.org/x/text v0.16.0 // indirect
8182
golang.org/x/time v0.5.0 // indirect
82-
golang.org/x/tools v0.21.0 // indirect
83+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
8384
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
84-
google.golang.org/appengine v1.6.8 // indirect
85-
google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2 // indirect
86-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c // indirect
87-
google.golang.org/grpc v1.62.1 // indirect
88-
google.golang.org/protobuf v1.33.0 // indirect
85+
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
86+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
87+
google.golang.org/grpc v1.65.0 // indirect
88+
google.golang.org/protobuf v1.34.2 // indirect
89+
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
8990
gopkg.in/inf.v0 v0.9.1 // indirect
9091
gopkg.in/ini.v1 v1.67.0 // indirect
9192
gopkg.in/yaml.v2 v2.4.0 // indirect
9293
gopkg.in/yaml.v3 v3.0.1 // indirect
93-
k8s.io/apiextensions-apiserver v0.30.1 // indirect
94-
k8s.io/klog/v2 v2.120.1 // indirect
94+
k8s.io/apiextensions-apiserver v0.31.0 // indirect
95+
k8s.io/klog/v2 v2.130.1 // indirect
9596
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
9697
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
9798
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect

0 commit comments

Comments
 (0)