confd
Manage local application configuration files using templates and data from etcd or consul
Top Related Projects
Distributed reliable key-value store for the most critical data of a distributed system
Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.
Production-Grade Container Scheduling and Management
Quick Overview
confd is a lightweight configuration management tool designed to manage local application configuration files using templates and data from etcd or consul. It allows for dynamic updates of configuration files based on changes in key-value stores, making it ideal for distributed systems and microservices architectures.
Pros
- Simplifies configuration management in distributed environments
- Supports multiple backends (etcd, consul, environment variables, etc.)
- Lightweight and easy to integrate into existing systems
- Allows for dynamic updates without service restarts
Cons
- Limited to specific use cases (mainly configuration file management)
- Requires additional infrastructure (key-value store) for full functionality
- Learning curve for template syntax and backend integration
- Not actively maintained (last commit was in 2020)
Code Examples
- Basic template example:
[template]
src = "nginx.conf.tmpl"
dest = "/etc/nginx/nginx.conf"
keys = [
"/nginx",
]
This example defines a template configuration for confd, specifying the source template, destination file, and keys to watch in the backend.
- Template syntax example:
{{range gets "/services/*"}}
server {{.Value}};
{{end}}
This template iterates over all keys under "/services/" and generates a "server" line for each value.
- Command-line usage:
confd -onetime -backend env
This command runs confd once using environment variables as the backend.
Getting Started
- Install confd:
wget https://github.com/kelseyhightower/confd/releases/download/v0.16.0/confd-0.16.0-linux-amd64
mv confd-0.16.0-linux-amd64 /usr/local/bin/confd
chmod +x /usr/local/bin/confd
- Create a configuration file (e.g.,
/etc/confd/conf.d/myapp.toml
):
[template]
src = "myapp.conf.tmpl"
dest = "/etc/myapp/myapp.conf"
keys = [
"/myapp/database",
"/myapp/port"
]
- Create a template file (e.g.,
/etc/confd/templates/myapp.conf.tmpl
):
database_url = {{getv "/myapp/database"}}
port = {{getv "/myapp/port"}}
- Run confd:
confd -backend etcd -node http://127.0.0.1:2379
This setup assumes you're using etcd as the backend. Adjust the backend and node URL as needed for your environment.
Competitor Comparisons
Distributed reliable key-value store for the most critical data of a distributed system
Pros of etcd
- Distributed key-value store with strong consistency and high availability
- Supports complex operations like atomic compare-and-swap and multi-key transactions
- Built-in support for cluster management and leader election
Cons of etcd
- More complex to set up and manage compared to confd
- Requires additional infrastructure and resources to run effectively
- Steeper learning curve for developers and operators
Code Comparison
etcd example:
cli, _ := clientv3.New(clientv3.Config{Endpoints: []string{"localhost:2379"}})
defer cli.Close()
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
_, err := cli.Put(ctx, "key", "value")
cancel()
if err != nil {
log.Fatal(err)
}
confd example:
[template]
src = "nginx.conf.tmpl"
dest = "/etc/nginx/nginx.conf"
keys = [
"/nginx",
]
etcd is a distributed key-value store, while confd is a configuration management tool. etcd provides a robust foundation for building distributed systems, offering features like strong consistency and high availability. However, it requires more setup and management compared to confd. confd, on the other hand, is simpler to use and focuses on generating configuration files from various backends, including etcd. The code examples show the difference in complexity: etcd requires programmatic interaction, while confd uses a declarative configuration approach.
Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
Pros of Consul
- Full-featured service mesh with service discovery, health checking, and key-value store
- Supports multiple data centers and cloud environments out of the box
- Provides a robust API and CLI for easy integration and management
Cons of Consul
- More complex setup and configuration compared to confd
- Higher resource usage due to its comprehensive feature set
- Steeper learning curve for teams new to service mesh concepts
Code Comparison
confd example:
[template]
src = "nginx.conf.tmpl"
dest = "/etc/nginx/nginx.conf"
keys = [
"/nginx/worker_processes",
"/nginx/worker_connections"
]
Consul example:
service {
name = "web"
port = 80
check {
http = "http://localhost/health"
interval = "10s"
}
}
Summary
Consul offers a more comprehensive solution for service discovery and configuration management, while confd focuses primarily on configuration templating. Consul is better suited for larger, distributed systems, whereas confd is simpler and more lightweight, making it ideal for smaller deployments or specific configuration management tasks.
Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.
Pros of Ansible
- More comprehensive configuration management and automation capabilities
- Larger community and ecosystem with extensive modules and plugins
- Agentless architecture, requiring only SSH access to managed nodes
Cons of Ansible
- Steeper learning curve due to its broader feature set
- Potentially slower execution for simple tasks compared to confd
- Requires Python on managed nodes
Code Comparison
Ansible playbook example:
- name: Configure web server
hosts: webservers
tasks:
- name: Install nginx
apt:
name: nginx
state: present
- name: Start nginx service
service:
name: nginx
state: started
confd template example:
[template]
src = "nginx.conf.tmpl"
dest = "/etc/nginx/nginx.conf"
keys = [
"/nginx/worker_processes",
"/nginx/worker_connections"
]
reload_cmd = "service nginx reload"
Ansible offers a more declarative approach with built-in modules for various tasks, while confd focuses on templating and managing configuration files based on key-value stores. Ansible's playbooks can handle complex multi-step deployments, whereas confd is more specialized for dynamic configuration management.
Production-Grade Container Scheduling and Management
Pros of Kubernetes
- Comprehensive container orchestration platform with advanced features like auto-scaling, load balancing, and self-healing
- Large, active community with extensive documentation and support
- Widely adopted in enterprise environments for managing complex microservices architectures
Cons of Kubernetes
- Steeper learning curve and more complex setup compared to confd
- Requires more resources to run and maintain, potentially overkill for simpler deployments
- Can be challenging to debug and troubleshoot due to its distributed nature
Code Comparison
Kubernetes deployment example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
confd configuration example:
[template]
src = "nginx.conf.tmpl"
dest = "/etc/nginx/nginx.conf"
keys = [
"/nginx",
]
reload_cmd = "/usr/sbin/service nginx reload"
While Kubernetes offers a full-featured container orchestration platform, confd focuses on lightweight configuration management. Kubernetes is better suited for complex, distributed applications, while confd is ideal for simpler configuration tasks and can be easily integrated into existing systems.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
confd
confd
is a lightweight configuration management tool focused on:
- keeping local configuration files up-to-date using data stored in etcd, consul, dynamodb, redis, vault, zookeeper, aws ssm parameter store or env vars and processing template resources.
- reloading applications to pick up new config file changes
Project Status
confd
is currently being cleaned up to build on later versions of Go and moving to adopt native support for Go modules. As part of this work the following major changes are being made:
- The
etcd
andetcdv3
backend are going to be merged. etcd v2 has been deprecated and both backend will now use etcdv3 client libraries. - The
cget
,cgets
,cgetv
, andcgetvs
templates function have been removed due to an unmaintained dependencygithub.com/xordataexchange/crypt/encoding/secconf
. We need to rethink encryption in the core project and rely only on the standard library going forward. In the meanwhile these template function will not work and if support is required you will need to stick with an older version of confd.
Community
- IRC:
#confd
on Freenode - Mailing list: Google Groups
- Website: www.confd.io
Building
Go 1.10 is required to build confd, which uses the new vendor directory.
$ mkdir -p $GOPATH/src/github.com/kelseyhightower
$ git clone https://github.com/kelseyhightower/confd.git $GOPATH/src/github.com/kelseyhightower/confd
$ cd $GOPATH/src/github.com/kelseyhightower/confd
$ make
You should now have confd in your bin/
directory:
$ ls bin/
confd
Getting Started
Before we begin be sure to download and install confd.
Next steps
Check out the docs directory for more docs.
Top Related Projects
Distributed reliable key-value store for the most critical data of a distributed system
Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.
Production-Grade Container Scheduling and Management
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot