custom-database-controller

command module
v0.0.0-...-6f25e67 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2018 License: Apache-2.0 Imports: 26 Imported by: 0

README

custom-database-controller

Example respository for the blog post Kubernetes Custom Resources Grow Up in v1.10.

This repository implements a simple custom database controller which scales mysql deployments as per the Database custom resources.

This follows the same pattern as that of the Kuberentes sample-controller.

Installation

export GOPATH=~/go
go get github.com/nikhita/custom-database-controller

Prerequisites

Custom Resources support /status and /scale subresources as an alpha feature in v1.10. You will need a Kubernetes cluster with version of at least 1.10. Enable this feature using the CustomResourceSubresources feature gate on the kube-apiserver for v1.10. This feature is enabled by default for versions >v1.10.

--feature-gates=CustomResourceSubresources=true

Running

# assumes you have a working kubeconfig, not required if operating in-cluster
$ go run *.go -kubeconfig=$HOME/.kube/config

# create a CustomResourceDefinition
$ kubectl create -f artifacts/databases-crd.yaml

# create a custom resource of type Database
$ kubectl create -f artifacts/mysql-database.yaml

# check deployments created through the Databse custom resource
$ kubectl get deployments

You can scale the Database custom resource, which can automatically scale the mysql deployments as well.

$ kubectl get deployments
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
my-user 1         1         1            1           4s

# scaling
$ kubectl scale --replicas=3 databases/mysql
database.example.com "mysql" scaled

# after scaling
$ kubectl get deployments
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
my-user 3         3         3            3           1m

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
apis/example.com/v1
Package v1 is the v1 version of the API.
Package v1 is the v1 version of the API.
client/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/versioned/typed/example.com/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/example.com/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.

Jump to

Keyboard shortcuts

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