-
Notifications
You must be signed in to change notification settings - Fork 635
tilt: improve Tilt development workflow (#12956) #13255
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
d6f0847
1a4ef53
c958521
ead187c
65bcaee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ if str(local("command -v " + helm_cmd + " || true", quiet = True)) == "": | |
| settings = { | ||
| "helm_installation_name": "kgateway", | ||
| "helm_installation_namespace": "kgateway-system", | ||
| "helm_values_files": ["./test/kubernetes/e2e/tests/manifests/common-recommendations.yaml"], | ||
| "helm_values_files": [], | ||
| } | ||
|
|
||
| tilt_file = "./tilt-settings.yaml" if os.path.exists("./tilt-settings.yaml") else "./tilt-settings.json" | ||
|
|
@@ -57,9 +57,18 @@ RUN chmod 777 ./$binary_name | |
| standard_entrypoint = "ENTRYPOINT /app/start.sh /app/$binary_name" | ||
| debug_entrypoint = "ENTRYPOINT /app/start.sh /go/bin/dlv --listen=0.0.0.0:$debug_port --api-version=2 --headless=true --only-same-user=false --accept-multiclient --check-go-version=false exec --continue /app/$binary_name" | ||
|
|
||
| get_resources_cmd = "{0} -n {1} template {2} --include-crds install/helm/kgateway/ --set image.pullPolicy='Never' --set image.registry=ghcr.io/kgateway-dev --set image.tag='{3}'".format(helm_cmd, settings.get("helm_installation_namespace"), settings.get("helm_installation_name"), image_tag) | ||
| def _shell_escape_single_quotes(value): | ||
| """Escape a value for safe inclusion in a single-quoted shell string. | ||
| In POSIX shells, a single quote inside a single-quoted string is represented as: '"'"' | ||
| """ | ||
| return str(value).replace("'", "'\"'\"'") | ||
|
|
||
| get_resources_cmd = "{0} -n {1} template {2} --include-crds install/helm/kgateway/ --set image.pullPolicy='Never' --set image.registry=ghcr.io/kgateway-dev --set image.tag='{3}' --set controller.extraEnv.KGW_DISABLE_LEADER_ELECTION='true'".format(helm_cmd, settings.get("helm_installation_namespace"), settings.get("helm_installation_name"), image_tag) | ||
|
||
| for f in settings.get("helm_values_files") : | ||
| get_resources_cmd = get_resources_cmd + " --values=" + f | ||
| for key, value in settings.get("helm_sets", {}).items() : | ||
| escaped_value = _shell_escape_single_quotes(value) | ||
| get_resources_cmd = get_resources_cmd + " --set {0}='{1}'".format(key, escaped_value) | ||
|
|
||
| arch = str(local("make print-GOARCH", quiet = True)).strip() | ||
|
|
||
|
|
@@ -104,10 +113,12 @@ def build_docker_image(provider): | |
| tilt_helper_dockerfile, | ||
| tilt_dockerfile, | ||
| ]) | ||
| if provider.get("debug_port") : | ||
| dockerfile_contents = dockerfile_contents + debug_entrypoint | ||
| else : | ||
| dockerfile_contents = dockerfile_contents + standard_entrypoint | ||
|
|
||
Wolf-06 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Append the appropriate entrypoint based on whether debug_port is set | ||
| if provider.get("debug_port") : | ||
| dockerfile_contents = dockerfile_contents + debug_entrypoint | ||
| else : | ||
| dockerfile_contents = dockerfile_contents + standard_entrypoint | ||
|
|
||
| dockerfile_contents = dockerfile_contents.replace("$binary_name", provider.get("binary_name")) | ||
| dockerfile_contents = dockerfile_contents.replace("$debug_port", str(provider.get("debug_port"))) | ||
|
|
@@ -205,9 +216,12 @@ def install_kgateway(): | |
| install_helm_cmd = """ | ||
| kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || {{ kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.1.0/standard-install.yaml; }} ; | ||
| {0} upgrade --install -n {1} --create-namespace kgateway-crds install/helm/kgateway-crds ; | ||
| {0} upgrade --install -n {1} --create-namespace {2} install/helm/kgateway/ --set controller.image.pullPolicy='Never' --set image.registry=ghcr.io/kgateway-dev --set image.tag='{3}'""".format(helm_cmd, settings.get("helm_installation_namespace"), settings.get("helm_installation_name"), image_tag) | ||
| {0} upgrade --install -n {1} --create-namespace {2} install/helm/kgateway/ --set controller.image.pullPolicy='Never' --set image.registry=ghcr.io/kgateway-dev --set image.tag='{3}' --set controller.extraEnv.KGW_DISABLE_LEADER_ELECTION='true'""".format(helm_cmd, settings.get("helm_installation_namespace"), settings.get("helm_installation_name"), image_tag) | ||
|
||
| for f in settings.get("helm_values_files") : | ||
| install_helm_cmd = install_helm_cmd + " --values=" + f | ||
| for key, value in settings.get("helm_sets", {}).items() : | ||
| escaped_value = _shell_escape_single_quotes(value) | ||
| install_helm_cmd = install_helm_cmd + " --set {0}='{1}'".format(key, escaped_value) | ||
| local_resource( | ||
| name = settings.get("helm_installation_name") + "_helm", | ||
| cmd = ["bash", "-c", install_helm_cmd], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
|
|
||
| helm_installation_name: kgateway | ||
| helm_values_files: | ||
| - ./test/e2e/tests/manifests/common-recommendations.yaml | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm personally not in favour of this as the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The file is kind of a holdover from v1, doesn't really have much in it. Tilt needs some specific values, esp. KGW_DISABLE_LEADER_ELECTION.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the file again, I see now that it doesn't have a lot and is leftover from v1, but afaict most tests use this as the ProfileValuesManifestFile. The other specific values can be added to a tilt-profile.yaml or passed as helm flags in tilt-setting.yaml |
||
| helm_values_files: [] | ||
| # - ./my-custom-values.yaml | ||
| helm_installation_namespace: kgateway-system | ||
|
|
||
| # Inline Helm --set flags (key: value format) | ||
| helm_sets: {} | ||
|
||
| # Example: controller.extraEnv.KGW_VALIDATION_MODE: "strict" | ||
|
|
||
| enabled_providers: | ||
| - kgateway | ||
|
|
||
|
|
@@ -23,13 +26,27 @@ providers: | |
| # The service name | ||
| label: kgateway | ||
| # Command to build the binary | ||
| #build_binary: GCFLAGS='all="-N -l"' make -B kgateway | ||
| #build_binary: make -B kgateway GCFLAGS="all=-N -l" LDFLAGS="" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this change be reverted? It only updates a comment
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @davidjumani
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I mean is that the line is commented out, so any changes made don't have an effect. The command to build the binary is the subsequent line
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Use case:
We toggle between the options by commenting the other and uncommenting the one we wan to use.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has debugging been verified with this change ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
| build_binary: make -B kgateway | ||
| # Name of the binary file when built | ||
| binary_name: kgateway-linux-$ARCH | ||
| # A custom docker file. This might be required when the base image is different or managing an external project such as envoy | ||
| #dockerfile_contents: ... | ||
| # To enable debugging, just add the `debug_port` param to a provider (provided it supports debugging) | ||
| # Custom Dockerfile with Envoy binary for strict validation mode. | ||
| # NOTE: Do NOT include ENTRYPOINT here - the Tiltfile will append the correct | ||
| # entrypoint (standard or debug) based on whether debug_port is set. | ||
| dockerfile_contents: | | ||
| FROM quay.io/solo-io/envoy-gloo:1.36.3-patch1 as envoy-bin | ||
|
|
||
| FROM golang:latest as tilt | ||
| WORKDIR /app | ||
| COPY --from=tilt-helper /go/bin/dlv /go/bin/dlv | ||
| COPY --from=tilt-helper /process.txt . | ||
| COPY --from=tilt-helper /start.sh . | ||
| COPY --from=tilt-helper /restart.sh . | ||
| # Copy envoy binary for strict validation | ||
| COPY --from=envoy-bin /usr/local/bin/envoy /usr/local/bin/envoy | ||
| COPY $binary_name . | ||
| RUN chmod 777 ./$binary_name | ||
| # To enable debugging with strict validation, uncomment both debug_port and port 50100 | ||
Wolf-06 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #debug_port: 50100 | ||
| links: | ||
| - http://localhost:9092/metrics | ||
|
|
||
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.
Not in favour of this change