📚 / Documentation / Getting Started


Overview

klifter is an Ansible playbook used to deploy a complete Kubernetes infrastructure from a Git repository.

It supports:

  • executing Bash scripts
  • building Docker images with docker or kbld
  • applying Kubernetes manifests (through kubectl apply or with kustomize)
  • deploying Kubernetes applications with Helm or kapp
  • generating Kubernetes applications with ytt or helm template

Installation

klifter is distributed as a Docker image but you can also install it manually from sources.

With Docker

The Docker image is hosted on Github Container Registry:

$ docker pull ghcr.io/datapio/klifter:latest

From sources

You will need Python 3.9 or higher and Poetry:

$ git clone https://github.com/datapio/klifter
$ cd klifter
$ poetry install

NB: Only Debian is supported so far.

Usage

klifter takes as input a source, which can be one of the following:

  • a Git repository
  • a local directory

In the future, we may support the following sources:

  • a data-only Docker container
  • a TAR/ZIP/… archive
  • a remote archive (via HTTP/HTTPS)

Sample project

vars.yml:

---
packages:
  - name: foobar
    kind: bundle

bundles/foobar/10-namespace.yml:

---
apiVersion: v1
kind: Namespace
metadata:
  name: foobar

bundles/foobar/20-helloworld.yml:

---
apiVersion: batch/v1
kind: Job
metadata:
  name: helloworld
  namespace: foobar
spec:
  template:
    spec:
      containers:
        - name: hello
          image: alpine:latest
          command: ["/bin/sh", "-c", "echo world"]
      restartPolicy: Never
  backoffLimit: 4

Deploy

Assuming you have a working Kubernetes configuration on your host, you can run the Docker image with your local project:

$ docker run --rm -it \
      -v $HOME/.kube:/workspace/.kube \
      -v /path/to/sample/project:/data \
      -e K8S_STATE_SOURCE_KIND=local \
      ghcr.io/datapio/klifter:latest

Or from a Git repository:

$ docker run --rm -it \
      -v $HOME/.kube:/workspace/.kube \
      -e K8S_STATE_SOURCE_KIND=git \
      -e K8S_STATE_SOURCE_GIT_URL=https://github.com/example/example.git \
      -e K8S_STATE_SOURCE_GIT_REF=main \
      ghcr.io/datapio/klifter:latest

To run the playbook from sources (environment will be read from a .env file):

$ poetry run bash run-playbook.sh

NB: Running the playbook from sources will install the tools on your machine.

What’s next?

You can either read our tutorials, or dive into the tools reference.