Skip to content

Commit 983d397

Browse files
committed
add tilt for local dev env
Signed-off-by: Artem Bortnikov <artem.bortnikov@telekom.com>
1 parent a8076da commit 983d397

File tree

13 files changed

+242
-179
lines changed

13 files changed

+242
-179
lines changed

.github/workflows/nilaway-lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ jobs:
1010
- uses: actions/checkout@v4.1.7
1111
- uses: actions/setup-go@v5.0.1
1212
with:
13-
go-version: 1.22.4
13+
go-version: 1.23.4
1414
- run: make nilaway-lint

Dockerfile

Lines changed: 1 addition & 1 deletion
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

Lines changed: 35 additions & 3 deletions
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_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

Lines changed: 43 additions & 0 deletions
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)

charts/etcd-operator/crds/etcd-cluster.yaml

Lines changed: 18 additions & 19 deletions
Large diffs are not rendered by default.

config/crd/bases/etcd.aenix.io_etcdclusters.yaml

Lines changed: 18 additions & 19 deletions
Large diffs are not rendered by default.

config/dev/ctlptl-kind.yaml

Lines changed: 13 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resources:
2+
- local-registry-configmap.yaml
3+
- ../default
Lines changed: 9 additions & 0 deletions
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"

config/rbac/role.yaml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ rules:
88
- ""
99
resources:
1010
- configmaps
11+
- services
1112
verbs:
1213
- create
1314
- delete
@@ -20,22 +21,6 @@ rules:
2021
- ""
2122
resources:
2223
- endpoints
23-
verbs:
24-
- get
25-
- list
26-
- watch
27-
- apiGroups:
28-
- ""
29-
resources:
30-
- persistentvolumeclaims
31-
verbs:
32-
- get
33-
- list
34-
- patch
35-
- watch
36-
- apiGroups:
37-
- ""
38-
resources:
3924
- secrets
4025
verbs:
4126
- get
@@ -44,14 +29,11 @@ rules:
4429
- apiGroups:
4530
- ""
4631
resources:
47-
- services
32+
- persistentvolumeclaims
4833
verbs:
49-
- create
50-
- delete
5134
- get
5235
- list
5336
- patch
54-
- update
5537
- watch
5638
- apiGroups:
5739
- apps

0 commit comments

Comments
 (0)