konfig

command module
v1.18.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2022 License: Unlicense Imports: 3 Imported by: 0

README

CircleCI Coverage Status

Konfig

Konfig is a configuration system for application configuration.

Background

Configuration is a very interesting topic. As we build more microservices we need to rethink how we get distributed systems to get their configuration. More info please read External Configuration Store pattern.

Environment Variables

Well we have environment variables so why do we need a whole service for this solved problem? That is a great question.

Here are some reasons:

  • They are global state.
  • The values cannot handle structures more complex than a string.
  • They can't be versioned.
  • They are hard to verify/validate for correctness.

Configuration as Code

We want to standardize configuration and check it into version control. We are firm believers of using GitOps. Take a look at Your configs suck? Try a real programming language. Some systems to have a look at:

Format

This system is geared around a very specific system that we use to build services. The content type of this config is YAML.

We recommend that you find a way to validate your configurations. We recommend looking at the following:

Providers

The configuration can be augmented with values that might be sensitive and need to be retrieved at runtime.

Environment Variables

To retrieve an environment variables the value of the key in the config should be env:VARIABLE, ex: env:GITHUB_URL.

Vault

You can also store values in vault for safe keeping. To retrieve the value of the key in the config should be vault:secret/data/key, ex: vault:secret/data/transport/http/user_agent.

Server

The server is defined by the following proto contract. So each version of the service will have a new contract.

To configure we just need the have the following configuration:

server:
  v1:
    source:
      type: git or folder (see below)
Source

This system allows you to store your configuration from various sources. Though we highly recommend that you follow configuration as code.

Git

Distributed version control is awesome and we believe should be used when managing configuration.

To configure we just need the have the following configuration:

source:
    type: git
    git:
        url: https://github.com/alexfalkowski/app-config (the configuration repo)
        dir: tmp/app-config (where to clone the repo to)
        token: a GitHub token or can be set in KONFIG_GIT_TOKEN env variable

We expect the repo to have the following conventions:

  • Each application name is at the root of the repository.
  • Under the application we have the environments (staging, production, etc).
  • Under each environment we have the configuration that follows command.config.yml for all clusters or a file under a specific cluster. Where command should follow the commands that your service has. Like server, worker, etc.
  • Versions are tracked by having the name of the service and the version. So a tag would would look like test/v1.5.0.

Take a look at app-config) as an example.

Folder

This is mainly used for testing or if you want to quickly run it. If you have a secure way to mount these configs, then by all means go for it.

To configure we just need the have the following configuration:

source:
    type: folder
    folder:
        dir: .config (the folder where the configurations can be found)

We expect that the folders to have the following conventions:

  • Each application name is at the root of the folder.
  • Each version is under the application and is in the format of v1.5.0
  • Under the version we have the environments (staging, production, etc).
  • Under each environment we have the configuration that follows command.config.yml for all clusters or a file under a specific cluster. Where command should follow the commands that your service has. Like server, worker, etc.

Client

The client is used to get the config that is defined in the config. These values reflect how the config is stored in the above sources.

To configure we just need the have the following configuration:

client:
  host: localhost:9090
  timeout: 5s
  application: test
  version: v1.5.0
  environment: staging
  cluster: '*'
  command: server

The client writes the config to the location specified by APP_CONFIG_FILE environment variable.

Health

The system defines a way to monitor all of it's dependencies.

To configure we just need the have the following configuration:

health:
  duration: 1s (how often to check)
  timeout: 1s (when we should timeout the check)

Deployment

Since we are advocating building microservices, you would normally use a container orchestration system. Here is what we recommend when using this system:

Other Systems

We love discovering systems that inspire us to make better systems. Below is a list of such systems:

Development

If you would like to contribute, here is how you can get started.

Structure

The project follows the structure in golang-standards/project-layout.

Dependencies

Please make sure that you have the following installed:

Setup

The get yourself setup, please run the following:

make setup
Binaries

To make sure everything compiles for the app, please run the following:

make build-test
Tests

To be able to test things locally you have to setup the environment.

Starting

Please run:

make start
Stopping

Please run:

make stop
Features

To run all the features, please run the following:

make features
Changes

To see what has changed, please have a look at CHANGELOG.md

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL