Kubernetes leader election using the coordination.k8s.io API.

Overview

Kube Coordinate

docs.rs Build Status

Kubernetes leader election using the coordination.k8s.io API.

Kube Coordinate builds upon the kube-rs ecosystem, and implements a streamlined version of the client-go leader election system. This implementation uses only Lease objects for coordination.

// Spawn a leader elector task, and get a handle to the state channel.
let handle = LeaderElector::spawn(/* ... */);
let state_chan = handle.state();

// Before taking action as a leader, just check the channel to ensure
// the lease is currently held by this process.
if state_chan.borrow().is_leader() {
    // Only perform leader actions if in leader state.
}

// Or, for a more sophisticated pattern, watch the state channel for changes,
// and use it to drive your application's state machine.
let state_stream = tokio_stream::wrappers::WatchStream::new(state_chan);
loop {
    tokio::select! {
        Some(state) = state_stream.next() => match state {
            LeaderState::Leader => (), // Leader tasks.
            _ => (), // Non-leader tasks.
        },
    }
}

Install

cargo add kube-coordinate

License

kube-coordinate is licensed under the terms of the MIT License or the Apache License 2.0, at your choosing.

You might also like...
A K8s-optimized operating system, based on CoreOS

Kanopy Ultramarine Kanopy is a lightweight and easy to setup operating system optimized for Kubernetes. It is based on Ultramarine Linux, a Fedora rem

A Kubernetes implementation of the Open Application Model specification

Rudr 🚨 NOTE: Rudr is deprecated in favor of the upcoming open application platform project as its successor. There are no plans to produce future rel

An example of a Kubernetes operator implemented in Rust
An example of a Kubernetes operator implemented in Rust

Rust Kubernetes operator example A Kubernetes operator built on top of kube-rs project. There is an explanatory article available. Steps to run on Lin

 KDash - A fast and simple dashboard for Kubernetes
KDash - A fast and simple dashboard for Kubernetes

KDash - A fast and simple dashboard for Kubernetes

Krustlet: Kubernetes Kubelet in Rust for running WASM

Krustlet: Kubernetes Kubelet in Rust for running WASM 🚧 🚧 This project is highly experimental. 🚧 🚧 It should not be used in production workloads.

Detects orphan configmaps and secrets in a Kubernetes cluster

KubExplorer Warning: Proof of concept. Feedback is much welcome. Discovers and prints out any Configmaps and Secrets not linked to any of the followin

Rust command line utility to quickly display useful secrets in a Kubernetes namespace
Rust command line utility to quickly display useful secrets in a Kubernetes namespace

kube-secrets This is a command line utility for quickly looking at secrets in a Kubernetes namespace that are typically looked at by humans. It specif

Rust Kubernetes client and controller runtime

kube-rs Rust client for Kubernetes in the style of a more generic client-go, a runtime abstraction inspired by controller-runtime, and a derive macro

💫 Small microservice to handle state changes of Kubernetes pods and post them to Instatus or Statuspages

💫 Kanata Small microservice to handle state changes of Kubernetes pods and post to Instatus 🤔 Why? I don't really want to implement and repeat code

kubernetes openapi unmangler

kopium A kubernetes openapi unmangler. Creates rust structs from a named crd by converting the live openapi schema. ⚠️ WARNING: ALPHA SOFTWARE ⚠️ Inst

Continuous Delivery for Declarative Kubernetes, Serverless and Infrastructure Applications
Continuous Delivery for Declarative Kubernetes, Serverless and Infrastructure Applications

Continuous Delivery for Declarative Kubernetes, Serverless and Infrastructure Applications Explore PipeCD docs » Overview PipeCD provides a unified co

engula-operator creates/configures/manages engula clusters atop Kubernetes

Engula Operator The engula operator manages engula clusters deployed to Kubernetes and automates tasks related to operating an engula cluster. Backgro

Build tool for custom setups of docker containers. Docker compose didn't offer enough, Kubernetes offered too much. Carbon is the in-between.
Build tool for custom setups of docker containers. Docker compose didn't offer enough, Kubernetes offered too much. Carbon is the in-between.

docker abstraction layer with added flair Fast travel: Tips Contributing How it works Installation Help This tool started its life as a way to make de

Rust client for Kubernetes

Rust client for Kubernetes API.

Ultralight, security-first service mesh for Kubernetes. Main repo for Linkerd 2.x.
Ultralight, security-first service mesh for Kubernetes. Main repo for Linkerd 2.x.

