-
Notifications
You must be signed in to change notification settings - Fork 0
Populate by files
Le Gall, Benoit edited this page Oct 31, 2025
·
7 revisions
-
consul.files.root-path: path to root directory (Required) -
consul.files.target: subdirectory used to override root configurations (Required) -
consul.files.format: (YAML | JSON | PROPERTIES) Supported format of the files (Required)
You need to have:
- all base configurations in the root of the configurations directory
- 1 subdirectory by environment, with only the configurations to override with environment related values (usually url, table name, ... all those values that change between environments)
Given we have a very classic platform with
- orders-services => need configurations to postgres and rabbitmq
- products-services => need configurations to couchbase and rabbitmq
- users-services => need configurations to postgres
you will have this structure:
.
└── path_to_configuration
├── dev
│ ├── application,couchbase.yaml
│ ├── application,postgres.yaml
│ ├── application,rabbitmq.yaml
│ └── orders-services.yaml
├── stg
│ ├── application,couchbase.yaml
│ ├── application,postgres.yaml
│ ├── application,rabbitmq.yaml
│ └── products-services.yaml
├── qa
│ ├── application,couchbase.yaml
│ ├── application,postgres.yaml
│ └── application,rabbitmq.yaml
├── prod
│ ├── application,couchbase.yaml
│ ├── application,postgres.yaml
│ ├── application,rabbitmq.yaml
│ └── users-services.yaml
├── application.yaml
├── application,couchbase.yaml
├── application,postgres.yaml
├── application,rabbitmq.yaml
├── orders-services.yaml
├── products-services.yaml
└── users-services.yaml
You will need to define the postgres, rabbitmq and couchbase as environment (Micronaut) or profile (Spring)
public class MyApplication {
public static void main(final String[] args) {
Micronaut.build(args)
.mainClass(MyApplication.class)
.environments("rabbitmq", "postgres")
.start();
}
}Note: current {version} is 1.2.2
java -jar {path_to_archive}/consul-populate-cli-{version}.jar \
--consul.host=localhost \
--consul.port=8500 \
--consul.kv.prefix=config/frog/my_app \
--consul.kv.version=1.2.3 \
--consul.files.format=YAML \
--consul.files.target=dev \
--consul.files.root-path={path_to_configuration}services:
consul-populate:
image: frogdevelopment/consul-populate:{version}
environment:
CONSUL_HOST: consul
CONSUL_PORT: 8500
CONSUL_KV_PREFIX: config/frog/my_app
CONSUL_KV_VERSION: 1.2.3
CONSUL_FILES_FORMAT: YAML
CONSUL_FILES_TARGET: dev
CONSUL_FILES_ROOT_PATH: /configurations
volumes:
- {path_to_configuration}:/configurations:roSee full docker-compose file in consul-populate/consul-populate-cli/docker-compose.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: consul-populate
spec:
template:
spec:
automountServiceAccountToken: false
containers:
- name: consul-populate
image: frogdevelopment/consul-populate:{version}
args:
- "--consul.host=consul-svc"
- "--consul.port=8500"
- "--consul.kv.prefix=frog"
- "--consul.kv.version=1.2.3"
- "--consul.files.format=YAML"
- "--consul.files.target=dev"
- "--consul.files.root-path=/configurations"
imagePullPolicy: Always
volumeMounts:
- mountPath: /configurations
name: configurations
restartPolicy: Never
volumes:
- name: configurations
persistentVolumeClaim:
claimName: configurations-pvc
readOnly: true
backoffLimit: 3See full manifest file in consul-populate/consul-populate-cli/minikube-manifest.yaml