-
Notifications
You must be signed in to change notification settings - Fork 0
feat: setup local dev environment for opslevel-runner with kind #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
archf
wants to merge
13
commits into
main
Choose a base branch
from
feature/improve-developer-setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+428
−43
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7af49e9
initial env and test setup
archf 8ca7807
fix: metrics port conflicts
archf d42a136
fix: exec local runner scripts with helper image name built locally
archf 8653234
test: keep coding agent job alive during enqueue tests
archf 68b1d50
fix: successfully exit the wait loop on first goreman exec
archf 39b8d70
chore: gitignore taskfile checksum cache
archf 0a26b70
fix: hot-reload opslevel-runner with watchexec
archf a9138b7
docs: Update README for local development
archf b4d6805
fix: tune down local dev runner default resources
archf 8801db8
feat: set lower resources request in tests/run-runner.sh
archf b99b828
remove coding-agent local runner specifics
archf 3a8d3b2
build: limit helper image rebuild triggers
archf 1832233
rename helper image tag to 'dev'
archf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Build the runner helper image and load it into kind. | ||
| # Loads iff: we rebuilt this run OR the image is absent in the kind cluster. | ||
|
|
||
| set -eu | ||
|
|
||
| CLUSTER_NAME="${1:-opslevel-runner}" | ||
| HELPER_IMAGE="${HELPER_IMAGE:-localhost/opslevel-runner:dev}" | ||
|
|
||
| SCRIPT_DIR="${BASH_SOURCE[0]%/*}" | ||
| source "$SCRIPT_DIR/kind-env.sh" | ||
|
|
||
| GOARCH="$(go env GOARCH)" | ||
| DIST_DIR="$SCRIPT_DIR/../dist" | ||
| DIST_BIN="$DIST_DIR/linux/${GOARCH}/opslevel-runner" | ||
| SRC_CHECKSUM_PREVIOUS="$DIST_DIR/linux/${GOARCH}/.build-checksum" | ||
|
|
||
| image_in_kind() { | ||
| "$cmd" exec "${CLUSTER_NAME}-control-plane" ctr -n k8s.io images ls -q 2>/dev/null \ | ||
| | grep -q "$HELPER_IMAGE" | ||
| } | ||
|
|
||
| checksum_sources() { | ||
| { cd "$SCRIPT_DIR/../src" && \ | ||
| shasum -a 256 cmd/enqueue.go cmd/root.go main.go go.mod go.sum ../Dockerfile | ||
| } | shasum -a 256 | cut -d' ' -f1 | ||
| } | ||
|
|
||
| # checksum the real image inputs (binary embeds the compiled go code) | ||
| src_checksum="$(checksum_sources)" | ||
|
|
||
| build_image() { | ||
| if [ ! -f "$DIST_BIN" ] || [ ! -f "$SRC_CHECKSUM_PREVIOUS" ] || [ "$(< "$SRC_CHECKSUM_PREVIOUS")" != "$src_checksum" ]; then | ||
| mkdir -p "$DIST_DIR/linux/${GOARCH}" | ||
| CGO_ENABLED=0 GOOS=linux GOARCH="$GOARCH" go build -C "$SCRIPT_DIR/../src" -o "$DIST_BIN" . | ||
| "$cmd" build -f "$SCRIPT_DIR/../Dockerfile" \ | ||
| --build-arg "TARGETPLATFORM=linux/${GOARCH}" \ | ||
| -t "$HELPER_IMAGE" \ | ||
| "$DIST_DIR" | ||
| printf '%s' "$src_checksum" > "$SRC_CHECKSUM_PREVIOUS" | ||
| return 0 | ||
| fi | ||
| return 1 | ||
| } | ||
|
|
||
| if build_image || ! image_in_kind; then | ||
| if [ "$cmd" = podman ]; then | ||
| "$cmd" save "$HELPER_IMAGE" | kind load image-archive /dev/stdin --name "$CLUSTER_NAME" | ||
| else | ||
| kind load docker-image "$HELPER_IMAGE" --name "$CLUSTER_NAME" | ||
| fi | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/usr/bin/env bash | ||
| # Shared kind env/runtime detection. Sourced by setup-kind.sh and stop-kind.sh. | ||
| # Caller may set SCRIPT_DIR to this script's dir (bin/); defaults to self-located. | ||
| # Sets $cmd (podman|docker) and exports KUBECONFIG. | ||
|
|
||
| SCRIPT_DIR="${SCRIPT_DIR:-${BASH_SOURCE[0]%/*}}" | ||
|
|
||
| # optional local overrides (e.g. KUBECONFIG); gitignored | ||
| [ -f "$SCRIPT_DIR/../.env.local" ] && source "$SCRIPT_DIR/../.env.local" | ||
| export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}" | ||
|
|
||
| if command -v podman &>/dev/null; then | ||
| export KIND_EXPERIMENTAL_PROVIDER=podman | ||
| cmd=podman | ||
| else | ||
| cmd=docker | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -eu | ||
| SCRIPT_DIR="${BASH_SOURCE[0]%/*}" | ||
|
|
||
| # source for KUBECONFIG and k8s context to be set | ||
| source "$SCRIPT_DIR/setup-kind.sh" opslevel-runner | ||
|
|
||
| exec watchexec --watch "$SCRIPT_DIR/../src" --exts go,mod,sum --restart \ | ||
| -- go run -C "$SCRIPT_DIR/../src" . run \ | ||
| --mode=faktory \ | ||
| --queues=runner \ | ||
| --job-pod-max-wait=900 \ | ||
| --runner-pod-namespace=default \ | ||
| --job-pod-helper-image=localhost/opslevel-runner:dev \ | ||
| --job-pod-requests-cpu="${OPSLEVEL_JOB_POD_REQUESTS_CPU:-50}" \ | ||
| --job-pod-requests-memory="${OPSLEVEL_JOB_POD_REQUESTS_MEMORY:-32}" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wouldn't say this is necessarily true - generally we prefer docker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is for the agent. It's hard to go the other way around. Falling back to the assumed more widely adopted tech.