Gitkube is a tool for building and deploying docker images on Kubernetes using git push.

After a simple initial setup, users can simply keep git push-ing their repos to build and deploy to Kubernetes automatically.

Gitkube is a young project; don’t forget to star the repo to show ❤️ and to keep up!

When should I use gitkube?

  1. Ideal for development where you can push your WIP branch to the cluster to test.
  2. Reference implementation for writing git-based automation on your server. Fork this repo and create your own CRD + controller + git remote hook that can do things on the Kubernetes cluster.


Getting started

Gitkube will run on any Kubernetes vendor/distribution AS IS. In case you find any difficulties in the setup, please comment on #33

Install gitkube

$ kubectl create -f

$ #expose gitkubed service
$ kubectl --namespace kube-system expose deployment gitkubed --type=LoadBalancer --name=gitkubed


Follow this example repo for a typical workflow of gitkube.

How it works

Gitkube has three components:

  1. Remote: Custom resource defined by a K8s CRD
  2. gitkube-controller: Controller that manages Remote objects and propogates changes to gitkubed
  3. gitkubed: Git host that builds docker image from repo and rolls out deployment

High level architecture



Local dev

User should have a git repo with source code and a Dockerfile. User should also create a base K8s deployment for the application.

Setting Remote

A Remote resource consists of 3 parts:

  1. authorizedKeys: List of ssh-keys for authorizing git push.
  2. registry: Details of docker registry where images are pushed post-build.
  3. deployments: Spec for building docker image and updating corresponding K8s deployment.

Here is a typical spec for a Remote:

kind: Remote
  name: sampleremote
  namespace: default

# Insert ssh-keys for allowing users to git push
  - "ssh-rsa your-ssh-public-key"

# Provide registry details for pushing and pulling image from/into the cluster 
    url: ""
    # dockercfg secret
        name: regsecret
        key: .dockercfg

# Define deployment rules
  - name: www                             # Name of K8s deployment which is updated on git push
    - name: www                           # Name of container in the deployment which is built during git push
      path: example/www                   # Location of source code in the git repo
      dockerfile: example/www/Dockerfile  # Location of Dockerfile for the source code

Deploying application

Once a Remote is created, it gets a git remote url which you can find in its status spec

$ kubectl get remote sampleremote -o yaml
  remoteUrl: ssh://[email protected]/~/git/default-sampleremote
  remoteUrlDesc: ""

Add the generated remoteUrl in git

$ git add remote sampleremote ssh://[email protected]/~/git/default-sampleremote

And finally, git push

$ git push sampleremote master


Gitkube is open to evolution. Some of the features to be added in future include:


Gitkube is an open source project licensed under Apache License 2.0

Contributions are welcome.


This project has come out of the work at Current maintainers @Tirumarai, @shahidh_k.