Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nevercase/k8s-controller-custom-resource

k8s-api & Redis-operator & Mysql-operator
https://github.com/nevercase/k8s-controller-custom-resource

dockerfile k8s k8s-api k8s-crd mysql-operator operator redis-operator

Last synced: 19 days ago
JSON representation

k8s-api & Redis-operator & Mysql-operator

Awesome Lists containing this project

README

        

# k8s-controller-custom-resource

## Features
- k8s-api: supports watching and listing default resources (such as Service, Pod, Configmap) and another custom resources definition
- redis-operator: including a simple master-slave mode which was main based on the resources of **k8s.StatefulSet** and **k8s.Service**
- mysql-operator: the same with the redis-operator

## Operators to do
- core/v1/interfaces would add the storage plugins(e.g. nfs) later for dynamically creating pv and pvc

## Api to do
- ingress controller

## RedisOperator

### clone git, build docker image and compile controller
```sh
$ git clone https://github.com/neverCase/k8s-controller-custom-resource.git
$ cd k8s-controller-custom-resource

# build image
$ make mysql
$ make redis

# compile controller
$ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o multiplexcrd cmd/multiplex/main.go
```

### define the resource of the `RedisOperator`
```sh
$ cat > redis-resource.yaml < example-redis.yaml < 6379/TCP 4m38s
service-redis-demo-slave ClusterIP 10.96.0.120 6379/TCP 4m38s
```

## MysqlOperator

The usage was the same with the RedisOperator.

## New custom-controller
```go
opt := k8sCoreV1.NewOption(&mysqlOperatorV1.MysqlOperator{},
controllerName,
OperatorKindName,
mysqlOperatorScheme.AddToScheme(scheme.Scheme),
clientSet,
fooInformer,
fooInformer.Informer(),
CompareResourceVersion,
Get,
Sync,
SyncStatus)
opts := k8sCoreV1.NewOptions()
if err := opts.Add(opt); err != nil {
klog.Fatal(err)
}
op := k8sCoreV1.NewKubernetesOperator(k8sClientSet, stopCh, controllerName, opts)
kc := k8sCoreV1.NewKubernetesController(op)
...
```