Skip to content

Commit 3fe2acb

Browse files
committed
Add Tiltfile
1 parent 74cd6d2 commit 3fe2acb

File tree

7 files changed

+185
-8
lines changed

7 files changed

+185
-8
lines changed

.dockerignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.*
2+
deploy/
3+
e2e/
4+
examples/
5+
hack/

Dockerfile

+21-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
# "docker": build in a Docker build container (default)
2+
# "local": copy from the build context. This is useful for tilt's live_update
3+
# feature, allowing hot reload of the kpp-api binary for fast
4+
# development iteration. See ./Tiltfile
5+
ARG BUILD_SOURCE="docker"
6+
17
FROM golang:1.21-alpine as builder
8+
RUN apk add --update --no-cache make
29
RUN mkdir -p /linode
310
WORKDIR /linode
411

@@ -7,13 +14,23 @@ COPY go.sum .
714
COPY main.go .
815
COPY cloud ./cloud
916
COPY sentry ./sentry
17+
COPY Makefile .
1018

11-
RUN go mod download
12-
RUN go build -a -ldflags '-extldflags "-static"' -o /bin/linode-cloud-controller-manager-linux /linode
19+
RUN make build-linux
1320

14-
FROM alpine:3.18.4
21+
FROM alpine:3.18.4 as base
1522
RUN apk add --update --no-cache ca-certificates
1623
LABEL maintainers="Linode"
1724
LABEL description="Linode Cloud Controller Manager"
18-
COPY --from=builder /bin/linode-cloud-controller-manager-linux /linode-cloud-controller-manager-linux
25+
26+
# Copy from docker
27+
FROM base as docker
28+
COPY --from=builder /linode/dist/linode-cloud-controller-manager-linux-amd64 /linode-cloud-controller-manager-linux
29+
30+
# Copy from local
31+
FROM base as local
32+
COPY dist/linode-cloud-controller-manager-linux-amd64 /linode-cloud-controller-manager-linux
33+
34+
# See documentation on the arg
35+
FROM $BUILD_SOURCE
1936
ENTRYPOINT ["/linode-cloud-controller-manager-linux"]

Makefile

+3-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ test: fmt codegen
4141

4242
.PHONY: build-linux
4343
build-linux: codegen
44-
echo "cross compiling linode-cloud-controller-manager for linux/amd64" && \
44+
echo "compiling linode-cloud-controller-manager for linux/amd64" && \
4545
GOOS=linux GOARCH=amd64 \
4646
CGO_ENABLED=0 \
47-
go build -o dist/linode-cloud-controller-manager-linux-amd64 .
47+
go build -ldflags '-extldflags "-static"' -o dist/linode-cloud-controller-manager-linux-amd64 .
4848

4949
.PHONY: build
5050
build: codegen
@@ -65,8 +65,7 @@ imgname:
6565
echo IMG=${IMG}
6666

6767
.PHONY: docker-build
68-
# we cross compile the binary for linux, then build a container
69-
docker-build: build-linux
68+
docker-build:
7069
DOCKER_BUILDKIT=1 docker build --platform=$(PLATFORM) --tag ${IMG} .
7170

7271
.PHONY: docker-push

Tiltfile

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
load("ext://deployment", "deployment_create")
2+
load("ext://k8s_attach", "k8s_attach")
3+
load("ext://restart_process", "docker_build_with_restart")
4+
load("ext://helm_resource", "helm_resource")
5+
6+
allow_k8s_contexts(k8s_context())
7+
8+
# in order to use this registry you must add `127.0.0.1 registry-proxy` in your /etc/hosts
9+
# and add http://registry-proxy:5000 to the list of insecure registries in docker daemon.
10+
load("ext://k8s_attach", "k8s_attach")
11+
12+
local_resource(
13+
"registry-probe",
14+
serve_cmd="sleep infinity",
15+
readiness_probe=probe(
16+
period_secs=15,
17+
http_get=http_get_action(host="registry-proxy", port=5000, path="/"),
18+
),
19+
labels=["registry"],
20+
)
21+
22+
k8s_attach(
23+
"registry-port-forward",
24+
"deployment/docker-registry",
25+
namespace="registry",
26+
port_forwards=[5000],
27+
labels=["registry"],
28+
)
29+
default_registry("registry-proxy:5000", host_from_cluster="docker.local")
30+
31+
labels = ["ccm-linode"]
32+
33+
local_resource(
34+
"linode-cloud-controller-manager-linux-amd64",
35+
"make build-linux",
36+
# No glob support :(
37+
deps=[
38+
"cloud/",
39+
"go.mod",
40+
"go.sum",
41+
"main.go",
42+
"Makefile",
43+
"sentry/",
44+
],
45+
ignore=[
46+
"**/*.bin",
47+
"**/gomock*",
48+
"cloud/linode/mock_client_test.go",
49+
],
50+
labels=labels,
51+
)
52+
53+
entrypoint = "/linode-cloud-controller-manager-linux"
54+
docker_build_with_restart(
55+
"linode/linode-cloud-controller-manager",
56+
".",
57+
entrypoint=[entrypoint],
58+
ignore=["**/*.go", "go.*", "Makefile"],
59+
live_update=[
60+
sync(
61+
"dist/linode-cloud-controller-manager-linux-amd64",
62+
entrypoint,
63+
),
64+
],
65+
build_args={"BUILD_SOURCE": "local"},
66+
platform="linux/amd64",
67+
)
68+
69+
chart_yaml = helm(
70+
"deploy/chart",
71+
name="ccm-linode",
72+
namespace="kube-system",
73+
values="./tilt.values.yaml",
74+
)
75+
k8s_yaml(chart_yaml)

