Skip to content

Commit

Permalink
add tilt for local dev env
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Bortnikov <[email protected]>
  • Loading branch information
aobort committed Dec 9, 2024
1 parent a8076da commit 4db2f8e
Show file tree
Hide file tree
Showing 17 changed files with 246 additions and 183 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/make-test-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
go-version: 1.22.4
go-version: 1.23.4
- uses: docker/[email protected]
- uses: tale/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/make-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
go-version: 1.22.4
go-version: 1.23.4
- run: |
if [ "${{ matrix.k8s.version }}" = "default" ]; then
# For latest version use default from Makefile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nilaway-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ jobs:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
go-version: 1.22.4
go-version: 1.23.4
- run: make nilaway-lint
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ jobs:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
go-version: 1.22.4
go-version: 1.23.4
- uses: pre-commit/[email protected]
2 changes: 1 addition & 1 deletion .github/workflows/release-assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
go-version: 1.22.4
go-version: 1.23.4
- name: Get tag from current run
run: |
TAG=${{ github.ref_name }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.22.4 AS builder
FROM golang:1.23.4 AS builder
ARG TARGETOS TARGETARCH

WORKDIR /workspace
Expand Down
38 changes: 35 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,17 @@ HELM ?= $(LOCALBIN)/helm
HELM_DOCS ?= $(LOCALBIN)/helm-docs
YQ = $(LOCALBIN)/yq
CRD_REF_DOCS ?= $(LOCALBIN)/crd-ref-docs
CTLPTL ?= $(LOCALBIN)/ctlptl
TILT ?= $(LOCALBIN)/tilt

## Tool Versions
# renovate: datasource=github-tags depName=kubernetes-sigs/kustomize
KUSTOMIZE_VERSION ?= v5.3.0
KUSTOMIZE_VERSION ?= v5.5.0
# renovate: datasource=github-tags depName=kubernetes-sigs/controller-tools
CONTROLLER_TOOLS_VERSION ?= v0.15.0
CONTROLLER_TOOLS_VERSION ?= v0.16.5
ENVTEST_VERSION ?= latest
# renovate: datasource=github-tags depName=golangci/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.59.1
GOLANGCI_LINT_VERSION ?= v1.62.2
# renovate: datasource=github-tags depName=kubernetes-sigs/kind
KIND_VERSION ?= v0.23.0
# renovate: datasource=github-tags depName=helm/helm
Expand All @@ -268,6 +270,9 @@ HELM_DOCS_VERSION ?= v1.13.1
# renovate: datasource=github-tags depName=mikefarah/yq
YQ_VERSION ?= v4.44.1

CTLPTL_VERSION ?= v0.8.36
TILT_VERSION ?= 0.33.21

## Tool install scripts
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
HELM_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3"
Expand Down Expand Up @@ -330,3 +335,30 @@ helm-docs: $(LOCALBIN)
yq: $(LOCALBIN)
@test -x $(YQ) && $(YQ) version | grep -q $(YQ_VERSION) || \
GOBIN=$(LOCALBIN) go install github.com/mikefarah/yq/v4@$(YQ_VERSION)

.PHONY: ctlptl
ctlptl: $(LOCALBIN)
@test -x $(CTLPTL) && $(CTLPTL) version | grep -q $(CTLPTL_VERSION) || \
GOBIN=$(LOCALBIN) go install github.com/tilt-dev/ctlptl/cmd/ctlptl@$(CTLPTL_VERSION)

ifeq (darwin,$(shell go env GOOS))
TILT_OS=mac
else
TILT_OS=$(shell go env GOOS)
endif

TILT_ARCH ?= $(shell go env GOARCH)

TILT_ARCHIVE=tilt.$(TILT_VERSION).$(TILT_OS).$(TILT_ARCH).tar.gz
.PHONY: tilt
tilt: $(LOCALBIN)
@test -x $(TILT) && $(TILT) version | grep -q $(TILT_VERSION) || \
rm -f $(TILT) && \
curl -sL https://github.com/tilt-dev/tilt/releases/download/v$(TILT_VERSION)/$(TILT_ARCHIVE) -o /tmp/$(TILT_ARCHIVE) && \
tar xzf /tmp/$(TILT_ARCHIVE) -C $(LOCALBIN) && \
rm -f /tmp/$(TILT_ARCHIVE)

.PHONY: tilt-up
tilt-up: kustomize kind ctlptl tilt
$(CTLPTL) apply -f config/dev/ctlptl-kind.yaml
$(TILT) up
43 changes: 43 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

update_settings(k8s_upsert_timeout_secs=60) # on first tilt up, often can take longer than 30 seconds

# tilt settings
settings = {
"allowed_contexts": [
"kind-etcd-operator-dev"
],
"kubectl": "/usr/local/bin/kubectl",
"kustomize": "./bin/kustomize",
"cert_manager_version": "v1.15.3",
}

# define variables and functions
kubectl = settings.get("kubectl")
kustomize_binary = settings.get("kustomize")

if "allowed_contexts" in settings:
allow_k8s_contexts(settings.get("allowed_contexts"))

def deploy_cert_manager():
version = settings.get("cert_manager_version")
print("Installing cert-manager")
local("{} apply -f https://github.com/cert-manager/cert-manager/releases/download/{}/cert-manager.yaml".format(kubectl, version), quiet=True, echo_off=True)

print("Waiting for cert-manager to start")
local("{} wait --for=condition=Available --timeout=300s -n cert-manager deployment/cert-manager".format(kubectl), quiet=True, echo_off=True)
local("{} wait --for=condition=Available --timeout=300s -n cert-manager deployment/cert-manager-cainjector".format(kubectl), quiet=True, echo_off=True)
local("{} wait --for=condition=Available --timeout=300s -n cert-manager deployment/cert-manager-webhook".format(kubectl), quiet=True, echo_off=True)

def waitforsystem():
print("Waiting for metal-operator to start")
local("{} wait --for=condition=ready --timeout=300s -n etcd-operator-system pod --all".format(kubectl), quiet=False, echo_off=True)

# deploy everything
deploy_cert_manager()

docker_build('ghcr.io/aenix-io/etcd-operator', '.')

yaml = kustomize("./config/dev", kustomize_bin=kustomize_binary)

k8s_yaml(yaml)
Loading

0 comments on commit 4db2f8e

Please sign in to comment.