Comment on Question on SSL traffic between podman containers and clients (should I run k3s?)
vegetaaaaaaa@lemmy.world 1 year agoIs the fact that I mentioned ChatGPT setting a wrong impression?
Not at all, but the fact that it suggested jumping straight to k8s for such a trivial problem is… interesting.
how using Unix sockets would improve my security posture here
Unix sockets enforce another layer of protection by requiring the user/application writing/reading to/from them to have a valid UID or be part of the correct group (traditional Linux/Unix permission system). Whereas using plain localhost HTTP networking, a rogue application could somehow listen on the loopback interface and/or exploit a race condition to bind the port and prentend to be the “real” application. Network namespaces (which container management tools use to create isolated virtual networks) mostly solve this problem. Again, basic unencrypted localhost networking is fine for a vast majority of use cases/threat models.
MigratingtoLemmy@lemmy.world 1 year ago
Hey, thanks for your comment. My apologies in replying this late; I wanted to read more about Unix sockets and podman before I got back.
If I understand correctly, Unix sockets specifically allow two or more processes to communicate amongst each other, and are supporter on Podman (and Docker).
Now, the question is: how do I programmatically programmatically utilise sockets for containers to communicate amongst each other?
I was considering a reverse proxy per pod as someone else suggested, since every podman pod has its own network namespace. Connecting between pods should likely be through the reverse proxies then. I just need to figure out how I can automate the deployment of such proxies along with the pods.
Thanks again for your comment, and please let me know if I’m missing anything.
vegetaaaaaaa@lemmy.world 1 year ago
Sockets are filesystem objects, similar to a file. So for 2 containers to access the same socket, the container exposing the socket must export it to the host filesystem via a
bind
mount/volume, and the container that needs read/write on this socket must be able to access it, also via a bind mount. The user ID or groups of the user accessing the socket must be allowed to access the socket via traditional unix permissions.Again, I personally do not bother with this, install the reverse proxy directly on the host, and configure it to forward traffic over HTTP on the loopback interface to your containers.
That’s a separate question. I use ansible for all deployment/automation needs - when it comes to podman I use the podman_container and podman_generate_systemd modules to automate deployment of containers as systemd services. The ansible also configures my reverse proxy to forward traffic to the container (simply copy files in
/etc/apache2/sites-available/…; a2enconf; systemctl reload apache2
). I have not used pods yet, but there is a podman_pod module. A simple bash script should also do the trick in a first time.MigratingtoLemmy@lemmy.world 1 year ago
Could you detail how you would do this? Especially since the containers in my case do not support HTTPS (they do not have the libraries compiler, if I’m not wrong).
Thank you for the clarification. I do not think I’ll be running malicious containers inside my pods, but I would like to contain unencrypted traffic as much as possible. Running an RP for every pod seems doable and since I reach containers through their loopback address inside the pod, this is reasonably safe for my use-case too.
Could you confirm if one can reach one’s containers on the loopback address in a separate network namespace on podman? I was wondering about the differences between a pod and a network namespace on podman, and so far the only mention of something like this is that containers in pods share a “security context”. I don’t know enough to understand what this is since I haven’t read about pods in Kubernetes.
Thanks, I was planning to use Ansible too.
vegetaaaaaaa@lemmy.world 1 year ago
I would re-read all docs about podman networking, different network modes, experiment with systemd
PrivateNetwork
option, re-read some basic about network namespaces, etc ;) I have no precise guide as I’ve never attempted it, so I would do some research, trial and error, take notes, etc, which is the stage you’re at.I think each pod uses its own network namespace [1]. You should check the docs and experiment (
ip netns, ip addr, ip link, ip route…
).I think it’s doable, but pretty much uncharted territory - at least the docs for basic building blocks exist, but I’ve never come across a real world example of how to do this. So if you go this way, you will be on your own debugging, documenting and maintaining the system and fixing it when it breaks. It will be an interesting learning experiment though, hope you can document and share the outcome. Good luck!