To start developing, you need the following tools installed:
All other remaining tools (e.g. kustomize
) are getting installed automatically when you start the development environment later on.
-
Depending on the
garm
server you want to use, you have to specify the server URL and the corresponding username and password in theconfig/overlays/local/manager_patch.yaml
file. -
Start the development environment by running
make tilt-up
in the root directory of this repository.This will start a local Kubernetes cluster using
kind
(kind get clusters
will show you agarm-operator
cluster) and deploy thegarm-operator
into it.The
make tilt-up
command will give you the URL to the local tilt environment. -
Time to start developing. 🎉
To improve the local development process, we add delve into garm-operator
container image.
This allows us to debug the garm-operator
running in the local kind
cluster.
The following steps are required to start debugging the garm-operator
:
-
set the
mode
variable fromlocal
todebug
in theTiltfile
This will start the
garm-operator
container with thecommand
andargs
specified in theconfig/overlays/debug/manager_patch.yaml
file. (Ensure that the correct GARM credentials are set.)The
garm-operator-controller-manager
pod should log then print the following log message which indicates that you are able to attach a debugger to thegarm-operator
:2023-12-08T15:39:21Z warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted) API server listening at: [::]:2345
-
IDE configuration
-
VSCode
- Create a
launch.json
file in the.vscode
directory with the following content:{ "version": "0.2.0", "configurations": [ { "name": "garm-operator - attach", "type": "go", "request": "attach", "mode": "remote", "port": 2345 } ] }
- Create a
-
IntelliJ
- Create a
.run
folder in the root of your project if not present. Create agarm-operator debug.run.xml
file with the following content:
<component name="ProjectRunConfigurationManager"> <configuration default="false" name="garm-operator debug" type="GoRemoteDebugConfigurationType" factoryName="Go Remote"> <option name="disconnectOption" value="ASK" /> <method v="2" /> </configuration> </component>
You can now choose your config in IntelliJs
Run Configurations
and hitDebug
- Create a
-
-
Happy debugging 🐛
If you need a garm-server
with a configured garm-provider-k8s in your local cluster to spin up some k8s based runners
for testing, you can do the following:
Clone the garm-provider-k8s
repo:
$ git clone https://github.com/mercedes-benz/garm-provider-k8s && cd ./garm-provider-k8s
And follow this guide. But instead
of the make tilt-up
in the garm-provider-k8s
repo, execute the folling command. Make sure you are in your kind-garm-operator
kubernetes context:
$ RUNNER_IMAGE="localhost:5000/runner:linux-ubuntu-22.04-x86_64" make build copy docker-build docker-build-summerwind-runner && kubectl apply -k hack/local-development/kubernetes/
Essentially this does the same as the make tilt-up
target in garm-provider-k8s
, but in your local garm-operator cluster. Otherwise, a separate cluster will be spawned with the latest garm-operator release.