/kkcd

A Kubernetes CD using CronJobs and kubecfg

Primary LanguagePythonApache License 2.0Apache-2.0

Kubernetes Continous Deployment via a CRD Controller

We want to keep all our k8s manifests under version control and have our git system be the only interaction point for our deployments in production.

People should just git push and review PR

Then the question comes, how do you deploy.

kkcd

kkcd is a simple CRD based controller written in Python, just for rapid prototyping. Once you create an App using a custom App object kind, the controller creates a CronJob with a gitRepo volume. The manifests repository is cloned by the git-repo volume and the CronJob runs kubecfg update. kubecfg is an improved kubectl apply.

That's it. See the original blog post

Every time you git push, kubecfg will apply the updates in a declarative way follwing the CronJob schedule.

The CRD is just a controller to use kubectl to manage your apps

Installation

kubectl create -f https://raw.githubusercontent.com/sebgoa/kkcd/master/kkcd.yaml

This will create a CRD and launch a controller

Write an App

apiVersion: bitnami.com/v1
kind: App
metadata:
  name: cookie
spec:
  repo: https://github.com/sebgoa/opencompose-jsonnet

We can extend the spec and add the CronJob schedule in there.

Create this app and watch the CronJob being created and soon your app will be running

kubectl create -f example.yaml
kubectl get apps
kubectl get cronjobs
kubectl get pods

Build

Using Bazel, build the controller image

bazel build :controller

push controller image to Docker hub

bazel run :push_controller

Note

Code is largely inspired by warm-image