Declarative Infrastructure

The difference between "infrastructure as code" and "declarative infrastructure"

Declarative infrastructure is "infrastructure as code" done right.

When you want to start writing infrastructure as code, you may be tempted to write a long shell script that creates infrastructure. That can be helpful, but at some point you need to update or delete the resources you previously created. A script for just a couple resources can look like this:

# this is pseudo code for imperative infrastructure, or infrastructure-as-script:

loadBalancer = getLoadBalancer('phoenix-app')
if loadBalancer.exists() {
    loadBalancer.backends = [IP1, IP2...]
    update(loadBalancer)
} else {
    loadBalancer = new loadBalancer(backend: IP1, IP2)
    create(loadBalancer
} 

old_lb = getLoadBalancer('ufcs-app')
if old_lb.exists() {
    delete(old_lb)
}

It only gets more complex from there. With declarative infrastructure, you have desired state, and actual state, and a tool such as Terraform or Kubernetes will determine the differences between desired state and actual state, and make the necessary changes. An example of a Terraform configuration looks like this:

# declarative infastructure - preferred
resource "aws_lb" "phoenix_app" {
    name = "phoenix-app"
    load_balancer_type = "application"
    # ...
}

As you make changes to the configuration (the desired state), you can run terraform plan, terraform apply, etc. to make it reality.

Terraform

The gold standard in declarative infrastructure, Terraform will manage your infrastructure across dozens of cloud and SaaS vendors through a provider plugin architecture. It does not abstract the differences between clouds, but it allows you to manage resources across clouds, and integrate them effectively.

Custom Terraform providers can be developed to integrate your existing infrastructure services with cloud resources.

Kubernetes

Kubernetes is the industry standard for managing containerized workloads. Through Kubernetes, you can manage containers, load balancers, DNS, and more. It provides API abstractions that are intended to provide a consistent experience between various cloud and datacenter platforms.

But Kube is not just for containers. Using CRDs and controllers, Kubernetes becomes an infrastructure-management platform with a declarative API, state management, drift correction, and more. We've built operators to provide an abstraction over existing capabilities, and to provide new purpose-built functionality.

We have extensive experience in developing software delivery platforms based on Kubernetes.