• Stars
    star
    140
  • Rank 261,473 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 5 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Experimental configuration generator inspired by JSX

Configula

Configula is a configuration generation language and processor. It's goal is to make the programmatic definition of declarative configuration easy and intuitive.

Inspiration

Configula is inspired by the JSX language in React that combines Javascript and HTML tags. Configula defines a similar pattern for Python and YAML (for now).

Consider this declaration:

my_object = foo: bar

It's neither Python, nor YAML. It combines the syntax of both. Instead of being a templating language like Jinja or others, or a Domain-Specific Language (DSL) like HCL, ARM templates or jsonnet, it combines the power of a full programming language with the ease of a declarative syntax like YAML.

Programmatic Example

Let's generate a Kubernetes namespace for a collection of users. Each namespace gets the user's name.

Here is what this looks like in Configula:

# Simple example of creating 3 Kubernetes namespaces

# Our users in need of namespaces
users = ['jim', 'sally', 'sue']

# The namespaces objects from YAML
namespaces = map(lambda user: <
        apiVersion: v1
        kind: Namespace
        metadata:
          # Use the !~ tag syntax to inline Python code
          name: !~ user
    >, users)

# Output
render(namespaces)

An alternate version that uses a for loop looks like this:

# Simple example of creating 3 Kubernetes namespaces
users = [ 'bob', 'sue', 'sally']

# This Python object is defined by inline YAML
namespace = <
  apiVersion: v1
  kind: Namespace
  metadata:
    # The !~ syntax enables python substitution, in this case a variable named `userName`
    name: !~ user
>

for user in users:
  namespace.render()
  print("---")

In either case you run this through the configula interpreter:

configula namespaces.py

and the output of this looks like:

apiVersion: v1
kind: Namespace
metadata:
  name: bob
---
apiVersion: v1
kind: Namespace
metadata:
  name: sue
---
apiVersion: v1
kind: Namespace
metadata:
  name: sally
---

Templating Example

The previous example is programming centric. If your configuration is mostly data and not much code, sometimes it makes sense to have a data-centric template. Such templates look more like YAML than Python.

Here is a simple example:

first = "brendan"
last = "burns"

apiVersion: v1
kind: Namespace
metadata:
  name: !~ first + ' ' + last

When you run this with configula namespace.yml it will output:

apiVersion: v1
kind: Namespace
metadata:
  name: brendan burns

Getting Started

The easiest way to get started is with the Docker image:

# Clone the repo
git clone https://github.com/brendandburns/configula
cd configula

# Run the namespaces example
docker run -v $PWD/examples:/examples brendanburns/configula \
  ./configula examples/namespaces.py

See this directory for more examples.

Read the docs

Installing configula

Getting Started

Download Configula for your platform

Integrating with Kubernetes

Configula can be used as a kubectl plugin.

To install the plugin run this command:

# assumes that configula is in /usr/local/bin/ change paths as needed.
ln -s /usr/local/bin/kubectl-configula /usr/local/bin/configula

Once that's done you can run:

kubectl configula create -f examples/namespaces.py

FAQ

What about other Javascript? Java? Go? .NET? Other Language?

We're open to other programming languages. What other languages would you want to see? Please file issues.

What about JSON? HCL? Other Data Language?

We're open to other data languages too! What other languages would you want to see? Please file issues.

More Repositories

1

designing-distributed-systems-labs

Labs for the Designing Distributed Systems book.
JavaScript
1,249
star
2

designing-distributed-systems

Sample code and configuration files from the Designing Distributed Systems book.
Python
904
star
3

gcp-live-k8s-visualizer

Source code for the Kubernetes visualizer used in the GCP Live Container Engine Demo
JavaScript
214
star
4

metaparticle

A new pattern for distributed system development
JavaScript
186
star
5

ksql

Query Kubernetes API objects using SQL.
JavaScript
129
star
6

kbp-sample

Sample app for Kubernetes best practices book from O'Reilly
JavaScript
86
star
7

kubesanity

KubeSanity a sanity checking framework for Kubernetes
Python
84
star
8

kubernetes-adduser

Simple tool for adding users to Kubernetes clusters
Shell
49
star
9

py-k4a

python libraries for the kinect for Azure
C
46
star
10

cl-k8s

Common Lisp Client for Kubernetes
Common Lisp
33
star
11

kubectl-select

A simple plugin for kubectl that enables the selection of resources.
Go
24
star
12

topz

A simple utility for running 'top' as a webserver.
Go
19
star
13

arduino-air-quality-exporter

An exporter from Arduino to prometheus for Air Quality metrics.
C++
15
star
14

k8s-playbooks

Some ansible playbooks for managing my k8s cluster(s)
Shell
14
star
15

dns-sync

A declarative synchronization tool for managing cloud DNS records.
Go
11
star
16

caddy-wasm

WebAssembly (WASM) extension for the caddy2 web server.
Go
9
star
17

typescript

A Typescript client for Kubernetes
TypeScript
9
star
18

dotnet-dockerfile

Simple .NET core library for parsing and generating Dockerfiles
C#
9
star
19

kubernetes-teams

Kubernetes teams app
JavaScript
9
star
20

acs-ignite-demos

Demos for my sessions at ignite.
Shell
7
star
21

devops-days-seattle-2019

Demos from DevOps Days 2019
Shell
7
star
22

aci-bridge-k8s

Experimental ACI Bridge for Kubernetes
TypeScript
6
star
23

wazero-http

Module implementation of the wasi-http spec for wasi-go
Go
4
star
24

dev-wasm

[moved, see https://github.com/dev-wasm] Giant docker image to make wasm building easy.
Dockerfile
3
star
25

eraser

A simple daemon for ensuring that images are removed from a machine.
C#
3
star
26

air-quality-display

Arduino app for displaying air quality
C++
3
star
27

arc-prometheus

arc-prometheus
3
star
28

admission-control-sdk

Javascript SDK for building Kubernetes admission controllers [work in progress]
JavaScript
3
star
29

dapr-demo

Shell
3
star
30

vs-docker

A visual studio plugin for interacting with the Docker API (Build, Run, Stop)
JavaScript
3
star
31

container-survey

Questions to ask in the monthly container survey.
2
star
32

oss-canada-demos

Shell
2
star
33

k8s-community-survey

Docker image for analyzing kubernetes community survey data
Jupyter Notebook
2
star
34

client-java

Java client library for Kubernetes
Java
2
star
35

mongo-k8s

MongoDB configuration for Kubernetes
2
star
36

simple-node

JavaScript
1
star
37

mongoose-api

JavaScript
1
star
38

cloud-primitives

Cloud primitives for cloudy cloud
TypeScript
1
star
39

js-sdk

Actions SDK for Javascript
JavaScript
1
star
40

cri-base

A simple base application for implementing Kubernetes Container Runtime Interface Servers
Go
1
star
41

micropython-ota

Python
1
star
42

webinar

Shell
1
star
43

velocity-demos

HTML
1
star
44

drawing

TypeScript
1
star
45

acs-build-demos

Demos for the ACS build session
Shell
1
star
46

wasi-http-examples

Examples of using the WASI HTTP API in WebAssembly
1
star
47

wasi-http-ts

Experimental HTTP client for typescript and WebAssembly
TypeScript
1
star
48

hostname-server

Simple server that responds with path and hostname.
JavaScript
1
star
49

dev-wasm-dapr

TypeScript
1
star
50

azure-cloud-shell

TypeScript
1
star
51

ghc-feature

A DevContainer feature that installs the Glasgow Haskell Compiler
Shell
1
star
52

rabbitmq-arc

RabbitMQ Configuration for Azure Arc
1
star