Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/nevercase/k8s-controller-custom-resource
- Owner: neverCase
- Created: 2020-02-20T09:35:46.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-31T07:12:03.000Z (almost 3 years ago)
- Last Synced: 2024-11-19T03:13:24.294Z (about 1 month ago)
- Topics: dockerfile, k8s, k8s-api, k8s-crd, mysql-operator, operator, redis-operator
- Language: Go
- Homepage:
- Size: 1.96 MB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)
...
```