|
| 1 | +--- |
| 2 | +title: "Development Guide" |
| 3 | +weight: 2 |
| 4 | +linkTitle: "Development Guide" |
| 5 | +description: > |
| 6 | + Development guide for MongoDB Operator |
| 7 | +--- |
| 8 | + |
| 9 | +## Pre-requisites |
| 10 | + |
| 11 | +**Access to Kubernetes cluster** |
| 12 | + |
| 13 | +First, you will need access to a Kubernetes cluster. The easiest way to start is minikube. |
| 14 | + |
| 15 | +- [Virtualbox](https://www.virtualbox.org/wiki/Downloads) |
| 16 | +- [Minikube](https://kubernetes.io/docs/setup/minikube/) |
| 17 | +- [Kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) |
| 18 | + |
| 19 | +**Tools to build an Operator** |
| 20 | + |
| 21 | +Apart from kubernetes cluster, there are some tools which are needed to build and test the MongoDB Operator. |
| 22 | + |
| 23 | +- [Git](https://git-scm.com/downloads) |
| 24 | +- [Go](https://golang.org/dl/) |
| 25 | +- [Docker](https://docs.docker.com/install/) |
| 26 | +- [Operator SDK](https://github.com/operator-framework/operator-sdk/blob/v0.8.1/doc/user/install-operator-sdk.md) |
| 27 | +- [Make](https://www.gnu.org/software/make/manual/make.html) |
| 28 | + |
| 29 | +## Building Operator |
| 30 | + |
| 31 | +To build the operator on local system, we can use `make` command. |
| 32 | + |
| 33 | +```shell |
| 34 | +$ make manager |
| 35 | +... |
| 36 | +go build -o bin/manager main.go |
| 37 | +``` |
| 38 | + |
| 39 | +MongoDB operator gets packaged as a container image for running on the Kubernetes cluster. |
| 40 | + |
| 41 | +```shell |
| 42 | +$ make docker-build |
| 43 | +``` |
| 44 | + |
| 45 | +If you want to play it on Kubernetes. You can use a minikube. |
| 46 | + |
| 47 | +```shell |
| 48 | +$ minikube start --vm-driver virtualbox |
| 49 | +... |
| 50 | +😄 minikube v1.0.1 on linux (amd64) |
| 51 | +🤹 Downloading Kubernetes v1.14.1 images in the background ... |
| 52 | +🔥 Creating kvm2 VM (CPUs=2, Memory=2048MB, Disk=20000MB) ... |
| 53 | +📶 "minikube" IP address is 192.168.39.240 |
| 54 | +🐳 Configuring Docker as the container runtime ... |
| 55 | +🐳 Version of container runtime is 18.06.3-ce |
| 56 | +⌛ Waiting for image downloads to complete ... |
| 57 | +✨ Preparing Kubernetes environment ... |
| 58 | +🚜 Pulling images required by Kubernetes v1.14.1 ... |
| 59 | +🚀 Launching Kubernetes v1.14.1 using kubeadm ... |
| 60 | +⌛ Waiting for pods: apiserver proxy etcd scheduler controller dns |
| 61 | +🔑 Configuring cluster permissions ... |
| 62 | +🤔 Verifying component health ..... |
| 63 | +💗 kubectl is now configured to use "minikube" |
| 64 | +🏄 Done! Thank you for using minikube! |
| 65 | +``` |
| 66 | + |
| 67 | +```shell |
| 68 | +$ make test |
| 69 | +``` |
0 commit comments