All Projects → blak3mill3r → keenest-rube

blak3mill3r / keenest-rube

Licence: MIT License
Clojure interface to Kubernetes

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to keenest-rube

nifikop
The NiFiKop NiFi Kubernetes operator makes it easy to run Apache NiFi on Kubernetes. Apache NiFI is a free, open-source solution that support powerful and scalable directed graphs of data routing, transformation, and system mediation logic.
Stars: ✭ 122 (+114.04%)
Mutual labels:  kubernetes-operator
secureCodeBox-v2
This Repository contains the stable beta preview of the next major secureCodeBox (SCB) release v2.0.0.
Stars: ✭ 23 (-59.65%)
Mutual labels:  kubernetes-operator
siddhi-operator
Operator allows you to run stream processing logic directly on a Kubernetes cluster
Stars: ✭ 16 (-71.93%)
Mutual labels:  kubernetes-operator
mloperator
Machine Learning Operator & Controller for Kubernetes
Stars: ✭ 85 (+49.12%)
Mutual labels:  kubernetes-operator
k6-operator
An operator for running distributed k6 tests.
Stars: ✭ 170 (+198.25%)
Mutual labels:  kubernetes-operator
k8s-operator
Write simple Kubernetes operators in a few lines of bash (or your favourite language)
Stars: ✭ 29 (-49.12%)
Mutual labels:  kubernetes-operator
custom-pod-autoscaler-operator
Operator for managing Kubernetes Custom Pod Autoscalers (CPA).
Stars: ✭ 29 (-49.12%)
Mutual labels:  kubernetes-operator
couchdb-operator
prototype kubernetes operator for couchDB
Stars: ✭ 17 (-70.18%)
Mutual labels:  kubernetes-operator
cdap-operator
CDAP Kubernetes Operator
Stars: ✭ 17 (-70.18%)
Mutual labels:  kubernetes-operator
wg-operator
Wireguard operator
Stars: ✭ 20 (-64.91%)
Mutual labels:  kubernetes-operator
grafana-operator
An operator for Grafana that installs and manages Grafana instances, Dashboards and Datasources through Kubernetes/OpenShift CRs
Stars: ✭ 449 (+687.72%)
Mutual labels:  kubernetes-operator
kubereplay
Seamless integration of goReplay and Kubernetes
Stars: ✭ 30 (-47.37%)
Mutual labels:  kubernetes-operator
chaos-operator
chaos engineering via kubernetes operator
Stars: ✭ 90 (+57.89%)
Mutual labels:  kubernetes-operator
oracle-database-operator
The Oracle Database Operator for Kubernetes (a.k.a. OraOperator) helps developers, DBAs, DevOps and GitOps teams reduce the time and complexity of deploying and managing Oracle Databases. It eliminates the dependency on a human operator or administrator for the majority of database operations.
Stars: ✭ 74 (+29.82%)
Mutual labels:  kubernetes-operator
netperf-operator
Kubernetes operator to measure TCP transmission speed between 2 pods
Stars: ✭ 39 (-31.58%)
Mutual labels:  kubernetes-operator
KubeContext
Mac MenuBar App for Switching your K8s Context
Stars: ✭ 15 (-73.68%)
Mutual labels:  kubernetes-operator
spark-operator
Operator for managing the Spark clusters on Kubernetes and OpenShift.
Stars: ✭ 129 (+126.32%)
Mutual labels:  kubernetes-operator
aws-iam-operator
AWS IAM Operator for Kubernetes
Stars: ✭ 23 (-59.65%)
Mutual labels:  kubernetes-operator
konsumerator
Kafka Consumer Operator. Kubernetes operator to manage consumers of unbalanced kafka topics with per-partition vertical autoscaling based on Prometheus metrics
Stars: ✭ 20 (-64.91%)
Mutual labels:  kubernetes-operator
wordpress-operator
Bitpoke Kubernetes operator for WordPress
Stars: ✭ 159 (+178.95%)
Mutual labels:  kubernetes-operator

[keenest-rube "0.1.0-alpha0"]

Clojars Project

