Skip to content

Commit 44121ab

Browse files
committed
feat(devenv): move to controller folder and remove reqs
Signed-off-by: Alessio Pragliola <seth.pro@gmail.com>
1 parent b809505 commit 44121ab

File tree

10 files changed

+184
-133
lines changed

10 files changed

+184
-133
lines changed

devenv/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

devenv/Makefile

Lines changed: 0 additions & 32 deletions
This file was deleted.

devenv/Tiltfile

Lines changed: 0 additions & 70 deletions
This file was deleted.

devenv/configs/tiltfiles/cert-manager.tiltfile

Lines changed: 0 additions & 21 deletions
This file was deleted.

devenv/tilt_config.json

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin/*
2+
tilt_config.json
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
detected_OS := $(shell uname -s)
2+
real_OS := $(detected_OS)
3+
arch := $(shell uname -m)
4+
goarch := $(shell go env GOARCH)
5+
ifeq ($(detected_OS),Darwin)
6+
detected_OS := mac
7+
real_OS := darwin
8+
endif
9+
ifeq ($(detected_OS),Linux)
10+
detected_OS := linux
11+
real_OS := linux
12+
endif
13+
14+
## Cleanup targets
15+
16+
.PHONY: cleanup-crds
17+
cleanup-crds:
18+
@echo "Cleaning up CRDs..."
19+
@kubectl delete -f ../config/crd/bases/ || true
20+
21+
## Requirements
22+
23+
CERT_MANAGER_VERSION := 1.17.1
24+
25+
.PHONY: cmctl check-cert-manager
26+
check-cert-manager:
27+
@echo "Checking if cert-manager is installed and ready..."
28+
@$(LOCALBIN)/cmctl check api > /dev/null 2>&1 || (printf "cert-manager is not installed or is not ready yet, please install cert-manager first or wait for it to be ready.\nYou can install cert-manager by running the following command:\n\nkubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v$(CERT_MANAGER_VERSION)/cert-manager.yaml\n\n" && exit 1)
29+
@echo "cert-manager is installed and ready."
30+
31+
## Location to install dependencies to
32+
LOCALBIN ?= $(shell pwd)/bin
33+
$(LOCALBIN):
34+
mkdir -p $(LOCALBIN)
35+
36+
## Tool Binaries
37+
TILT ?= $(LOCALBIN)/tilt
38+
CMCTL ?= $(LOCALBIN)/cmctl
39+
40+
## Tool Versions
41+
TILT_VERSION := 0.33.22
42+
CMCTL_VERSION := 2.1.1
43+
44+
.PHONY: cmctl
45+
.PHONY: $(CMCTL)
46+
cmctl: $(CMCTL)
47+
$(CMCTL): $(LOCALBIN)
48+
test -s $(LOCALBIN)/cmctl || curl -fsSL https://github.com/cert-manager/cmctl/releases/download/v$(CMCTL_VERSION)/cmctl_$(detected_OS)_$(goarch).tar.gz | tar -xz -C $(LOCALBIN) cmctl
49+
50+
.PHONY: tilt
51+
.PHONY: $(TILT)
52+
tilt: $(TILT)
53+
$(TILT): $(LOCALBIN)
54+
test -s $(LOCALBIN)/tilt || curl -fsSL https://github.com/tilt-dev/tilt/releases/download/v$(TILT_VERSION)/tilt.$(TILT_VERSION).$(detected_OS).$(arch).tar.gz | tar -xz -C $(LOCALBIN) tilt
55+
56+
tilt-up: tilt check-cert-manager
57+
$(LOCALBIN)/tilt up
58+
59+
tilt-down: tilt cleanup-crds
60+
$(LOCALBIN)/tilt down
File renamed without changes.
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
load("ext://restart_process", "docker_build_with_restart")
2+
3+
load_dynamic("./configs/tiltfiles/Tiltfile.setup")
4+
5+
config.define_string_list("services")
6+
7+
parsed_config = config.parse()
8+
9+
for service in parsed_config.get("services", []):
10+
load_dynamic("./configs/tiltfiles/Tiltfile.%s" % (service))
11+
12+
manifests = kustomize("../config/default")
13+
14+
objects = decode_yaml_stream(manifests)
15+
16+
for o in objects:
17+
if o["kind"] == "Deployment" and o.get("metadata").get("name") in ["workspace-controller-controller-manager"]:
18+
o["spec"]["template"]["spec"]["securityContext"] = {"runAsNonRoot": False, "readOnlyRootFilesystem": False}
19+
o["spec"]["template"]["spec"]["containers"][0]["imagePullPolicy"] = "Always"
20+
21+
overridden_manifests = encode_yaml_stream(objects)
22+
23+
k8s_yaml(overridden_manifests, allow_duplicates=True)
24+
25+
local_resource(
26+
"cert-manager-req-check",
27+
serve_cmd="sleep infinity",
28+
labels="requirements",
29+
readiness_probe=probe(
30+
exec=exec_action(
31+
command=["/bin/sh", "-c", "./bin/cmctl check api"]
32+
), initial_delay_secs=5, timeout_secs=60
33+
)
34+
)
35+
36+
k8s_resource(
37+
new_name="certs",
38+
objects=[
39+
"workspace-controller-serving-cert:certificate",
40+
"workspace-controller-selfsigned-issuer:issuer"
41+
],
42+
labels="controller",
43+
resource_deps=[
44+
"controller-namespace",
45+
"cert-manager-req-check"
46+
]
47+
)
48+
49+
k8s_resource(
50+
new_name="reqs",
51+
objects=[
52+
"workspace-controller-controller-manager:serviceaccount",
53+
"workspace-controller-leader-election-role:role",
54+
"workspace-controller-manager-role:clusterrole",
55+
"workspace-controller-workspace-editor-role:clusterrole",
56+
"workspace-controller-workspace-viewer-role:clusterrole",
57+
"workspace-controller-workspacekind-editor-role:clusterrole",
58+
"workspace-controller-workspacekind-viewer-role:clusterrole",
59+
"workspace-controller-leader-election-rolebinding:rolebinding",
60+
"workspace-controller-manager-rolebinding:clusterrolebinding",
61+
"workspace-controller-validating-webhook-configuration:validatingwebhookconfiguration"
62+
],
63+
labels="controller",
64+
resource_deps=[
65+
"controller-namespace"
66+
]
67+
)
68+
69+
k8s_resource(
70+
new_name="crds",
71+
objects=[
72+
"workspacekinds.kubeflow.org:customresourcedefinition",
73+
"workspaces.kubeflow.org:customresourcedefinition"
74+
],
75+
labels="controller",
76+
resource_deps=[
77+
"controller-namespace",
78+
]
79+
)
80+
81+
k8s_resource(
82+
new_name="controller-namespace",
83+
objects=["workspace-controller-system:Namespace:default"],
84+
labels="requirements"
85+
)
86+
87+
k8s_resource(
88+
workload="workspace-controller-controller-manager",
89+
new_name="controller",
90+
labels="controller",
91+
resource_deps=[
92+
"controller-namespace",
93+
"cert-manager-req-check",
94+
"certs"
95+
]
96+
)
97+
98+
local_resource(
99+
"manager-bin",
100+
"CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/manager cmd/main.go",
101+
dir = "../",
102+
deps = [
103+
"../cmd",
104+
"../internal",
105+
"../go.mod",
106+
"../go.sum",
107+
],
108+
labels="controller",
109+
)
110+
111+
docker_build_with_restart(
112+
"ghcr.io/kubeflow/notebooks/workspace-controller",
113+
context = "../",
114+
dockerfile = "../tilt.dockerfile",
115+
entrypoint = ["/manager"],
116+
only=[
117+
"bin/",
118+
],
119+
live_update = [
120+
sync("../bin/manager", "/manager"),
121+
],
122+
)
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
load("ext://namespace", "namespace_create")
2-
31
# Disable analytics
42
analytics_settings(False)
53

64
update_settings(k8s_upsert_timeout_secs = 120)
7-
8-
namespace_create("workspace-controller-system")

0 commit comments

Comments
 (0)