You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-25Lines changed: 30 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,33 +7,44 @@ A rust kubernetes reference controller for a [`Document` resource](https://githu
7
7
8
8
The `Controller` object reconciles `Document` instances when changes to it are detected, writes to its `.status` object, creates associated events, and uses finalizers for guaranteed delete handling.
9
9
10
-
## Requirements
11
-
- A Kubernetes cluster / k3d instance
12
-
- The [CRD](yaml/crd.yaml)
13
-
- Opentelemetry collector (**optional**)
10
+
## Installation
14
11
15
-
### Cluster
16
-
As an example; get `k3d` then:
12
+
### CRD
13
+
Apply the CRD from [cached file](yaml/crd.yaml), or pipe it from `crdgen` to pickup schema changes:
17
14
18
15
```sh
19
-
k3d cluster create --registry-create --servers 1 --agents 1 main
20
-
k3d kubeconfig get --all >~/.kube/k3d
21
-
export KUBECONFIG="$HOME/.kube/k3d"
16
+
cargo run --bin crdgen | kubectl apply -f -
22
17
```
23
18
24
-
A default `k3d` setup is fastest for local dev due to its local registry.
19
+
### Controller
25
20
26
-
### CRD
27
-
Apply the CRD from [cached file](yaml/crd.yaml), or pipe it from `crdgen` (best if changing it):
21
+
Install the controller via `helm` by setting your preferred settings. For defaults:
Setup an opentelemetry collector in your cluster. [Tempo](https://github.com/grafana/helm-charts/tree/main/charts/tempo) / [opentelemetry-operator](https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-operator) / [grafana agent](https://github.com/grafana/helm-charts/tree/main/charts/agent-operator) should all work out of the box. If your collector does not support grpc otlp you need to change the exporter in [`main.rs`](./src/main.rs).
35
30
36
-
If you don't have a collector, you can build locally without the `telemetry` feature (`tilt up telemetry`), or pull images [without the `otel` tag](https://hub.docker.com/r/clux/controller/tags/).
31
+
Build and run with `telemetry` feature, or configure it via `helm`:
This requires an opentelemetry collector in your cluster. [Tempo](https://github.com/grafana/helm-charts/tree/main/charts/tempo) / [opentelemetry-operator](https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-operator) / [grafana agent](https://github.com/grafana/helm-charts/tree/main/charts/agent-operator) should all work out of the box. If your collector does not support grpc otlp you need to change the exporter in [`telemetry.rs`](./src/telemetry.rs).
38
+
39
+
Note that the [images are pushed either with or without the telemetry feature](https://hub.docker.com/r/clux/controller/tags/) depending on whether the tag includes `otel`.
40
+
41
+
### Metrics
42
+
43
+
Metrics is available on `/metrics` and a `ServiceMonitor` is configurable from the chart:
@@ -43,22 +54,16 @@ If you don't have a collector, you can build locally without the `telemetry` fea
43
54
cargo run
44
55
```
45
56
46
-
or, with optional telemetry (change as per requirements):
57
+
or, with optional telemetry:
47
58
48
59
```sh
49
60
OPENTELEMETRY_ENDPOINT_URL=https://0.0.0.0:55680 RUST_LOG=info,kube=trace,controller=debug cargo run --features=telemetry
50
61
```
51
62
52
63
### In-cluster
53
-
Use either your locally built image or the one from dockerhub (using opentelemetry features by default). Edit the [deployment](./yaml/deployment.yaml)'s image tag appropriately, and then:
For prebuilt, edit the [chart values](./charts/doc-controller/values.yaml) or [snapshotted yaml](./yaml/deployment.yaml) and apply as you see fit (like above).
60
65
61
-
To build and deploy the image quickly, we recommend using [tilt](https://tilt.dev/), via `tilt up` instead.
66
+
To develop by building and deploying the image quickly, we recommend using [tilt](https://tilt.dev/), via `tilt up` instead.
62
67
63
68
## Usage
64
69
In either of the run scenarios, your app is listening on port `8080`, and it will observe `Document` events.
@@ -102,7 +107,7 @@ $ curl 0.0.0.0:8080/
102
107
{"last_event":"2019-07-17T22:31:37.591320068Z"}
103
108
```
104
109
105
-
The metrics will be scraped by prometheus if you setup a`PodMonitor` or `ServiceMonitor` for it.
110
+
The metrics will be scraped by prometheus if you setup a`ServiceMonitor` for it.
106
111
107
112
### Events
108
113
The example `reconciler` only checks the `.spec.hidden` bool. If it does, it updates the `.status` object to reflect whether or not the instance `is_hidden`. It also sends a Kubernetes event associated with the controller. It is visible at the bottom of `kubectl describe doc samuel`.
0 commit comments