Skip to content

Commit

Permalink
chore(dev): Transition local k8s dev to Tilt (vectordotdev#11804)
Browse files Browse the repository at this point in the history
* feat(dev)!: Use tilt rather than skaffold

Signed-off-by: Spencer Gilbert <[email protected]>

* polish tiltfile and dockerfile

Signed-off-by: Spencer Gilbert <[email protected]>

* Add docs and fix style

Signed-off-by: Spencer Gilbert <[email protected]>
  • Loading branch information
spencergilbert authored Mar 11, 2022
1 parent 4a55953 commit 2fcdff3
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ node_modules
tests/data/wasm/*/target
heaptrack.*
massif.*

# tilt
tilt_modules/
28 changes: 28 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
###################
# VECTOR TILTFILE #
###################

load('ext://helm_resource', 'helm_resource', 'helm_repo')

docker_build(
ref='timberio/vector',
context='.',
build_args={'RUST_VERSION': '1.58'},
dockerfile='tilt/Dockerfile'
)

helm_repo(name='vectordotdev', url='https://helm.vector.dev')
helm_resource(
name='vector',
chart='vectordotdev/vector',
image_deps=['timberio/vector'],
image_keys=[('image.repository', 'image.tag')],
flags=[
'--devel',
'--set', 'role=Agent',
# '--set', 'env[0].name=VECTOR_LOG',
# '--set', 'env[0].value=trace'
]
)

k8s_resource(workload='vector', port_forwards=8686)
14 changes: 10 additions & 4 deletions docs/DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,11 @@ at `lib/k8s-test-framework`, and the actual end-to-end tests using that
framework are at `lib/k8s-e2e-tests`.

The Kubernetes-related distribution bit that are at `distribution/docker`,
`distribution/kubernetes` and `distribution/helm`.
There are also snapshot tests for Helm at `tests/helm-snapshots`.
`distribution/kubernetes` and our Helm chart can be found at [`vectordotdev/helm-charts`](https://github.com/vectordotdev/helm-charts/).

The development assistance resources are located at `skaffold.yaml`
and `skaffold` dir.
and `skaffold` dir. Alternative `tilt` resources are located at `Tiltfile`
and in the `tilt` dir.

#### Development

Expand All @@ -560,7 +560,7 @@ Vector:

- `linux` system (create an issue if you want to work with another OS and we'll
help);
- [`skaffold`](https://skaffold.dev/)
- [`skaffold`](https://skaffold.dev/) or [`tilt`](https://tilt.dev/)
- [`docker`](https://www.docker.com/)
- [`kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
- [`kustomize`](https://kustomize.io/)
Expand Down Expand Up @@ -624,6 +624,12 @@ You might need to tweak `skaffold`, here are some hints:
- For the rest of the `skaffold` tweaks you might want to apply check out
[this page](https://skaffold.dev/docs/environment/).

##### Alternative: Tilt

As an alternative to `skaffold` you can use `tilt` to detect changes, rebuild
your image, and update your Kubernetes resource. Simply start your local Kubernetes
cluster and run `tilt up` from Vector's root dir.

#### Testing

##### Integration tests
Expand Down
35 changes: 35 additions & 0 deletions tilt/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ARG RUST_VERSION
ARG DEBIAN_RELEASE=bullseye
# Features required for both Agent and Aggregator Helm chart configurations
ARG FEATURES=api,api-client,sources-datadog_agent,sources-fluent,sources-host_metrics,sources-internal_metrics,sources-kubernetes_logs,sources-logstash,sources-splunk_hec,sources-statsd,sources-syslog,sources-vector,sinks-console,sinks-prometheus,sinks-vector

#
# VECTOR BUILDER
#
FROM docker.io/rust:${RUST_VERSION}-${DEBIAN_RELEASE} as builder
RUN apt-get update && apt-get -y install build-essential git clang cmake libclang-dev libsasl2-dev libstdc++-10-dev libssl-dev libxxhash-dev zlib1g-dev zlib1g
RUN git clone https://github.com/rui314/mold.git
RUN cd mold && git checkout v1.1.1 && make -j$(nproc) && make install && rm -rf mold

WORKDIR /vector
COPY . .
ARG FEATURES
RUN --mount=type=cache,target=/vector/target \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
/usr/local/bin/mold -run cargo build --bin vector \
--no-default-features --features $FEATURES && \
cp target/debug/vector .

#
# TARGET
#
FROM debian:${DEBIAN_RELEASE}-slim
RUN apt-get update && apt-get -y install zlib1g
COPY --from=builder /vector/vector /usr/bin/vector
VOLUME /var/lib/vector/

# Smoke test
RUN ["vector", "--version"]

ENTRYPOINT ["/usr/bin/vector"]

0 comments on commit 2fcdff3

Please sign in to comment.