Skip to content

feat: Add KAMAL_HOST to app and accessory containers#1471

Merged
djmb merged 1 commit intobasecamp:mainfrom
jakeprem:jakeprem/add-kamal-host-var
May 20, 2025
Merged

feat: Add KAMAL_HOST to app and accessory containers#1471
djmb merged 1 commit intobasecamp:mainfrom
jakeprem:jakeprem/add-kamal-host-var

Conversation

@jakeprem
Copy link
Contributor

@jakeprem jakeprem commented Mar 26, 2025

I searched existing issues and blog posts and didn't see a way to see which host a container was running on.

I'm running Opentelemetry Collector as an accessory on my hosts as a target for OTLP traces, scraper for Prometheus metrics, and using the hostmetrics receiver to grab stats about my VMs in Hetzner. Mainly for the hostmetrics I needed a way to label which VM/host it corresponds to. From what I could see apps get deployed with <host>-<container identifier> as their default hostname, but accessories just got <container identifier>.

I didn't see any other clean ways to set per-host environment variables so this seemed like the simplest solution.

Happy to have any feedback, and if this seems like a viable change I can go back and add some tests for it too. (So far I did manually testing with an accessory using host, hosts, and roles.)

edit: Looks like this change does need me to update some of the tests so we can probably skip running the workflow for now.

Adds the host the container is being deployed to as KAMAL_HOST.
My use case is to more easily tag the host for metrics tagging,
but there might be other uses as well.
@djmb djmb merged commit 9c8a44e into basecamp:main May 20, 2025
@djmb
Copy link
Collaborator

djmb commented May 20, 2025

Following up with passing tests in #1564

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants