I’ve spent the last few days trying to debug an issue on Kubernetes with an external plugin that I’ve been writing in Go for Prow. Prow’s hook component is forwarding on a GitHub webhook and the plugin mounts in various pieces of configuration from the cluster (the Prow config, GitHub OAuth token and the webhook HMAC secret). As a consequence, running the plugin standalone in my dev environment is tricky, but just the sort of scenario that Telepresence is designed for.
The following command is all that is needed to perform a whole host of magic:
1 2 3 4 5 6 7 8 |
telepresence \ --swap-deployment my-plugin-deployment \ --expose 8888 \ --mount=/tmp/tp \ --run ./my-plugin \ --config-path /tmp/tp/etc/config/config.yaml \ --hmac-secret-file /tmp/tp/etc/webhook/hmac \ --github-token-path /tmp/tp/etc/github/oauth |
- It locates
the my-plugin-deployment
deployment already running in the cluster and scales down the number of replicas to zero. - It executes
the my-plugin
binary locally and creates a replacement deployment in the cluster that routes traffic to the local process on the exposed port. - It finds the volumes defined in the deployment and syncs their contents
to /tmp/tp
using the mount paths also specified in the deployment. - Although not needed in this scenario, it also sets up the normal Kubernetes environment variables around the process and routes network traffic back to the cluster.
Now, it was convenient in this case that the binary already exposed command line arguments for the configuration files so that I could direct them to the alternative path. Failing that, you could always use Telepresence in its--docker-run
mode and then mount the files onto the container at the expected location
And the issue I was trying to debug? I had used refresh
configAgent.Start()
logrus
info
by default). As a consequence, everything was actually working as it should and my debug statements just weren’t outputting anything!