Skip to content
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

Generate dynamic myhostname for each pod #165

Closed
wants to merge 4 commits into from

Conversation

jonathon2nd
Copy link
Contributor

To comply with ISP's request, and according to smtp best practices, I would like to have dynamic hostnames for my smtp servers.

Simply using the HOSTNAME env var is not helpful as by default is something like mail-0. Looked briefly into hacking it to be closer to what I want, but decided it was not worth it.

I have made an attempt at this, I know it is not the best. But it works and I bet if y'all like it you can do it better.

By setting the following in the values.

# if the following is true, config.prefix.myhostname should not be set
GenerateHostName:
  enabled: true
  domain: example.com
  prefix: smtp

The following hostname will be used by each pod, and they will be unique and be built off of the public IP of that host.
smtp-###-###-###-###.example.com

We have tested this out and it is fully working. Have it in use right now and monitoring.

I hope that this can be useful.

@bokysan
Copy link
Owner

bokysan commented Dec 29, 2023

Hello @jonathon2nd.

Thank you so much for this commit. After careful consideration, though, I've decided not to merge it. I understand your reasoning for making it.

However:

  1. This is a pretty edge-case scenario, which would not benefit a lot of people.
  2. It includes a lot of external dependencies (e.g. on curlimages/curl:latest and http://ipinfo.io).
  3. It works with helm chart only, there's no way to use this with Docker-only installation.
  4. It increases complexity of the code.
  5. Same thing can be achieved 'manually' by simply mounting the following script into /docker-init.db/:
#!/usr/bin/env bash
# This should be placed under /docker-init.db/set_hostname.sh
IP=$(curl http://ipinfo.io/ip)
IP=$(echo "$IP" | tr '.' '-')
PREFIX="prefix" # Alternately, this could be provided from environment
DOMAIN="example.org" # Alternately, this could be provided from environment
postconf -e "myhostname=${PREFIX}-${IP}.${DOMAIN}"

Again, thank you so much for the commit either way -- I'm happy that the image serves its purposes!

@bokysan bokysan closed this Dec 29, 2023
jonathon2nd added a commit to fpm-git/docker-postfix that referenced this pull request Dec 29, 2023
jonathon2nd added a commit to fpm-git/docker-postfix that referenced this pull request Dec 29, 2023
@jonathon2nd
Copy link
Contributor Author

Thanks for the feedback! I took it and simplified the setup.

Setup here with this correction, just in case anyone else would find this useful.

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