https://github.com/coryodaniel/hello_operator
A greeting-server operator created with Bonny
https://github.com/coryodaniel/hello_operator
Last synced: about 1 year ago
JSON representation
A greeting-server operator created with Bonny
- Host: GitHub
- URL: https://github.com/coryodaniel/hello_operator
- Owner: coryodaniel
- License: mit
- Created: 2018-12-24T06:39:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-12T23:45:08.000Z (over 6 years ago)
- Last Synced: 2025-03-24T05:34:45.318Z (about 1 year ago)
- Language: Elixir
- Homepage:
- Size: 21.5 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HelloOperator
Hello world operator created with Bonny.
[Bonny](https://github.com/coryodaniel/bonny) is a Kubernetes Operator SDK written in Elixir.
[HelloOperator Docker Image](https://quay.io/coryodaniel/hello_operator)
This [operator](./manifest.yaml) contains all the resources necessary to define an operator (CRDs, RBAC, ServiceAccount, and Deployment). The operator itself creates a simple Deployment running the [greeting-server](https://github.com/coryodaniel/greeting-server) and an HTTP Service.
The code for generating the lifecycle of a `Greeting` Deployment/Service is [here](./lib/hello_operator/controllers/v1/greeting.ex).
## Usage
*Deploying the operator outside a cluster (development):*
```shell
mix deps.get
mix compile
# Deploy to kubernetes
mix bonny.gen.manifest
kubectl apply -f ./manifest.yaml
iex -S mix
```
*Deploying the operator inside a cluster (production):*
```shell
mix deps.get
mix compile
# Build docker image
mix bonny.gen.dockerfile
export BONNY_IMAGE=YOUR_IMAGE_NAME_HERE
docker build -t ${BONNY_IMAGE} .
docker push ${BONNY_IMAGE}:latest
# Optionally, skip building the docker image and play with the operator
# export BONNY_IMAGE=quay.io/coryodaniel/hello_operator
# Deploy to kubernetes
mix bonny.gen.manifest --image ${BONNY_IMAGE}
kubectl apply -f ./manifest.yaml
```
*Create two `Greeting` resources:*
Create the "Hello" and "Hola" Greeting services:
```shell
kubectl apply -f ./greetings.yaml
```
Inspect the greeting resources:
```shell
# you should see two greetings
kubectl get greetings
kubectl describe greetings/hello-server
kubectl describe greetings/hola-server
```
You should be able to browse to NodePort Service of each:
```shell
kubectl get svc/hello-server
kubectl get svc/hola-server
```
* http://HELLO_SERVICE_NODE_PORT/greeting/Chauncy - Hello, Chauncy
* http://HOLA_SERVICE_NODE_PORT/greeting/Chauncy - Hola, Chauncy
## Kubernetes Client
This project uses a very trivial [kubernetes client](./lib/k8s/client.ex). It is not recommended for production.