A Clojure tool for Kubernetes operations

  • Cluster state is a value in an atom, the API calls are abstracted away
  • Manage your resources from the comfort of your Clojure REPL
  • Or, use it to build a Kubernetes abstraction...

Demo?

This one time, when I had completed the setup already...
;; I started poking around...

(count @pods)                   ;; => 0
(count @replicationcontrollers) ;; => 0
(count @services)               ;; => 0
  ;;      👎
;; and then I was all, like
(swap! pods assoc :my-awesome-podz
       {:metadata
        {:labels {:app "bunk" :special "false"} :namespace "playground" :name "my-awesome-podz"}
        :spec
        {:containers
         [{:name
           "two-peas"
           :env
           [{:name "REDIS_URL" :value "prolly.xwykgm.ng.0001.use1.cache.amazonaws.com:6379"}]
           :ports
           [{:containerPort 420, :protocol "TCP"}]
           :image
           "1337.dkr.ecr.us-east-1.amazonaws.com/two-peas:v1.0"}]
         :restartPolicy "Always",
         :terminationGracePeriodSeconds 30}})
  ;;      => 🔥
;;        (or if we're being optimistic, a new value for the pods atom)

;; and after a moment, a running pod:
(-> @pods
    :my-awesome-podz
    :status
    :containerStatuses
    first
    :ready) ;; => true

;;    and similarly for other resources...
;;       the Clojure data matches the JSON of the k8s API
;;          which is good, because there are no docs (yet)

Design

  • Kubernetes' API is an uncommonly good one, it's very consistent
    • It bends the REST rules and supports streaming updates to a client
    • given a WATCH request, it will keep the response body open, and continue to send lines of JSON
  • On initialization, keenest-rube GETs a (versioned) list of each kind of resource, initializes the atom, and then starts tailing a WATCH request starting from that version
    • this ensures that the atom is kept closely in sync with Kubernetes (few hundred ms, tops)
    • this uses aleph behind the scenes
  • Reading the state of the cluster is as easy as dereferencing it...
  • The abstraction over mutations is provided by a "derived atom" from lentes for each kind of resource
    • the pods atom in the demo, for example
    • the value in it is a map (by name) of all the pods in the namespace
    • these atoms make an API call as a side-effect of an update (by diffing)
      • You swap! the atom, keenest-rube does PUT, DELETE, and POST
    • All API errors throw, and the state of the atom is updated only using data from Kubernetes.
      • Your own updates to it are more like suggestions...
      • Only API responses from mutations, and the data from a WATCH stream, update the atom
    • Multiple resource mutations in a single swap! are explicitly disallowed
      • Because you'll be wanting to see the error message if a mutation fails

Setup

👉      If you just want to try it out,

           just clone this repo, launch a repl, and look at dev/user.clj

If you want to use it in your own project, you'll want something to manage the state...

Supposing we want to use mount and leiningen:

In project.clj

:dependencies [[keenest-rube "0.1.0-alpha0"]] ;; the "alpha" is for realz
:profiles {:dev {:dependencies [[mount "0.1.11"]]}}

and in src/your/playground.clj

(ns your.playground
  (:require
   [mount.core :as mount :refer [defstate]]
   [rube.core :as k]))

(defstate kube
  :start (k/intern-resources ;; this interns a var for each k8s resource
          (k/cluster
           {:server "http://localhost:8080" ;; kubectl proxy (or whatever)
            :namespace "playground"}))      ;; not production! (yet)
  :stop (k/disconnect! kube))

Disclaimer

This is alpha for a reason. It has not been thoroughly tested, it may misbehave, and the API may change.

Use it at your own risk.

That being said, it is restricted to operating within a k8s namespace

so it should be mostly harmless...

Is it any good?

Yes.

Contributing

Fork it, send me a pull request!

License

MIT

Similar work

https://github.com/nubank/clj-kubernetes-api

This library is quite different:

It's solid, much more low-level, providing Clojure helpers for each API call, generated from the official Swagger specs. It's also more complete than keenest-rube, which is young and has limitations. There's no reason you can't use them side by side, though.

Also I found it to be a valuable resource, and borrowed a couple of helper functions, so with many thanks to the author(s) of that library, I'll call this a derivative work.

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].