Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flyer103/minimalist-operator
Minimalist Operator Demo.
https://github.com/flyer103/minimalist-operator
Last synced: 2 months ago
JSON representation
Minimalist Operator Demo.
- Host: GitHub
- URL: https://github.com/flyer103/minimalist-operator
- Owner: flyer103
- License: apache-2.0
- Created: 2022-09-01T12:31:41.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-01T12:48:49.000Z (over 2 years ago)
- Last Synced: 2024-09-06T15:33:45.441Z (5 months ago)
- Language: Go
- Size: 78.1 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
The project is designed to implement a K8s Operator with as few tools as possible and understand the K8s Operator core logic.
# How to write an Operator
1. Write CRD and register CR with kube-apiserver: [crd.yaml](./yaml/crd.yaml)
2. Write resource definitions through code:![apis.png](./misc/apis.png)
3. Generate clients:
```
$ make build-resource
```
You may need to prepare the code generation tool by doing the following:
```shell
$ go get k8s.io/code-generator/cmd/defaulter-gen
$ go get k8s.io/code-generator/cmd/client-gen
$ go get k8s.io/code-generator/cmd/lister-gen
$ go get k8s.io/code-generator/cmd/informer-gen
$ go get k8s.io/code-generator/cmd/deepcopy-gen
```4. Write controller and add event handlers to informer.
# Usage
```shell
# Register CR.
$ kubectl apply -f yaml/crd.yaml# Build Operator.
$ make build-operator# Run operator outside of Cluster.
$ ./release/operator -kubeconfig ~/.kube/config
```