An open API service indexing awesome lists of open source software.

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

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