mongodbatlas-operator

module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2019 License: Apache-2.0

README

MongoDB Atlas Kubernetes Operator

Overview

A Kubernetes Operator for MongoDB Atlas with which you can manage your MongoDB Atlas projects and clusters from within Kubernetes such as you do with your containerized applications. It is built using the Operator Framework and Kubernetes Custom Resource Definitions (CRDs). This project was inspired from the MongoDB Atlas Terraform Provider with the goal to have Kubernetes as the single source for both (stateless) applications and MongoDB Atlas as the persistence layer. Furthermore, the Kubernetes operator ensures via Reconcile loops to have the desired state matching with the actual state and thus following the GitOps approach.

Scope

Currently it supports:

  • Create/Delete MongoDB Atlas Projects
  • Create/Delete MongoDB Atlas Clusters

Prerequisites

Getting Started

This example creates a MongoDB Atlas project and a cluster inside this project.

Init

First, create the MongoDB Atlas project CRD and some RBAC:

kubectl create -f deploy/service_account.yaml
kubectl create -f deploy/role.yaml
kubectl create -f deploy/role_binding.yaml
kubectl create -f deploy/crds/knappek_v1alpha1_mongodbatlasproject_crd.yaml
kubectl create -f deploy/crds/knappek_v1alpha1_mongodbatlascluster_crd.yaml

Create a Kubernetes secret containing the Private Key of the MongoDB Atlas Programmatic API Key

kubectl create secret generic example-monogdb-atlas-project \
    --from-literal=privateKey=xxxxxxxxx

Deploy the MongoDB Atlas Project Operator:

kubectl apply -f deploy/operator.yaml
Create a MongoDB Atlas Project

Adapt the publicKey and orgId in knappek_v1alpha1_mongodbatlasproject_cr.yaml accordingly and deploy your first MongoDB Atlas Project

kubectl apply -f deploy/crds/knappek_v1alpha1_mongodbatlasproject_cr.yaml
Create a Cluster

Adapt knappek_v1alpha1_mongodbatlascluster_cr.yaml accordingly and deploy your first MongoDB Atlas Cluster

kubectl apply -f deploy/crds/knappek_v1alpha1_mongodbatlascluster_cr.yaml

Cleanup

kubectl delete -f deploy/crds/knappek_v1alpha1_mongodbatlascluster_cr.yaml
kubectl delete -f deploy/crds/knappek_v1alpha1_mongodbatlasproject_cr.yaml
kubectl delete -f deploy/
kubectl delete -f deploy/crds/

Developers Build Guide

Create all CRDs that are managed by the operator

Run this once:

make init

Run Operator locally

export KUBECONFIG=/path/to/config
make dev

Create MongoDB Atlas Project

make deploy-project

Create MongoDB Atlas Cluster

make deploy-cluster

Delete MongoDB Atlas Project and Cluster

make delete-cluster
make delete-project

Run Operator Scorecard Tests

This test will be deprecated soon at be replaced by real system tests.

This will run the Operator Scorecard tests:

make test

Contributing

Read through the Contributing Guidelines and Code of Conduct.

Create new API

This example creates a new MongoDBAtlasCluster API:

make api KIND=MongoDBAtlasCluster
Create new Controller for the API

To create a controller for the recently created API, run:

make controller KIND=MongoDBAtlasCluster

Directories

Path Synopsis
cmd
manager command
pkg
apis/knappek/v1alpha1
Package v1alpha1 contains API Schema definitions for the knappek v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=knappek.com Package v1alpha1 contains API Schema definitions for the knappek v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=knappek.com
Package v1alpha1 contains API Schema definitions for the knappek v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=knappek.com Package v1alpha1 contains API Schema definitions for the knappek v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=knappek.com

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL