|
| 1 | +# Welcome to Tilt! |
| 2 | +# To get you started as quickly as possible, we have created a |
| 3 | +# starter Tiltfile for you. |
| 4 | +# |
| 5 | +# Uncomment, modify, and delete any commands as needed for your |
| 6 | +# project's configuration. |
| 7 | + |
| 8 | +cluster_name = 'k8scluster' |
| 9 | +project_name = 'taintmanager' |
| 10 | + |
| 11 | +# Allow the cluster to avoid problems while having kubectl configured to talk to a remote cluster. |
| 12 | +allow_k8s_contexts(cluster_name) |
| 13 | + |
| 14 | +# Use custom Dockerfile for Tilt builds, which only takes locally built binary for live reloading. |
| 15 | +dockerfile = ''' |
| 16 | + FROM golang:1.19-alpine |
| 17 | + RUN go install github.com/go-delve/delve/cmd/dlv@latest |
| 18 | + COPY %s /usr/local/bin/%s |
| 19 | + ''' % (project_name, project_name)# Build Docker image |
| 20 | + |
| 21 | +# Tilt will automatically associate image builds with the resource(s) |
| 22 | +# that reference them (e.g. via Kubernetes or Docker Compose YAML). |
| 23 | +# |
| 24 | +# More info: https://docs.tilt.dev/api.html#api.docker_build |
| 25 | +# |
| 26 | +# docker_build('registry.example.com/my-image', |
| 27 | +# context='.', |
| 28 | +# # (Optional) Use a custom Dockerfile path |
| 29 | +# dockerfile='./deploy/app.dockerfile', |
| 30 | +# # (Optional) Filter the paths used in the build |
| 31 | +# only=['./app'], |
| 32 | +# # (Recommended) Updating a running container in-place |
| 33 | +# # https://docs.tilt.dev/live_update_reference.html |
| 34 | +# live_update=[ |
| 35 | +# # Sync files from host to container |
| 36 | +# sync('./app', '/src/'), |
| 37 | +# # Execute commands inside the container when certain |
| 38 | +# # paths change |
| 39 | +# run('/src/codegen.sh', trigger=['./app/api']) |
| 40 | +# ] |
| 41 | +# ) |
| 42 | + |
| 43 | + |
| 44 | +# Run local commands |
| 45 | +# Local commands can be helpful for one-time tasks like installing |
| 46 | +# project prerequisites. They can also manage long-lived processes |
| 47 | +# for non-containerized services or dependencies. |
| 48 | +# |
| 49 | +# More info: https://docs.tilt.dev/local_resource.html |
| 50 | +# |
| 51 | +# local_resource('install-helm', |
| 52 | +# cmd='which helm > /dev/null || brew install helm', |
| 53 | +# # `cmd_bat`, when present, is used instead of `cmd` on Windows. |
| 54 | +# cmd_bat=[ |
| 55 | +# 'powershell.exe', |
| 56 | +# '-Noninteractive', |
| 57 | +# '-Command', |
| 58 | +# '& {if (!(Get-Command helm -ErrorAction SilentlyContinue)) {scoop install helm}}' |
| 59 | +# ] |
| 60 | +# ) |
| 61 | + |
| 62 | +# Building binary locally. |
| 63 | +local_resource('%s-binary' % project_name, |
| 64 | + 'GOOS=linux GOARCH=amd64 go build -gcflags "all=-N -l" -o taintmanager taintmanager.go', |
| 65 | + deps=[ |
| 66 | + './taintmanager.go', |
| 67 | + ], |
| 68 | +) |
| 69 | + |
| 70 | +# Extensions are open-source, pre-packaged functions that extend Tilt |
| 71 | +# |
| 72 | +# More info: https://github.com/tilt-dev/tilt-extensions |
| 73 | +# |
| 74 | +load('ext://git_resource', 'git_checkout') |
| 75 | + |
| 76 | +# Load the restart_process extension with the docker_build_with_restart func for live reloading. |
| 77 | +load('ext://restart_process', 'docker_build_with_restart') |
| 78 | + |
| 79 | +# Wrap a docker_build to restart the given entrypoint after a Live Update. |
| 80 | +docker_build( |
| 81 | + 'lthub/' + project_name, |
| 82 | + '.', |
| 83 | + dockerfile_contents=dockerfile, |
| 84 | + entrypoint='/go/bin/dlv --listen=0.0.0.0:50100 --api-version=2 --headless=true --only-same-user=false --accept-multiclient --check-go-version=false exec -- /usr/local/bin/taintmanager -remove jupyterhub:NoSchedule', |
| 85 | + live_update=[ |
| 86 | + # Copy the binary so it gets restarted. |
| 87 | + sync(project_name, '/usr/local/bin/%s' % project_name), |
| 88 | + ], |
| 89 | +) |
| 90 | + |
| 91 | +# Apply Kubernetes manifests |
| 92 | +# Tilt will build & push any necessary images, re-deploying your |
| 93 | +# resources as they change. |
| 94 | +# |
| 95 | +# More info: https://docs.tilt.dev/api.html#api.k8s_yaml |
| 96 | +# |
| 97 | +# k8s_yaml(['k8s/deployment.yaml', 'k8s/service.yaml']) |
| 98 | +# Create the deployment from YAML file path. |
| 99 | +k8s_yaml('deployment.yaml') |
| 100 | + |
| 101 | +# Configure the resource. |
| 102 | +k8s_resource( |
| 103 | + project_name, |
| 104 | + port_forwards = ["50100:50100"] # Set up the K8s port-forward to be able to connect to it locally. |
| 105 | +) |
0 commit comments