Skip to content

Commit a244b10

Browse files
committed
Add Tiltfile
1 parent 74cd6d2 commit a244b10

File tree

7 files changed

+184
-7
lines changed

7 files changed

+184
-7
lines changed

.dockerignore

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

Dockerfile

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

@@ -7,13 +17,23 @@ COPY go.sum .
717
COPY main.go .
818
COPY cloud ./cloud
919
COPY sentry ./sentry
20+
COPY Makefile .
1021

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

14-
FROM alpine:3.18.4
24+
FROM alpine:3.18.4 as base
1525
RUN apk add --update --no-cache ca-certificates
1626
LABEL maintainers="Linode"
1727
LABEL description="Linode Cloud Controller Manager"
18-
COPY --from=builder /bin/linode-cloud-controller-manager-linux /linode-cloud-controller-manager-linux
28+
29+
# Copy from docker
30+
FROM base as docker
31+
COPY --from=builder /linode/dist/linode-cloud-controller-manager-linux-amd64 /linode-cloud-controller-manager-linux
32+
33+
# Copy from local
34+
FROM base as local
35+
COPY dist/linode-cloud-controller-manager-linux-amd64 /linode-cloud-controller-manager-linux
36+
37+
# See documentation on the arg
38+
FROM $BUILD_SOURCE
1939
ENTRYPOINT ["/linode-cloud-controller-manager-linux"]

Makefile

+2-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ build-linux: codegen
4444
echo "cross 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 -a -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

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
deps=[
37+
"*.go",
38+
"cloud/**/*.go",
39+
"sentry/**/*.go",
40+
"go.*",
41+
"Makefile",
42+
],
43+
ignore=["./build/",],
44+
labels=labels,
45+
)
46+
47+
docker_build_with_restart(
48+
"linode/linode-cloud-controller-manager",
49+
".",
50+
entrypoint=["/linode-cloud-controller-manager-linux-amd64"],
51+
ignore=["**/*.go", "go.*"],
52+
live_update=[
53+
sync("./dist/linode-cloud-controller-manager-linux-amd64", "/linode-cloud-controller-manager-linux"),
54+
],
55+
build_args={"BUILD_SOURCE": "local"},
56+
platform="linux/amd64",
57+
)
58+
59+
# Avoiding helm_resource because orchestrating `helm install` over an
60+
# argocd app seems to require deleting the app which is slow and upsets pulumi.
61+
chart_yaml = helm(
62+
"deploy/chart",
63+
name="ccm-linode",
64+
namespace="kube-system",
65+
values="./tilt.values.yaml",
66+
)
67+
k8s_yaml(chart_yaml)
68+
69+
# k8s_resource(
70+
# "ccm-linode", labels=labels
71+
# )

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)