Linkerd 🎈 Welcome to Linkerd! 👋 Linkerd is an ultralight, security-first service mesh for Kubernetes. Linkerd adds critical security, observability,

 Northstar is a horizontally scalable and multi-tenant Kubernetes cluster provisioner and orchestrator
Northstar is a horizontally scalable and multi-tenant Kubernetes cluster provisioner and orchestrator

Northstar Northstar is a horizontally scalable and multi-tenant Kubernetes cluster provisioner and orchestrator. Explore the docs » View Demo · Report

Kubernetes controller written in Rust for automatically generating and updating secrets

Kubernetes controller written in Rust for automatically generating and updating secrets

Rust Kubernetes runtime helpers. Based on kube-rs.
Rust Kubernetes runtime helpers. Based on kube-rs.

kubert Rust Kubernetes runtime helpers. Based on kube-rs. Features clap command-line interface support; A basic admin server with /ready and /live pro

Playing with web dev in Rust. This is a sample Rust microservice that can be deployed on Kubernetes.

Playing with web dev in Rust. This is a sample Rust microservice that can be deployed on Kubernetes.

Comments
  • Consider security linting

    Consider security linting

    Hi there,

    My unsolicited recommendation is that security linting can be implemented during the CI phase. A nice tool for this is SemGrep

    https://semgrep.dev/ https://github.com/semgrep/semgrep

    I did a manual lint of the code, no significant findings as of now but if you put this in the CI phase, we can catch any potential security artifacts the moment they appear.

    opened by thanasisk 0
Releases(v0.1.3)
  • v0.1.3(Dec 11, 2023)

    What's Changed

    • Add categories & keywords to Cargo.toml by @thedodd in https://github.com/thedodd/kube-coordinate/pull/1

    Full Changelog: https://github.com/thedodd/kube-coordinate/compare/v0.1.2...v0.1.3

    Source code(tar.gz)
    Source code(zip)
  • v0.1.2(Dec 5, 2023)

  • v0.1.1(Dec 5, 2023)

Owner
Anthony Dodd
Anthony Dodd
A single-binary, GPU-accelerated LLM server (HTTP and WebSocket API) written in Rust

Poly Poly is a versatile LLM serving back-end. What it offers: High-performance, efficient and reliable serving of multiple local LLM models Optional

Tommy van der Vorst 13 Nov 5, 2023
A crate to implement leader election for Kubernetes workloads in Rust.

Kubernetes Leader Election in Rust This library provides simple leader election for Kubernetes workloads.

Hendrik Maus 33 Dec 29, 2022
A simple demo to bind a TCP port with k8s exec channel.k8s.io websocket API.

k8s-webterm-connector Tired with web terminals? Let's use it with CLI! This is just a simple demo to bind a TCP port with k8s exec websocket API, whic

Chielo 4 Aug 11, 2023
Rust based Kubernetes Operator to deploy K8s objects minimally.

kube-nimble nimble /ˈnɪmbl/ - quick and light in movement or action; agile. This project began from a place of curiosity about Kubernetes CRDs and the

Meet Vasani 3 Feb 26, 2024
kubesql, Experimental tool to query K8s API using plain SQL

kubesql, an experimental tool for querying your Kubernetes API Server using simple and smallest SQL syntax.

Furkan Türkal 168 Dec 19, 2022
H2O Open Source Kubernetes operator and a command-line tool to ease deployment (and undeployment) of H2O open-source machine learning platform H2O-3 to Kubernetes.

H2O Kubernetes Repository with official tools to aid the deployment of H2O Machine Learning platform to Kubernetes. There are two essential tools to b

H2O.ai 16 Nov 12, 2022
Kubernetes operator for declaratively deploying wasmCloud applications (via wadm) and hosts on Kubernetes.

wasmcloud-operator An operator for managing a set of wasmCloud hosts running on Kubernetes and manage wasmCloud applications using wadm. The goal is t

wasmcloud 11 May 1, 2024
Coordination repository of the Game Development Working Group

Rust Game Development Working Group ??️ The game development working group's main purpose is to make Rust a first-class option for game developers. Wh

Rust game development working group 448 Jan 2, 2023
Transmute - a binary that works alone or in coordination with coverage formatter to report test quality

Transmute is a binary that works alone or in coordination with coverage formatter to report test quality. It will change your code and make the tests fail. If don't, we will raise it for you.

Victor Antoniazzi 5 Nov 17, 2022
Cost saving K8s controller to scale down and up of resources during non-business hours

Kube-Saver Motivation Scale down cluster nodes by scaling down Deployments, StatefulSet, CronJob, Hpa during non-business hours and save $$, but if yo

Mahesh Rayas 5 Aug 15, 2022