You are looking at the documentation of a prior release. To read the documentation of the latest release, please visit here.

Development Guide

This document is intended to be the canonical source of truth for things like supported toolchain versions for building KubeDB. If you find a requirement that this doc does not capture, please submit an issue on github.

This document is intended to be relative to the branch in which it is found. It is guaranteed that requirements will change over time for the development branch, but release branches of KubeDB should not change.

Build KubeDB

Some of the KubeDB development helper scripts rely on a fairly up-to-date GNU tools environment, so most recent Linux distros should work just fine out-of-the-box.

Setup GO

KubeDB is written in Google’s GO programming language. Currently, KubeDB is developed and tested on go 1.8.3. If you haven’t set up a GO development environment, please follow these instructions to install GO.

Code Organization

KubeDB codebase is across various repositories under github.com/kubedb organization. There are 5 categories of git repositories:

RepositoryDescription
https://github.com/kubedb/apimachineryContains api types, clientset and KubeDB framework interfaces.
https://github.com/kubedb/xdbThis repository contains operator for db, eg, https://github.com/kubedb/postgres
https://github.com/kubedb/db_exporterThis repository contains Prometheus exporter for db, eg, https://github.com/kubedb/postgres_exporter .
https://github.com/kubedb/operatorThis repository contains the combined operator for all databases supported by KubeDB.
https://github.com/kubedb/cliThis repository contains CLI for KubeDB.

For each of these repositories, you can get source code and build code using the following steps:

Download Source

$ go get github.com/kubedb/operator
$ cd $(go env GOPATH)/src/github.com/kubedb/operator

Install Dev tools

To install various dev tools for KubeDB, run the following command:

$ ./hack/builddeps.sh

Build Binary

$ ./hack/make.py

Dependency management

For KubeDB original repositories, we use Glide to manage dependencies. Dependencies are already checked in the vendor folder. If you want to update/add dependencies, run:

$ glide slow

Build Docker images

For unified operator or db specific operators, we support building Docker images. To build and push your custom Docker image, follow the steps below. To release a new version of KubeDB, please follow the release guide.

# Build Docker image
$ ./hack/docker/operator/setup.sh; ./hack/docker/operator/setup.sh push

# Add docker tag for your repository
$ docker tag kubedb/operator:<tag> <image>:<tag>

# Push Image
$ docker push <image>:<tag>

# Example:
$ docker tag kubedb/operator:default aerokite/operator:default
$ docker push aerokite/operator:default

Run KubeDB in localhost

# clone kubedb-operator project
$ git clone https://github.com/kubedb/operator

# cd to operator project
$ cd $GOPATH/src/github.com/kubedb/operator

# deploy KubeDB resources and run KubeDB operator in localhost
$ ./hack/deploy/setup.sh --minikube --run

# deploy Kubedb Catalog, *KubeDB operator will run in a message loop, you should not stop it immediately, To install Kubedb Catalog you can just start another terminal.* 
$ ./hack/deploy/install-catalog.sh

After deploy KubeDB successfully, you can debug it using any IDE you like, You should start your KubeDB operator using the same param in ./hack/deploy/setup.sh.

Debug using atom

Generate CLI Reference Docs

$ cd ~/go/src/github.com/kubedb/cli
$ ./hack/gendocs/make.sh