Quick revision
The short answer
I would keep the twelve-factor principle that one identical image runs everywhere, and deliver the environment's configuration through GitOps, as versioned and reviewed files applied to the cluster, because that fits audit needs without a runtime dependency. A central configuration server is worth it only where we truly need dynamic changes, and then it must not block startup. Secrets go to a dedicated secret store in every approach, and dynamic runtime changes stay limited to what is tested, because configuration changes cause many outages.
What to remember
In this answer, we compared environment-based configuration, central configuration servers and GitOps. Environment configuration keeps images identical and simple, config servers add dynamic changes and auditing at the price of a startup dependency and a larger blast radius, and GitOps gives versioned, reviewed configuration without a runtime dependency. Secrets belong in a dedicated secret store whichever we choose, and dynamic runtime changes should stay limited to what we have tested.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would keep the twelve-factor principle that one identical image runs everywhere, and deliver the environment's configuration through GitOps, as versioned and reviewed files applied to the cluster, because that fits audit needs without a runtime dependency. A central configuration server is worth it only where we truly need dynamic changes, and then it must not block startup. Secrets go to a dedicated secret store in every approach, and dynamic runtime changes stay limited to what is tested, because configuration changes cause many outages.
Why this question is asked
Large organisations often have all three approaches at once: older services reading environment variables, a Spring Cloud Config server introduced a few years ago, and newer teams putting everything in Git with Argo CD or Flux. Each choice was reasonable when it was made, but the mixture makes audits slow and incidents confusing. Interviewers ask this at the architect or director level because it has no single correct answer; they want to hear the trade-offs and the risks we would watch. In this answer, we will recap what each approach means, compare what they give and what they cost, look at secrets separately, and then make a recommendation with the risks to monitor.
1A Quick Recap of the Three Approaches
The twelve-factor app is a set of guidelines for building services that run well on cloud platforms. One of them says that configuration, meaning everything that differs between environments, belongs in the environment rather than in the code. In practice that means environment variables, and the main benefit is that the same image runs in test and in production.
A central configuration server, such as Spring Cloud Config, is a service that other services call at startup, and sometimes later, to fetch their properties, usually from a Git repository behind it. It adds dynamic refresh, a single place to look and an audit of reads. GitOps means the desired state of the cluster, including ConfigMaps and the references to Secrets, lives in Git, and a controller in the cluster applies whatever the main branch says. Configuration is then reviewed and versioned like code, and the cluster delivers it as environment variables or mounted files.
| Aspect | Env vars only | Config server | GitOps |
|---|---|---|---|
| Same image everywhere | yes | yes | yes |
| Review and history | only if the deploy files are in Git | yes, via its Git backend | yes, every change is a PR |
| Dynamic change at runtime | no, needs a restart | yes, with refresh | no, a new rollout |
| Runtime dependency | none | server must be up at startup | none at startup |
| Blast radius of a bad change | one deployment | every client that refreshes | one rollout, can canary |
| Structure for many values | flat, awkward | rich YAML per app | rich files per app |
2Environment Configuration: Simple and Portable
Environment-based configuration keeps images identical across environments, which is the most important property of all: what we tested is exactly what we run. It is also simple; every language and platform understands environment variables, and Spring Boot maps them to properties through relaxed binding.
Its weakness is scale and structure. Hundreds of flat variables are hard to review, nested structures and maps are awkward to express, and if the variables are typed into a deployment console rather than stored in Git, there is no history. So in a large organisation pure environment configuration usually needs something to manage it, which is where GitOps comes in.
3Central Configuration Servers: Power and Blast Radius
A config server gives us dynamic changes: we change a value in the backing repository, trigger a refresh, and services pick it up without a restart. It also gives one place to see every service's configuration and encryption of values at rest. These are real advantages for some use cases.
But it adds two risks. First, it becomes a dependency at startup: if the server is down, services that need it cannot start, and if that happens during a scale-up or a large deployment, the whole platform is stuck. Second, it increases the blast radius: a wrong value refreshed into every client changes every running instance at once, with no canary. We can reduce both, by marking the import optional, keeping a local fallback and refreshing in waves, but each mitigation adds work, and the server itself needs high availability.
4GitOps: Versioned, Reviewed, No Runtime Dependency
GitOps gives us most of what audit teams want: every change is a commit with an author and a reviewer, the history is complete, and the running state can be compared with Git at any time. Because the cluster delivers configuration as environment variables or mounted files, services have no extra dependency at startup; if the GitOps controller is down, running services and new pods keep working with what is already applied.
The trade-off is that a change needs a rollout, so it takes minutes rather than seconds. For most configuration that is a feature, not a bug: the rollout can go through a canary and be rolled back like code.
5Secrets Are a Separate Question
Whatever we choose for ordinary configuration, secrets need their own treatment. A password should not sit in a Git repository, even an encrypted one we forget to rotate, nor in a config server's backing store that many people can read. A dedicated secret store, such as Vault or a cloud secret manager, gives access control per secret, audit of every read, rotation and often short-lived credentials. The configuration in Git then contains only a reference, such as the path of the secret, and the platform or an operator delivers the value to the pod as a file.
6My Recommendation and the Risks I Would Watch
For a large organisation I would make GitOps with an identical image the default: configuration files per service and environment in Git, applied by the cluster, delivered as environment variables or config trees, with secrets referenced from a secret store. A config server, if we keep one, is for the few cases that truly need runtime change, and its imports are optional so it can never block startup.
The risks I would watch are these. Dynamic runtime changes grow quietly, so I keep an explicit list of values that may change live, each tested in both states. Drift appears when someone edits the cluster by hand, so the GitOps controller should report or revert differences. The config repository becomes a bottleneck if one central team must approve every change, so ownership is per service. And every approach depends on validation at startup, because configuration changes remain one of the biggest causes of outages.
- Is it a secret?password, key, tokenYesSecret store; reference in GitNoContinue
- Must it change without a rollout?kill switch, feature flagYesFlag service or config server, testedNoContinue
- Does it differ per environment?URLs, sizes, timeoutsYesGitOps file per environmentNoDefault in code or packaged file
3 steps in order. Play them, or step through them one at a time.
7Follow-up questions
Does GitOps break the twelve-factor rule that config lives in the environment?
No. The service still reads its configuration from the environment, as variables or mounted files, and the image is identical everywhere. GitOps only changes how that environment is defined: from hand-edited settings to versioned files in Git that a controller applies.
How would you migrate away from a config server?
Service by service. For each one we copy its effective properties into GitOps-managed ConfigMaps, import them with spring.config.import or a config tree, compare the env endpoint output before and after, and only then remove the config server import. The server is retired when the last client is gone.
When is a config server still the right choice?
When a group of services genuinely needs coordinated runtime changes without restarts, and the team can run the server with high availability. Even then, I would keep the import optional and limit which keys may be refreshed.
8Conclusion
In this answer, we compared environment-based configuration, central configuration servers and GitOps. Environment configuration keeps images identical and simple, config servers add dynamic changes and auditing at the price of a startup dependency and a larger blast radius, and GitOps gives versioned, reviewed configuration without a runtime dependency. Secrets belong in a dedicated secret store whichever we choose, and dynamic runtime changes should stay limited to what we have tested.
Open with
I would separate three questions: how configuration reaches the service, where it is defined, and where secrets live. For the first I keep the twelve-factor idea. One identical image runs everywhere and reads configuration from its environment, as variables or mounted files, so what we tested is what we run.
Then, if they want more
For where it is defined, my default for a large organisation is GitOps. Configuration files per service and environment live in Git, every change is a reviewed pull request, and Argo CD or Flux applies them. That gives the audit trail compliance teams want and adds no dependency at startup.
A central config server gives dynamic refresh and one place to look, but it becomes a hard dependency at startup and a big blast radius, because a bad refreshed value hits every instance at once. I would keep one only for the few cases that really need runtime change, and make its import optional so an outage cannot block deploys.
Secrets go into a dedicated store like Vault or a cloud secret manager in every model, with only references in Git. The risks I would watch are dynamic changes creeping beyond a small tested list, drift from hand edits, a central approval bottleneck, and missing startup validation, since config changes cause a large share of outages.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Boot reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Twelve-factor guidance says configuration belongs in the environment, while many...": https://scrivio-interview-library.netlify.app/spring-boot/externalized-configuration/04dbe36354/