All Projects → kube-rs → controller-rs

kube-rs / controller-rs

Licence: Apache-2.0 license
A kubernetes example controller

Programming Languages

rust
11053 projects
Makefile
30231 projects
Starlark
911 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to controller-rs

php-mvc
Mini framework para aplicaciones PHP con el patrón MVC
Stars: ✭ 35 (-73.88%)
Mutual labels:  controller
line-example-bot-tiny-php
Line Bot 基礎範例程式碼教學 (PHP) - 輕量版 LINEBotTiny.php
Stars: ✭ 58 (-56.72%)
Mutual labels:  example
web pipe
One-way pipe, composable, rack application builder
Stars: ✭ 56 (-58.21%)
Mutual labels:  controller
Fairtris
Clone of the official classic Tetris® game for the NES console, intended for Windows and Linux systems. It implements the original mechanics and includes many regional versions and several RNGs (all in one executable).
Stars: ✭ 30 (-77.61%)
Mutual labels:  controller
Polyel-Framework
⚡️ Voltis Core: A PHP framework based on Swoole from the ground up
Stars: ✭ 22 (-83.58%)
Mutual labels:  controller
ContainerView
Using Container View in iOS with Swift
Stars: ✭ 34 (-74.63%)
Mutual labels:  controller
kube-code-generator
Kubernetes code generator docker image
Stars: ✭ 60 (-55.22%)
Mutual labels:  controller
react-phoenix-users-boilerplate
Elixir/Phoenix + React + users template/boilerplate.
Stars: ✭ 71 (-47.01%)
Mutual labels:  example
droid controller
Control the parameters of an Android system with the power of Xposed framework. 通过Xposed框架控制Android参数。
Stars: ✭ 15 (-88.81%)
Mutual labels:  controller
lifequote
React port of a life insurance quick quoting application
Stars: ✭ 36 (-73.13%)
Mutual labels:  example
FCND-Term1-P3-3D-Quadrotor-Controller
Udacity Flying Car Nanodegree - Term 1 - Project 3 - 3D Quadrotor Controller
Stars: ✭ 31 (-76.87%)
Mutual labels:  controller
RockerView
A game controller view
Stars: ✭ 21 (-84.33%)
Mutual labels:  controller
go-learning
My Golang training material for testing smaller Go concepts and ideas.
Stars: ✭ 27 (-79.85%)
Mutual labels:  example
SPX-GC
SPX is a graphics control client for live video productions and live streams using CasparCG, OBS, vMix, or similar software.
Stars: ✭ 178 (+32.84%)
Mutual labels:  controller
tetris-demo
A Tetris example written in Rust using Piston in under 500 lines of code
Stars: ✭ 106 (-20.9%)
Mutual labels:  example
sbuscontroller
This Arduino-Sketch lets you connect your SBUS compatible radio wirelessly as controller to your pc.
Stars: ✭ 24 (-82.09%)
Mutual labels:  controller
thanos-receive-controller
Kubernetes controller to automatically configure Thanos receive hashrings
Stars: ✭ 55 (-58.96%)
Mutual labels:  controller
nxbt
Control your Nintendo Switch through a website, terminal, or macro.
Stars: ✭ 340 (+153.73%)
Mutual labels:  controller
aws-ses-serverless-example
AWS SES example in NodeJS using lambda
Stars: ✭ 75 (-44.03%)
Mutual labels:  example
godot entt example
A simple example on how to use entt (https://github.com/skypjack/entt) within godot
Stars: ✭ 36 (-73.13%)
Mutual labels:  example

controller-rs

ci docker image

A rust kubernetes reference controller for a Document resource using kube-rs, with observability instrumentation.

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.

Requirements

  • A Kubernetes cluster / k3d instance
  • The CRD
  • Opentelemetry collector (optional)

Cluster

As an example; get k3d then:

k3d cluster create --registry-create --servers 1 --agents 1 main
k3d kubeconfig get --all > ~/.kube/k3d
export KUBECONFIG="$HOME/.kube/k3d"

A default k3d setup is fastest for local dev due to its local registry.

CRD

Apply the CRD from cached file, or pipe it from crdgen (best if changing it):

cargo run --bin crdgen | kubectl apply -f -

Opentelemetry

Setup an opentelemetry collector in your cluster. Tempo / opentelemetry-operator / grafana agent should all work out of the box. If your collector does not support grpc otlp you need to change the exporter in main.rs.

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.

Running

Locally

cargo run

or, with optional telemetry (change as per requirements):

OPENTELEMETRY_ENDPOINT_URL=https://0.0.0.0:55680 RUST_LOG=info,kube=trace,controller=debug cargo run --features=telemetry

In-cluster

Use either your locally built image or the one from dockerhub (using opentemetry features by default). Edit the deployment's image tag appropriately, and then:

kubectl apply -f yaml/deployment.yaml
kubectl wait --for=condition=available deploy/doc-controller --timeout=20s
kubectl port-forward service/doc-controller 8080:80

To build and deploy the image quickly, we recommend using tilt, via tilt up instead.

NB: namespace is assumed to be default. If you need a different namespace, you can replace default with whatever you want in the yaml and set the namespace in your current-context to get all the commands here to work.

Usage

In either of the run scenarios, your app is listening on port 8080, and it will observe Document events.

Try some of:

kubectl apply -f yaml/instance-lorem.yaml
kubectl delete doc lorem
kubectl edit doc lorem # change hidden

The reconciler will run and write the status object on every change. You should see results in the logs of the pod, or on the .status object outputs of kubectl get doc -oyaml.

Webapp output

The sample web server exposes some example metrics and debug information you can inspect with curl.

$ kubectl apply -f yaml/instance-lorem.yaml
$ curl 0.0.0.0:8080/metrics
# HELP doc_controller_reconcile_duration_seconds The duration of reconcile to complete in seconds
# TYPE doc_controller_reconcile_duration_seconds histogram
doc_controller_reconcile_duration_seconds_bucket{le="0.01"} 1
doc_controller_reconcile_duration_seconds_bucket{le="0.1"} 1
doc_controller_reconcile_duration_seconds_bucket{le="0.25"} 1
doc_controller_reconcile_duration_seconds_bucket{le="0.5"} 1
doc_controller_reconcile_duration_seconds_bucket{le="1"} 1
doc_controller_reconcile_duration_seconds_bucket{le="5"} 1
doc_controller_reconcile_duration_seconds_bucket{le="15"} 1
doc_controller_reconcile_duration_seconds_bucket{le="60"} 1
doc_controller_reconcile_duration_seconds_bucket{le="+Inf"} 1
doc_controller_reconcile_duration_seconds_sum 0.013
doc_controller_reconcile_duration_seconds_count 1
# HELP doc_controller_reconciliation_errors_total reconciliation errors
# TYPE doc_controller_reconciliation_errors_total counter
doc_controller_reconciliation_errors_total 0
# HELP doc_controller_reconciliations_total reconciliations
# TYPE doc_controller_reconciliations_total counter
doc_controller_reconciliations_total 1
$ curl 0.0.0.0:8080/
{"last_event":"2019-07-17T22:31:37.591320068Z"}

The metrics will be auto-scraped if you have a standard PodMonitor for prometheus.io/scrape.

Events

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.

While this controller has no child objects configured, there is a configmapgen_controller example in kube-rs.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].