-
Notifications
You must be signed in to change notification settings - Fork 502
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
Stable container name for the web service #1091
Comments
Docker network alias, umm could be a good one? |
We run There's more info here - https://dev.37signals.com/kamal-prometheus/ |
I'm really not sure why this ticket was closed, as I've got the same issue and I don't think this is properly covered.
but as @miharekar noted that name will change with each git commit.
Will work indeed, but I have not seen this option exposed. An example post-deploy hook: CONTAINER_ID=$(kamal server exec -q docker ps --filter "ancestor=ghcr.io/..." --format "{{.ID}}" | tail -n +2)
echo "Container ID: $CONTAINER_ID"
kamal server exec docker network disconnect kamal "$CONTAINER_ID";
kamal server exec docker network connect --alias cloudconnect kamal "$CONTAINER_ID";
|
I ran into the same issue when setting up Prometheus without otel collector and solved it adding a post-deploy hook that adds an alias on every deploy (something similar to @jonasbark's approach). That said, I don’t think this case is unique to Prometheus. We could be emitting anything through any port with a listener consuming it, and in all those cases, we should be able to connect to the container using a stable hostname. Having an option to add aliases right in the config would indeed be good. |
@jonasbark this was super useful for me to be able to get an "accessory" (anycable-go) to connect with a service (RPC) running as a "server" (in kamal's terms), thank you very much! 🙏 However, in the end I think I found a simpler solution, so I'll leave it here in case someone finds it useful. Since kamal forwards the servers:
anycable-rpc:
hosts: <%= ENV['HOST'] %>
options:
network-alias: my-app-anycable-rpc
accessories:
anycable-go:
# ... other configs
env:
clear:
ANYCABLE_RPC_HOST: "my-app-anycable-rpc:50051" Note: I initially tried the Edit: fixed the example with the proper |
Use case: I'd like to connect from Prometheus to my web service without going through the internet.
I can connect to other accessories like
[service-name]-cadvisor:9200
but[service-name]-web:80
goes through Kamal Proxy and that one rejects it, because it doesn't recognize the host.The actual container name of the web service changes with each deploy, so I can't really hardcode it in prometheus' config.yml.
Any other suggestions you might have of how I might achieve that?
The text was updated successfully, but these errors were encountered: