Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nikhita/custom-database-controller
https://github.com/nikhita/custom-database-controller
Last synced: 18 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/nikhita/custom-database-controller
- Owner: nikhita
- License: apache-2.0
- Created: 2018-04-06T14:27:22.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-14T19:09:52.000Z (about 6 years ago)
- Last Synced: 2024-10-12T12:37:52.649Z (about 1 month ago)
- Language: Go
- Size: 3.89 MB
- Stars: 22
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# custom-database-controller
Example respository for the blog post [
Kubernetes Custom Resources Grow Up in v1.10](https://blog.openshift.com/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](https://github.com/kubernetes/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](https://kubernetes.io/docs/tasks/access-kubernetes-api/extend-api-custom-resource-definitions/#subresources) 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](https://kubernetes.io/docs/admin/kube-apiserver) for v1.10.
This feature is enabled by default for versions >v1.10.```sh
--feature-gates=CustomResourceSubresources=true
```## Running
```sh
# 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.
```sh
$ 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
```