News for hackers. Stuff that matters.
Re:The Twelve-Factor App by zemo on Thursday October 12, 2023 @11:23AM (#37858507)
the twelve-factor app is a set of recommendations from 2011 that are based less on engineering principles and more on the capabilities of Heroku and containerized infrastructure in 2011. For example:

> Another approach to config is the use of config files which are not checked into revision control, such as config/database.yml in Rails. This is a huge improvement over using constants which are checked into the code repo, but still has weaknesses: it’s easy to mistakenly check in a config file to the repo; there is a tendency for config files to be scattered about in different places and different formats, making it hard to see and manage all the config in one place. Further, these formats tend to be language- or framework-specific.

> The twelve-factor app stores config in environment variables (often shortened to env vars or env).

yeah the reason they argue for this is that the people that wrote this worked on Heroku, and the way that Heroku worked is you populated the environment variables from some fields in a web app. If you want your config history tracked in version control, or you do gitops, or you have k8s configmaps, or you want to have your configuration files on a mounted volume ... those things are all broadly fine; they keep the configuration state separate from the app deploy state. This document really confuses the forest with the trees and recommends things based less on actual engineering principles and more on the product capabilities of the corporation that produced it. It is an actively harmful set of guidelines.

Re:The Twelve-Factor App by jbotdev on Thursday October 12, 2023 @11:41AM (#37858752)
It is true that this is somewhat influenced by how Heroku works, but ConfigMaps and GitOps do not meet the same security and usability requirements as Heroku config/env vars.

If you want secure config storage on Kubernetes, you end up using Secrets, which ends up being key-value like env vars anyway. If you want similar security with Git you need a layer of encryption, which breaks diffs and requires additional tooling. This all leads back to why high-level deployment tools like Heroku were created.

Re:The Twelve-Factor App by campbel on Thursday October 12, 2023 @11:50AM (#37858861)
> If you want secure config storage on Kubernetes, you end up using Secrets, which ends up being key-value like env vars anyway.

You can load the secret file directly into the app, no need to load it as env vars or keep it strictly as key-value pairs.

> If you want similar security with Git you need a layer of encryption, which breaks diffs and requires additional tooling. This all leads back to why high-level deployment tools like Heroku were created.

You can use tools like ejson[1] or sops[2] to get encrypted files checked into Git that have key level granularity on diffs.

There is definitely a place for higher level abstractions than Kubernetes. Mostly it gives operators a standard platform to build from when teams outgrow the PaaS sandbox.

[1] https://github.com/Shopify/ejson [2] https://github.com/getsops/sops

Re:The Twelve-Factor App by Spivak on Thursday October 12, 2023 @12:23PM (#37859344)
> You can load the secret file directly into the app

Now you're getting away from the spirit of 12factor and hard-coupling them again. The intent is for the app to consume the secrets but have no knowledge or care where they came from.

Edit: misread as "load the secrets directly into the app." Yeah, this is just env vars but different.

Re:The Twelve-Factor App by derefr on Thursday October 12, 2023 @12:33PM (#37859463)
My trick for this with k8s Secrets, when there's some sort of config file that absolutely must be consumed from disk, is to

1. create a Secret that defines the file as a key

2. mount that Secret into the container (.secret.secretName in the volume definition) under an arbitrary conventional path, e.g. /secrets

3. define an env-var that gives the path to the file; where the assumption when this env-var isn't defined is to find the file in the working directory. If your own code uses the file, it can read the path from this env-var; while if the core of your container is some opaque tool that doesn't know about the env-var but does take the file's path on the command-line, then you can wrap the tool in an entrypoint script that reads the env-var and passes it as a command-line arg to the tool.

IMHO, this approach is flexible but principle-of-least-surprise obeying for both development and production deployment.

Re:The Twelve-Factor App by inferiorhuman on Thursday October 12, 2023 @01:40PM (#37860338)
That sounds an awful lot like a .env file to me.
Re:The Twelve-Factor App by pojzon on Thursday October 12, 2023 @02:10PM (#37860738)
yup thats exactly what .env is, and tbh that doesn't change anything in the bigger picture
Re:The Twelve-Factor App by derefr on Thursday October 12, 2023 @05:24PM (#37863344)
...no? It's the opposite.

A .env file allows you to go from knowing/assuming where a particular file is, to having environment variables.

What I'm describing is that you can go from being passed environment variables directly, to knowing where certain files are; which therefore allows those files to be mounted into a container-image in arbitrary places, rather than encoding brittle assumptions about config-file locations into the binary within the container-image — assumptions that usually get in the way during development, when you're not running the binary inside a container.

Re:The Twelve-Factor App by inferiorhuman on Friday October 13, 2023 @12:34AM (#37866715)
Re:The Twelve-Factor App by derefr on Friday October 13, 2023 @02:48PM (#37874072)
You still didn't understand my point. The thing that I'm talking about is using env-vars to point at config files that do not themselves contain env-vars, but rather are opaque app-specific config files, in formats like YAML or whatever-else.
Re:The Twelve-Factor App by yjftsjthsd-h on Thursday October 12, 2023 @12:30PM (#37859424)
I'm not really kubernetes expert, but don't they come from /my-secrets and the application doesn't need to care how that got mounted?
Re:The Twelve-Factor App by kelnos on Thursday October 12, 2023 @01:42PM (#37860368)
> Now you're getting away from the spirit of 12factor

The entire point here is that 12-factor isn't the be-all, end-all, so this is irrelevant.

> The intent is for the app to consume the secrets but have no knowledge or care where they came from.

This doesn't really make sense, and is an impossible requirement. The app will always have to know where configuration or secrets come from. Environment variables is just one option of "knowing where they come from". Choosing file storage is just as valid.

Re:The Twelve-Factor App by kagakuninja on Thursday October 12, 2023 @01:54PM (#37860530)
I don't use kubernates. We have JVM servers running on AWS. We load secrets from Secrets Manager. Configs are mostly HOCON files stored in S3. The knowledge of where to find them is configured via env vars.

We use a custom setup in which the config values are loaded from multiple sources actually, so we could put everything into secrets manager, or load them all from env vars or HOCON files.

If we had to set every config value in ECS / lambda using env vars, it would be a major pain in the ass, and error prone.

Re:The Twelve-Factor App by pojzon on Thursday October 12, 2023 @02:12PM (#37860775)
> We load secrets from Secrets Manager

And how your apps authenticate to Secrets Manager ? Did you ever call `env` on a pod that has IRSA configured ?

This is just a middle step to do exactly the same thing but instead of using envFromSecret you use envFromSM

Re:The Twelve-Factor App by maccard on Thursday October 12, 2023 @04:13PM (#37862584)
Not OP but an IAM role with scoped access to secrets. Better again, using secretsFrom in the task definition which injects the secret as an environment variable for you.
Re:The Twelve-Factor App by pojzon on Friday October 13, 2023 @05:08PM (#37875653)
IRSA in pods and containers is translated to env vars. That was the point.

That if you dont want to pull in k8s dependencies to the code, at the end every approach ends up as a mounted file or env vars.

Re:The Twelve-Factor App by redeux on Thursday October 12, 2023 @12:08PM (#37859132)
> somewhat influenced by how Heroku works

The Twelve-Factor App is marketing content produced by the former Founder & CTO of Heroku. It's a great piece of content no doubt, but it should be viewed with that lens.

Re:The Twelve-Factor App by probotect0r on Thursday October 12, 2023 @03:23PM (#37861855)
If it's marketing content then it's not doing a very good job. I have known about the 12factor app principles for a long time, and only found out today that it has ties to Heroku.
Re:The Twelve-Factor App by pests on Thursday October 12, 2023 @05:08PM (#37863167)
Likewise.
Re:The Twelve-Factor App by nine_k on Thursday October 12, 2023 @07:38PM (#37864580)
Still, Heroku would look impressively good if you wanted to deploy a 12-factor app, won't it?

Not all marketing is that straightforward.

Re:The Twelve-Factor App by nine_k on Thursday October 12, 2023 @07:34PM (#37864556)
I'd say 99% of my configs are not secret, at least not from containers running nearby.

I'm fine reading a few passwords and tokens from a secure key-value store. But the rest of my config can be a bit more expressive.

Re:The Twelve-Factor App by sgarland on Friday October 13, 2023 @08:04AM (#37869657)
ExternalSecrets with K8s. Put them into SOPS, Vault, your cloud’s secrets handler etc. - then reference them in the app as though they exist. They get loaded at deployment.

Doesn't break diffs, doesn’t directly couple anything.

Re:The Twelve-Factor App by morelisp on Thursday October 12, 2023 @11:31AM (#37858621)
The 12 factor app that stored config in env vars found it trivial to migrate to ConfigMaps. The LOB apps today that expect complex ConfigMap layouts (at worst case, directly from the k8s API) are going to be hell to migrate to whatever comes after k8s.
Re:The Twelve-Factor App by throw1234651234 on Thursday October 12, 2023 @11:36AM (#37858688)
The whole .env file holding all your configs thing is a disaster. People forget to update the template, it has to be passed around, etc.

Configure your secrets in Azure Key Vault (AWS Secrets Manager, GCP-something-I-forget) or whatever the non-cloud Vault software is called.

Devs only set client_id, client_secret, and env defaulted to dev. On startup, the app fetches configs for the secret store. The needed secrets are in source control. If the needed secret is missing from the secret store, there is a clear error on startup.

You are welcome, I just saved you weeks of onboarding, confusion, and devs passing around .envs on Slack.

Re:The Twelve-Factor App by campbel on Thursday October 12, 2023 @11:52AM (#37858897)
I agree, sops / ejson / gitcrypt or something else that encrypts a file in vcs, then use your cloud or shared secret vault to disperse the decryption key.
Re:The Twelve-Factor App by danwee on Thursday October 12, 2023 @11:58AM (#37858984)
> You are welcome, I just saved you weeks of onboarding, confusion, and devs passing around .envs on Slack.

Don't get it. At one company I worked, .env files for the DEV environment were open (the file itself was stored on Vault, so only engineers had access to it), and one could only access DEV resources via VPN. So, starting a service using the DEV .env file was rather easy an uncomplicated.

Re:The Twelve-Factor App by throw1234651234 on Thursday October 12, 2023 @01:47PM (#37860422)
Here is the problem with that. A dev pushes a change that requires a change to the env file. Another dev pulls down the code, but doesn't change the env file. Everything breaks. At really bad companies, DevOps sets env vars from somewhere other than that file passed around by devs - another failure point.

My proposal:

1. Key Vault | HashiCorp Vault | whatever is the source of truth for secrets.

2. When a developer adds a key, they add it to Key Vault and update code to use it.

3. On app startup, code checks the dev's local for 2 env vars ONLY, which allow access to key vault.

4. The app then tries to pull in all the env vars it needs by secret name.

5. If any are missing, it fails.

This keeps devs from having to pass around .env files outside of source control. Btw, Azure (and all other cloud) builds can be configured to pull env vars directly from Key Vault, so there's that benefit too.

Re:The Twelve-Factor App by parasti on Thursday October 12, 2023 @02:48PM (#37861304)
"5. If any are missing, it fails."

That's literally all you need to solve the scenario you described with .env files.

Re:The Twelve-Factor App by meowtimemania on Thursday October 12, 2023 @03:44PM (#37862184)
The difference is any time the .env config is updated, all engineers have to update their .env file.

So with .env file:

- developer adds to .env

- pushes code

- all developers see failures in dev env due to missing env var

- all developers search slack/email to figure out what went wrong

- all developers update their .env file and things are working again

————- In gp’s comment ———-

- one person works on feature that introduces new config

- failure happens in their local environment

- they update config backend and push code

- all other developers get updates with no changes needed

Re:The Twelve-Factor App by Rapzid on Thursday October 12, 2023 @04:18PM (#37862651)
You can also just supply defaults that can be locally overriden.. Benefit is they are reviewable in the same PR that adds the code depending on them..
Re:The Twelve-Factor App by throw1234651234 on Thursday October 12, 2023 @05:00PM (#37863092)
You can't keep secrets in code most of the time.
Re:The Twelve-Factor App by Rapzid on Thursday October 12, 2023 @05:14PM (#37863225)
Usually not big secrets.

I do and have done both and a blend. Secrets for external services needed in dev usually in parameter store. Kinda depends on the existing work flow. There is so much to do you should be tackling problems that move the needle and chip away at small stuff, pet peeve stuff in smaller time-boxed increments.

It depends, always it depends.

Re:The Twelve-Factor App by throw1234651234 on Thursday October 12, 2023 @04:13PM (#37862587)
Exactly, thank you for phrasing it much better than I did!
Re:The Twelve-Factor App by ATMLOTTOBEER on Friday October 13, 2023 @01:41AM (#37867105)
This is the workflow my company uses. It seems to work ok, but it’s hard to maintain discipline around using this pattern consistently
Re:The Twelve-Factor App by victorNicollet on Friday October 13, 2023 @03:13AM (#37867710)
My company enforces this with two rules. One, deployment always builds and deploys exactly what's in the git repository, so there is no way to include anything else (secrets, configuration...) in a deployment. Two, it's obviously forbidden to commit secrets to the git repository (we enforce this through training and reviews, but it's fairly easy to add pre-commit hooks as well).
Re:The Twelve-Factor App by victorNicollet on Friday October 13, 2023 @03:16AM (#37867731)
There's an optional but very helpful sixth step: expose the loaded configuration (by pushing it to the logs, or as a /_config endpoint). For secrets, obviously don't expose the secret value itself, but do expose the vault address, secret identifier, and which version of the secret was loaded. This helps check that an application isn't using an outdated version of a secret.
Re:The Twelve-Factor App by nickzelei on Thursday October 12, 2023 @12:08PM (#37859147)
I've resulted into a pretty similar setup.

We use SOPS and the encrypted .env file is stored in VCS. The key is stored in 1password with instructions on where to stuff it on your machine. Then you just decrypt the .env file and you're off to the races.

Re:The Twelve-Factor App by edwinbalani on Thursday October 12, 2023 @12:12PM (#37859184)
For anyone new to SOPS like I was - https://github.com/getsops/sops
Re:The Twelve-Factor App by victorNicollet on Thursday October 12, 2023 @12:32PM (#37859453)
Hard agree. I think it's easy to get stuck on the mental model that "the configuration value is the secret" (which means the configuration itself needs special handling), and the correct mental model should be "the configuration value is the identifier of the secret", with another system (Azure Key Vault, etc) being responsible for converting the secret-identifier into the secret-value.

My company open sourced the .NET library we use for this: https://github.com/Lokad/Secrets

Re:The Twelve-Factor App by geraldwhen on Thursday October 12, 2023 @01:57PM (#37860576)
The corporate VPN and proxy setups tend to fail or be slow. This would add non-trivial startup time to any app, and catastrophic startup time to integration tests.
Re:The Twelve-Factor App by xwdv on Thursday October 12, 2023 @12:03PM (#37859062)
If it is truly harmful, it shouldn’t be sitting at the top of Hackernews. Let’s flag it.
Re:The Twelve-Factor App by zemo on Thursday October 12, 2023 @12:14PM (#37859218)
I... don't think the "flag" functionality is intended to communicate "this is bad advice".
Re:The Twelve-Factor App by xwdv on Thursday October 12, 2023 @12:49PM (#37859677)
It is “harmful” advice, not bad. Regardless, why should it sit on the front page of hackernews?
Re:The Twelve-Factor App by zemo on Thursday October 12, 2023 @01:15PM (#37860034)
it's really hard for me to express just how much content hits the front page of HN that, if you follow it, will make you worse at programming.
Re:The Twelve-Factor App by russelg on Thursday October 12, 2023 @08:12PM (#37864826)
Because there is productive discussion about it in the comments?
Re:The Twelve-Factor App by v2223943777435 on Thursday October 12, 2023 @03:54PM (#37862325)
i got a ton of value out of reading the comments though
Re:The Twelve-Factor App by wutwutwat on Thursday October 12, 2023 @12:40PM (#37859559)
Heroku didn’t invent ENV variables nor did it dream up the idea of using them for app config. This has been in use long before Heroku existed. I’ll give Heroku credit for making it common knowledge and spreading the use of these concepts, though.
Re:The Twelve-Factor App by zemo on Thursday October 12, 2023 @01:08PM (#37859959)
yeah I never suggested that heroku invented environment variables, and the idea that environment variables weren't common knowledge before heroku came along is ... let's say at best revisionist.
Re:The Twelve-Factor App by wutwutwat on Thursday October 12, 2023 @01:24PM (#37860131)
True.

If you remember the world before 12 factor you know that even if motivated by self serving incentives, Heroku making this mainstream has been an overall win for the entire industry and we are generally better and more secure for them having done so. We are still benefitting from all of this today, and Heroku who championed it is making death rattles.

Re:The Twelve-Factor App by hirako2000 on Thursday October 12, 2023 @02:48PM (#37861322)
While valid points in many contexts, I've seen many other contexts where following this principle/pattern a/ yields none of its benefits b/ results in very significant business impact.

Here is some obvious case observed many times.

A small and very fast pace team builds a server application having limited to no external dependencies. No db even.

Just a server doing stuff.

It does have some config yes, many many key/value pairs even, a config file ended up with a dozen properties just to control Req per sec limits and such.

Now just to deploy the thing, since of course env defined configurations is where things belong in best practice, the dev team setup a process to peer review those env values and despite all of that, fail to get the app running.

Human errors happen but since more mistakes and release delays were caused by misconfiguration than any other reasons, the keen and bright enginnering team all agreed it would be better to have a config repo. One genius in the group argued that having a config service would be even neater than have the app read from a git repo! The whole got so hyped and of course spend the whole next sprint building and testing that. Brilliant, it worked!

Except that of course outages happened, of course. Outages happen.

Bringing down all environments one by one, hence blocking pretty much everyone. Everything went down because hey, since we made that effort which took for longer than we thought to build a config service and have our app reads from it, one of the dev minds thought it was a genius idea to have the app reload the config every 5 mins at runtime so that if a configuration change was made, no need to even restart anything. Of course error handling wasn't robust and well tested since the boss reminded the team we've got to ship a product by the end of the quarter and solving the universe can maybe wait 5 or 10 years after the IPO.

Team resorted to simply track the config in the repo. Kept the runtime reload of the config and things worked just fine.

Things can be done right and impacts could have been avoided. The example may seem like a twisted case since these were all configurations, not environment specific values. But I've just seen so many occurences of env variables being separated from the application repo costing so much and distracting contributors for no benefit that I have grown very cautious of it.

Re:The Twelve-Factor App by ElevenLathe on Thursday October 12, 2023 @04:04PM (#37862468)
The intent of this part of 12 Factor comes from the Bad Old Days when devs didn't run their own stuff in production. There was a dev team who could push code and cut releases, and an ops team who would then deploy the releases, and who was paged when things blew up.

If you store the database hostname/credentials, as an example, in the "code" (either literally in the app code, or in a config.ini that lives in the repo and gets baked into a release), then the ops people can't quickly repoint the app at a hot-spare database during an incident: they'll need to edit the repo, push it, cut a new release, etc. If there is a long build step (as for a C++ app, for example), then this isn't really tenable during an outage. If this is in an environment variable, their normal deployment scripts can make the change for them.

I agree that this is probably not necessary anymore if your team is all wearing both hats (dev and ops), and its just as quick to make an edit to the repo and cut/deploy a new release as it would have been for the Ops team to run their deployment script in the old days.

Re:The Twelve-Factor App by hirako2000 on Friday October 13, 2023 @11:16AM (#37871583)
Great you pointing out the presence vs absence of dedicated operation enginners. Also that things have evolved more than a bit in team structures and tooling.

Even when ops are perfectly comfortable with git, they are rarely keen on touching dev repos even if deployment times were tenable. If code changes need peer reviewed, how so configuration values don't get treated at least the same way?

Secrets in clear are obviously a no go, I feel though that encrypted secrets in repos has become reasonably simple with mature tooling in this area. Ansible's fast growth got cut short once people started to hear k8s at every meet ups perhaps.

Re:The Twelve-Factor App by ElevenLathe on Friday October 13, 2023 @11:47AM (#37871914)
Secrets in the repo is actually something I've seen for a long time, and there's not much tooling necessary for it beyond just shelling out (yes, I know) to gpg in your deploy scripts. I saw this on CVS-based projects very early in my career, which then fizzled out as the "12 factor style" (secrets in ENV vars) took over.

Can I ask what the modern solution for this is?

Also:

> If code changes need peer reviewed, how so configuration values don't get treated at least the same way?

The easy answer to this is a CODEOWNERS file, with the app code being owned by the devs, and the config being owned by ops. But again, not sure how to do this for secrets without their being plaintext in the repo. Do any code review tools support encrypted content?

Re:The Twelve-Factor App by phendrenad2 on Thursday October 12, 2023 @12:59PM (#37859845)
History repeats itself. Netlify tried this with the MACH Alliance.
Re:The Twelve-Factor App by donatj on Thursday October 12, 2023 @01:22PM (#37860102)
The invention of dotenv files just makes me chuckle and seems to completely miss the point of not putting them in a config file.
Re:The Twelve-Factor App by bunderbunder on Thursday October 12, 2023 @02:04PM (#37860677)
dotenv files are great as a piece of developer ergonomics. And that's fine. I use them for that purpose all the time. I would not willingly consent to using them to manage environment variables in production. But I would also not willingly consent to doing it the way that's best for production during development.

I think that's fine. 12-factor is a set of guidelines about what you do in production. There's a whole universe of things that are smart ideas for development and bad ideas for production. Leaving debug symbols in your binaries, leaving ports for connecting a debugger open on your containers, etc.

Re:The Twelve-Factor App by zmmmmm on Thursday October 12, 2023 @05:06PM (#37863148)
It's interesting to me that your philosophy does sharply contradict with another popular notion which is that there is great benefit in unifying production and development environments. Curious what your take on that is.
Re:The Twelve-Factor App by Aeolun on Thursday October 12, 2023 @09:01PM (#37865226)
Loading environment variables from a .env file if it exists is no different between development and production.

You just set the variables at startup in prod, and in the file on development (probably mostly because you want to change them all the time).

Re:The Twelve-Factor App by stackskipton on Thursday October 12, 2023 @09:04PM (#37865259)
Ops person here. .env files at best should be injected into Developer environment by IDE/Editor. Many IDE/editors have this feature along with Docker. If that's not an option (Thanks JetBrains/Visual Studio), second thing is something like Python-dotenv where library loads .env file at startup, injects them into environment variables and rest of the code is configured to use environment variables. This behavior could even be environment variable controlled and should not error if no .env file is present.
Re:The Twelve-Factor App by bunderbunder on Friday October 13, 2023 @09:37AM (#37870461)
The devil's in the details.

There's an enormous difference between "I'm going to use a dev-friendly way to manage and swap out all the different configurations that I might want to plug into the app while I'm testing it, but still plug them in using the same mechanism", which is basically what you get with dotenv files, and, "I'm going to configure with environment variables in production and JSON files in development," which is another thing I often see people doing.

Re:The Twelve-Factor App by scooble on Thursday October 12, 2023 @03:51PM (#37862297)
I've read a bunch of tutorials promoting env vars to avoid secrets being accidentally checked into git. Step 1 is usually to create a .env file and add it to your gitignore.
Re:The Twelve-Factor App by AtlasBarfed on Thursday October 12, 2023 @09:43PM (#37865553)
... and if you setup a git project and forget the gitignore

... your secrets get checked into git.

Re:The Twelve-Factor App by rbanffy on Thursday October 12, 2023 @01:31PM (#37860208)
"Store config in the environment" does not necessarily mean configs are in environment variables - it only means configuration comes from the hosting environment, not the application itself - you are not adding a "settings.json" file to your machine before starting the app.

This way, the same source deployed in, i.e. your AKS cluster in Azure EU north will take the configuration you set for that cluster while the one you run out of an Docker Swarm of RPi Zero's in an Ikea photo frame (I have one cluster like that, called Gibson), will take the configuration from that cluster.

Re:The Twelve-Factor App by Kwpolska on Thursday October 12, 2023 @01:32PM (#37860232)
The page https://12factor.net/config disagrees with you:

> The twelve-factor app stores config in environment variables (often shortened to env vars or env).

Re:The Twelve-Factor App by rbanffy on Thursday October 12, 2023 @01:35PM (#37860285)
I would assume that is the interpretation back in 2011. While the mechanism changed, the principle still holds.
Re:The Twelve-Factor App by lucideer on Thursday October 12, 2023 @01:52PM (#37860489)
> or you have k8s configmaps [...] those things are all broadly fine; they keep the configuration state separate from the app deploy state

Why are they fine? This seems to be an argument grounded in "it's a newer norm therefore it's better" but I don't see the justification. I've never used Heroku but ConfigMaps are a bane to manage. Even as a general programming principle within application code, colocality is a well-known, long-discussed topic around improving maintainability. If you're not using monorepos, that's currently not a reasonable option with current orchestration conventions.

Even if you are using monorepos, you're highly likely to either get into writing & automating DSLs to feed into your configmaps or do weird things like using Jinja to do file includes in your mounts. That's all before you run into the etcd 1MB size limit & realise that actually this whole system is a hack.

TL;DR newer ain't intrinsically better

Re:The Twelve-Factor App by throwaway4good on Thursday October 12, 2023 @02:08PM (#37860723)
As far as I can tell this is the standard way of doing things also in a kubernetes setup: The application gets its configuration from the environment variables.

Then in the case of a kubernetes setup. The application is wrapped inside a mechanism that gets the configuration from some where else.

Re:The Twelve-Factor App by ljm on Thursday October 12, 2023 @02:17PM (#37860839)
Nobody calls it '12 factor' anymore but we still adhere to a generic set of principles as a result (since 12-factor predated docker and kubernetes in the mainstream).

- Logs as a stream: yep, just write your logs to STDOUT instead of a file. Let the orchestrator deal with reading and storing it.

- Configuration in the environment. Apps tend to pull config from different sources depending on the deploy - maybe a .env locally and a secret store in production.

- Port binding - your app listens on a port and you put nginx or whatever in front of it and set up a reverse proxy. K8S services and ingress do that.

I think the biggest criticism you can lay down on 12 Factor these days is that it's not actually written very well and assumes you know exactly what it is talking about.

Re:The Twelve-Factor App by talent_deprived on Thursday October 12, 2023 @03:23PM (#37861863)
> Port binding - your app listens on a port and you put nginx or whatever in front of it

Apache for my personal projects, in front of the docker containers.

Re:The Twelve-Factor App by morelisp on Thursday October 12, 2023 @03:41PM (#37862135)
It's written very well but the audience is server application programmers in 2011, not someone who has written a dozen services yet never seen a log rotator, "production mode", or an AF_UNIX socket in their whole career.
Re:The Twelve-Factor App by rbanffy on Thursday October 12, 2023 @04:45PM (#37862947)
> - Logs as a stream: yep, just write your logs to STDOUT instead of a file. Let the orchestrator deal with reading and storing it.

This is one that always feels odd to me: what happened to rsyslogd?

Re:The Twelve-Factor App by craigmcnamara on Thursday October 12, 2023 @05:01PM (#37863100)
Not the responsibility of the container. The host deals with those details.
Re:The Twelve-Factor App by rbanffy on Friday October 13, 2023 @05:34PM (#37875873)
Still, I haven't seen it in quite some time.
Re:The Twelve-Factor App by paulddraper on Thursday October 12, 2023 @06:42PM (#37864095)
*STDERR
Re:The Twelve-Factor App by me-vs-cat on Friday October 13, 2023 @06:47AM (#37869107)
The normal output of a service is a log, and should go to STDOUT. The service can separately output errors to STDERR.

The normal output of a non-service command (eg. grep) sometimes/often goes to STDOUT, which is why that command will write errors to STDERR -- even "info" messages that look like logging.

Re:The Twelve-Factor App by paulddraper on Friday October 13, 2023 @02:43PM (#37874019)
The normal output of a service is nothing.
Re:The Twelve-Factor App by zemo on Saturday October 14, 2023 @12:31PM (#37881853)
dunno if you haven't noticed but people haven't been writing self-daemonizing processes that disappear into the background silently for ::checks watch:: at least a decade now. The practice of writing self-daemonizing processes was always a wart, a reflection of how low our expectations are of the job-control expressivity of cli shells. Grab ten programmers who use bash/zsh every day and say "you have a program that runs in the foreground forever, launch it in the background and close your terminal" and see what they do. You'll find some mixture of nohup, launching it and putting it in the background and disowning it, putting it in a tmux session and then detaching from the session, or deciding they have to put it in a container just to get that behavior, or some other workaround to deal with the fact that launching a process into the background is an ergonomic challenge for a lot of people. The circa-2000 status quo actually had a drawback or two.