https://github.com/springerpe/cf-confd-buildpack
Application configuration files using templates and data from etcd, consul or environment vars
https://github.com/springerpe/cf-confd-buildpack
Last synced: 6 months ago
JSON representation
Application configuration files using templates and data from etcd, consul or environment vars
- Host: GitHub
- URL: https://github.com/springerpe/cf-confd-buildpack
- Owner: SpringerPE
- License: mit
- Created: 2019-04-24T14:34:24.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-30T10:18:17.000Z (about 7 years ago)
- Last Synced: 2025-01-14T04:44:37.716Z (over 1 year ago)
- Language: Shell
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cf-confd-buildpack
Cloudfoundry buildpack to manage application configuration files using templates
and data from etcd, consul, redis, vault, dns, environment variables
The idea is run [confd](https://github.com/kelseyhightower/confd) as pre-start
task with some template files. The templates will be rendered using the variables
provided by the backend (by default from environment vars) before the application
starts, when application is launched it gets the proper configuration.
## Using it
https://github.com/kelseyhightower/confd/blob/master/docs/quick-start-guide.md
First of all, **this buildpack has no extra requirements at all, it is an intermediate
buildpack which is only triggered if if finds a `confd` folder** you can create app folder,
put a `manifest.yml` like this:
```manifest.yml
---
applications:
- name: grafana
memory: 512M
instances: 1
stack: cflinuxfs3
random-route: true
buildpacks:
- https://github.com/SpringerPE/cf-confd-buildpack.git
- https://github.com/SpringerPE/cf-grafana-buildpack.git
env:
PROMETHEUS_USER: "hola"
PROMETHEUS_PASSWORD: "adios"
PROMETHEUS_URL: "http://hola.com"
...
```
In the app root folder, create a `confd` directory with two sub-folders,
one for the templates definition in `templates` folder and another
`conf.d` folder for the actions of how to render those templates.
Example:
```
confd
├── conf.d
│ └── prometheus.toml
├── Readme.md
└── templates
└── prometheus.yml.template
```
`prometheus.toml`:
```
[template]
src = "prometheus.yml.template"
dest = "/home/vcap/app/datasources/prometheus.yml"
keys = [
"/prometheus/password",
"/prometheus/user",
"/prometheus/url",
]
```
`prometheus.yml.template`:
```
# config file version
apiVersion: 1
# list of datasources that should be deleted from the database
deleteDatasources:
# list of datasources to insert/update depending
# what's available in the database
datasources:
- name: Prometheus
type: prometheus
access: proxy
orgId: 1
url: "{{getv "/prometheus/url"}}"
{{if exists "/prometheus/user"}}
basicAuth: true
basicAuthUser: "{{getv "/prometheus/user"}}"
basicAuthPassword: "{{getv "/prometheus/password"}}"
{{else}}
basicAuth: false
{{end}}
withCredentials: false
isDefault: false
editable: false
```
and run `cf push`
## Settings
Parameters are set via environment these environment variables:
```
CONFD_MODE="${CONFD_MODE:-onetime}"
CONFD_OPTS=${CONFD_OPTS:-"-backend env"}
CONFD_DIR="${CONFD_DIR:-$APP_ROOT/confd}"
```
# Documentation
https://github.com/kelseyhightower/confd/blob/master/docs/quick-start-guide.md
# Development
Implemented using bash scripts to make it easy to understand and change.
https://docs.cloudfoundry.org/buildpacks/understand-buildpacks.html
The builpack uses the `deps` and `cache` folders according the implementation purposes,
so, the first time the buildpack is used it will download all resources, next times
it will use the cached resources.
# Author
(c) Jose Riguera Lopez
Springernature Engineering Enablement
MIT License