devbox.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"packages": [
3+
"go_1_20@latest",
4+
"tilt@latest",
5+
"kubernetes-helm@latest"
6+
]
7+
}

devbox.lock

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"lockfile_version": "1",
3+
"packages": {
4+
"go_1_20@latest": {
5+
"last_modified": "2024-01-02T02:19:20Z",
6+
"resolved": "github:NixOS/nixpkgs/63143ac2c9186be6d9da6035fa22620018c85932#go_1_20",
7+
"source": "devbox-search",
8+
"version": "1.20.12",
9+
"systems": {
10+
"aarch64-darwin": {
11+
"store_path": "/nix/store/vgygiqcs16im3ffw6p0bv9zihixxg0cl-go-1.20.12"
12+
},
13+
"aarch64-linux": {
14+
"store_path": "/nix/store/rlk4nvwrz6rl7r87sn5g6v2vr2mhq8nv-go-1.20.12"
15+
},
16+
"x86_64-darwin": {
17+
"store_path": "/nix/store/vw51wxs8110al4q12pbg3vpi78w8ijk9-go-1.20.12"
18+
},
19+
"x86_64-linux": {
20+
"store_path": "/nix/store/s05mmkyf6sm6vskb4fwbjq0x93sqalqr-go-1.20.12"
21+
}
22+
}
23+
},
24+
"kubernetes-helm@latest": {
25+
"last_modified": "2023-11-19T17:46:56Z",
26+
"resolved": "github:NixOS/nixpkgs/0bf3f5cf6a98b5d077cdcdb00a6d4b3d92bc78b5#kubernetes-helm",
27+
"source": "devbox-search",
28+
"version": "3.13.2",
29+
"systems": {
30+
"aarch64-darwin": {
31+
"store_path": "/nix/store/bm0hydn3x8qicnnpp1j59affzbh802g6-kubernetes-helm-3.13.2"
32+
},
33+
"aarch64-linux": {
34+
"store_path": "/nix/store/rlxzcdijanfnr1cycmasxlqqbkhmfllc-kubernetes-helm-3.13.2"
35+
},
36+
"x86_64-darwin": {
37+
"store_path": "/nix/store/wihx37d21rxyvp5d10ki9qr57mmqa96n-kubernetes-helm-3.13.2"
38+
},
39+
"x86_64-linux": {
40+
"store_path": "/nix/store/2nsswfqlz4nc2hrbxchz7n98ccg9jfjx-kubernetes-helm-3.13.2"
41+
}
42+
}
43+
},
44+
"tilt@latest": {
45+
"last_modified": "2023-11-19T17:46:56Z",
46+
"resolved": "github:NixOS/nixpkgs/0bf3f5cf6a98b5d077cdcdb00a6d4b3d92bc78b5#tilt",
47+
"source": "devbox-search",
48+
"version": "0.33.6",
49+
"systems": {
50+
"aarch64-darwin": {
51+
"store_path": "/nix/store/d0kpgvk6vvb8lvsvmh338zxfnb9b7vp9-tilt-0.33.6"
52+
},
53+
"aarch64-linux": {
54+
"store_path": "/nix/store/d61h2m341hza65rs8ay04fjmdgwmw1m6-tilt-0.33.6"
55+
},
56+
"x86_64-darwin": {
57+
"store_path": "/nix/store/30kfkrlyrbk3bzwr524kmqmsygf5a89p-tilt-0.33.6"
58+
},
59+
"x86_64-linux": {
60+
"store_path": "/nix/store/9yqsnwx8khnbf86z81cyaaqmh4qkfy2i-tilt-0.33.6"
61+
}
62+
}
63+
}
64+
}
65+
}

tilt.values.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
env:
2+
- name: LINODE_HOSTNAME_ONLY_INGRESS
3+
value: "false"
4+
nodeSelector:
5+
node-role.kubernetes.io/master: "true"
6+
secretRef:
7+
apiTokenRef: apiToken
8+
name: linode-api-secret
9+
regionRef: region

0 commit comments

Comments
 (0)