Skip to content

Commit

Permalink
Add skaffold to tighten local development loop
Browse files Browse the repository at this point in the history
  • Loading branch information
foriequal0 committed Aug 2, 2024
1 parent 2c56e59 commit deb5583
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 10 deletions.
2 changes: 0 additions & 2 deletions .dockerignore

This file was deleted.

5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker build --tag "pod-graceful-drain:latest" .
- run: |
docker build --file docker/build.Dockerfile \
--tag "pod-graceful-drain:latest" \
.
- run: docker image save --output pod-graceful-drain.tar pod-graceful-drain
- uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion charts/pod-graceful-drain/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
{{- end }}
env:
- name: RUST_LOG
value: {{ .Values.logLevel }}
value: {{ .Values.logLevel | quote }}
readinessProbe:
httpGet:
path: "/healthz"
Expand Down
8 changes: 2 additions & 6 deletions Dockerfile → docker/build.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
FROM rust:1.79-slim-bookworm as fetch
FROM rust:1.79-slim-bookworm as builder
RUN apt-get update && apt-get install -y git
RUN mkdir /src
WORKDIR /src
COPY ./Cargo.* /src/
RUN cargo fetch --verbose

FROM fetch as builder
RUN apt-get update && apt-get install -y git
COPY . /src/
RUN cargo install --path .

Expand Down
16 changes: 16 additions & 0 deletions docker/build.Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/.github/
/charts/
/tests/
/.gitignore
/LICENSE
/README.md
/.python-version
/pyproject.toml
/requirements.lock
/requirements-dev.lock
/skaffold.yaml

/target/
/.venv/

/.idea/
26 changes: 26 additions & 0 deletions docker/skaffold.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM rust:1.79-slim-bookworm AS cache

# prepare git cli
RUN apt-get update && apt-get install -y git

# create /src dir
RUN mkdir /src
WORKDIR /src

# warm-up dependencies build cache
COPY ./Cargo.* /src/
COPY build.rs /src/
RUN mkdir src && \
echo 'fn main() { println!("Hello, world!"); }' > src/main.rs && \
cargo build && \
rm -rf src

FROM cache AS build

COPY . /src/
RUN cargo build

FROM debian:bookworm-slim
WORKDIR /app
COPY --from=build /src/target/debug/pod-graceful-drain /app/pod-graceful-drain
ENTRYPOINT ["/app/pod-graceful-drain"]
17 changes: 17 additions & 0 deletions docker/skaffold.Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/.git/
/.github/
/charts/
/tests/
/.gitignore
/LICENSE
/README.md
/.python-version
/pyproject.toml
/requirements.lock
/requirements-dev.lock
/skaffold.yaml

/.venv/
/target/

/.idea/
35 changes: 35 additions & 0 deletions skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# skaffold is just to help tighten the local development/test loop
apiVersion: skaffold/v4beta11
kind: Config
metadata:
name: pod-graceful-drain
build:
artifacts:
- image: ghcr.io/foriequal0/pod-graceful-drain
docker:
dockerfile: docker/skaffold.Dockerfile
context: .
local:
push: false
useBuildkit: true
concurrency: 0
deploy:
helm:
releases:
- name: pod-graceful-drain
chartPath: charts/pod-graceful-drain
valuesFiles:
- charts/pod-graceful-drain/values.yaml
setValues:
experimentalGeneralIngress: true
# Skaffold sends this parameter to Helm as a command line parameter
# '--set=logLevel=info,pod_graceful_drain=trace'. If we omit the backslash,
# Helm interprets a comma in the parameter as a delimiter for key=value pair,
# and it tries to set non-existent 'pod_graceful_drain' value to 'trace'.
# This escaping backslash is why I RIIR'd everything.
# Whenever I see Google-related products, I see this kind of practice.
# They implement some features in seemingly-unharmful broken ways because it is quick and simple.
# When they find features are broken, they don't fix it for compatibility reasons.
# Instead, they cover them up with still-broken ad-hoc mechanisms in obscure, undocumented ways.
# And they leak throughout their entire layers of abstractions like this.
logLevel: "info\\,pod_graceful_drain=trace"

0 comments on commit deb5583

Please sign in to comment.