I thought I'd recap the past few months. I'm beyond embarrassed to say that I'm still working on deployments. So far I have written, oh about 4, different deployment systems...one in Ansible, one using
JohnK's
drist tool, and several more written from scratch in
gleam. All of them worked until I fiddled with them until they broke, or I decided I didn't like them, or I accidentally deleted the code (yup). Anyway, I have now spent 100x the time on this problem than is reasonable. I know a bit more about jails and networking, but I'm not an expert in anything. I'm thinking of coming back, full circle, and am looking at
bastille.
Here's my path. Feel free to comment at any level. I'm a one person startup, trying to build a SaaS app. My thinking goes like this:
1. spend as little money as possible. don't risk overspend by using AWS/GCP/Azure. instead, rent bare metal (gthost) and use freebsd + jails
2. only rent one server, and have it dns point to it. this server then uses caddy to spread traffic for dev/stage/prod to dev/stage/prod jails
3. define a cidr schema to segregate traffic by environments, e.g. 10.0 -> global things like caddy, 10.1 -> dev, 10.2 -> stage, 10.3 -> prod
4. further refine the cidr schema to separate apps, such that 10.0.0 -> Caddy, 10.0.1 -> nginx, 10.1.0 -> dev webserver, 10.1.1 -> dev database
5. finally, use the last cidr set for blue/green deployments, such that 10.1.0.1/25 -> blue dev webserver, 10.1.0.128/25 -> green dev webserver
Note: I have other reasons for choosing freebsd than price. I'm a supporter of FOSS, EFF, and freedom in general. I think large corps are dysfunctional and a problematic.
Anyway, I actually had all of this working several times. Sigh.
One of the issues with the above setup is that I had it all working in an 10./8 space. Just one large network/broadcast segment. So I had templates to manage pf.conf for managing allowed traffic. With macros and whatnot, it's manageable, but pf.conf get's pretty big. However, the crucial failing of my approach is that every change to pf.conf has the potential to bring the network down, and the blast radius is global/dev/stage and prod environments.
So then I thought, separate bridges! That's the way to separate traffic. Somehow I didn't get that working.
So then I thought, VLANs! That's the way to separate traffic, and again, somehow I didn't get that working either.
So then I thought,
vlanfilter! That's the way to separate traffic, and again, somehow I didn't get that working either.
So then I thought, hierarchical jails! That's the way to limit the blast radius and make the pf.conf files easier to deal with.
Currently, I don't have anything fully working. And I need to pivot from this madness and just build the damn apps, get some customers, and then revisit all of this stuff when its actually relevant b/c I need to scale.
* Do I need my custom fancy jail deployment system that is like docker for freebsd? No.
* Do I need dev/stage/prod right now? No.
* Do I need hierarchical jails (for dev/stage/prod)? No.
* Do I need bridges, vlans, vlanfilter? I dunno, ...Probably a bridge...
* Do I need blue/green deployments...clearly No.
* Do I need bastille or any other system? I dunno, I think it's easier to use a tool than the bare jails tools, and getting ifconfig stuff right can be tricky sometimes. For instance, I never got thinjails working, so I defaulted back to thickjails.
One of the reasons I wrote my own system was so that I could generate templated pf.conf files that allowed traffic like this:
1. Allow traffic from the caddy loadbalancers to the jail web apps. This statement affects these files:
* pf.conf
* Caddyfile
2. Allow traffic from (dev|stage|prod) web jails over port X to database (dev|stage|prod) jails. This statement affects these files:
* pf.conf
* Caddyfile
* postgres conf file (iirc hba.conf)
* database ip address and password are injected into an environment file that the webapps use to auth to the database
I think that switching to vlans and/or vlanfilter would mean pf could be configured with vlan ids rather than individual jail ip addresses. That would definitely be much more manageable than what I've been doing.
So my questions for anyone reading this thread are:
Questions
1. What do you use to manage your jails and application deployments?
2. In the case of something like bastille, how manage it for repeatability? Shell scripts? Ansible? Nothing and write commands in the terminal each time?
Thanks in advance for any input/advice y'all might have.