• Stars
    star
    136
  • Rank 258,734 (Top 6 %)
  • Language
    Clojure
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 22 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kubernetes client, data driven

kubernetes-api

kubernetes-api is a Clojure library that acts as a kubernetes client

Motivation

We had a good experience with cognitect-labs/aws-api, and missed something like that for Kubernetes API. We had some client libraries that generated a lot of code, but it lacked discoverability and documentation.

clojure.deps

{:deps {nubank/k8s-api {:mvn/version "0.1.2"}}}

Leiningen

[nubank/k8s-api "0.1.2"]
;; In your ns statement
(ns my.ns
  (:require [kubernetes-api.core :as k8s]))

Usage

Instantiate a client

There're multiple options for authentication while instantiating a client. You can explicit set a token:

(def k8s (k8s/client "http://some.host" {:token "..."}))

Or a function that returns the token

(def k8s (k8s/client "http://some.host" {:token-fn (constantly "...")}))

You can also define client certificates

(def k8s (k8s/client "http://some.host" {:ca-cert     "/some/path/ca-docker.crt"
                                         :client-cert "/some/path/client-cert.pem"
                                         :client-key  "/some/path/client-java.key"}))

Discover

You can list all operations with

(k8s/explore k8s)

or specify a specific entity

(k8s/explore k8s :Deployment)
;=>
[:Deployment
 [:get "read the specified Deployment"]
 [:update "replace the specified Deployment"]
 [:delete "delete a Deployment"]
 [:patch "partially update the specified Deployment"]
 [:list "list or watch objects of kind Deployment"]
 [:create "create a Deployment"]
 [:deletecollection "delete collection of Deployment"]
 [:list-all "list or watch objects of kind Deployment"]]

get info on an operation

(k8s/info k8s {:kind :Deployment
               :action :create})
;=>
{:summary "create a Deployment",
 :parameters {:namespace java.lang.String,
              #schema.core.OptionalKey{:k :pretty} (maybe Str),
              #schema.core.OptionalKey{:k :dry-run} (maybe Str),
              #schema.core.OptionalKey{:k :field-manager} (maybe Str),
              :body ...},
 :returns {200 {#schema.core.OptionalKey{:k :apiVersion} (maybe Str),
                #schema.core.OptionalKey{:k :kind} (maybe Str),
                #schema.core.OptionalKey{:k :metadata} ...,
                #schema.core.OptionalKey{:k :spec} ...,
                #schema.core.OptionalKey{:k :status} ...},
           201 {#schema.core.OptionalKey{:k :apiVersion} (maybe Str),
                #schema.core.OptionalKey{:k :kind} (maybe Str),
                #schema.core.OptionalKey{:k :metadata} ...,
                #schema.core.OptionalKey{:k :spec} ...,
                #schema.core.OptionalKey{:k :status} ...},
           202 {#schema.core.OptionalKey{:k :apiVersion} (maybe Str),
                #schema.core.OptionalKey{:k :kind} (maybe Str),
                #schema.core.OptionalKey{:k :metadata} ...,
                #schema.core.OptionalKey{:k :spec} ...,
                #schema.core.OptionalKey{:k :status} ...},
           401 Any}}

Invoke

You can call an operation with

(k8s/invoke k8s {:kind    :ConfigMap
                 :action  :create
                 :request {:namespace "default"
                           :body      {:api-version "v1"
                                       :data       {"foo" "bar"}}}})

invoke it will return the body, with :request and :response in metadata

(meta (k8s/invoke ...))
;=>
{:request ...
 :response {:status ...
            :body ...}}

You can debug the request map with

(k8s/request k8s {:kind    :ConfigMap
                  :action  :create
                  :request {:namespace "default"
                            :body      {:api-version "v1"
                                        :data       {"foo" "bar"}}}})

If you want to read more about all different patch strategies Kubernetes offers, check this document

More Repositories

1

fklearn

fklearn: Functional Machine Learning
Jupyter Notebook
1,463
star
2

workspaces

Live development environment for Clojurescript
Clojure
487
star
3

matcher-combinators

Library for creating matcher combinator to compare nested data structures
Clojure
434
star
4

morse

A graphical, interactive tool for browsing Clojure data
JavaScript
324
star
5

state-flow

Integration testing framework using a state monad in the backend for building and composing flows
Clojure
290
star
6

nuvigator

A powerful routing abstraction over Flutter Navigator, with nested Navigator and Deeplinks
Dart
266
star
7

docopt.clj

Clojure implementation of the docopt description language
Clojure
77
star
8

mockfn

A mocking library for Clojure.
Clojure
74
star
9

clj-github

A Clojure library for interacting with the github developer API
Clojure
56
star
10

selvage

Testing at the edges with a world-transition style integration test framework
Clojure
53
star
11

i18next

Dart
44
star
12

nodely

Clojure
42
star
13

clj-github-app

A library to implement GitHub Apps in Clojure.
Clojure
41
star
14

node-modules-boilerplate

Demo project for Frontend Meetup scheduled to October 26th
JavaScript
40
star
15

vessel

A containerization tool for Clojure applications
Clojure
36
star
16

nixpkgs

Nix Packages collection used in Nubank
Nix
31
star
17

clj-owasp

28
star
18

ordnungsamt

helping maintain order and consistency across code-bases
Clojure
25
star
19

emidje

Test runner, report viewer and formatting tool for Midje within Emacs
Emacs Lisp
25
star
20

diversidados-curso-ds

Curso de data science - Diversidados
Jupyter Notebook
21
star
21

umschreiben-clj

Rewrite utilities for refactoring clojure files
Clojure
17
star
22

midje-nrepl

nREPL middleware to interact with Midje
Clojure
13
star
23

clj-github-mock

An emulator of the github api implemented in clojure to test your github app
Clojure
11
star
24

mobile-book-club

Ruby
10
star
25

clj-bigpanda

A clojure library for BigPanda Alerts and Deployments
Clojure
10
star
26

new-grad-template

Clojure
8
star
27

robocode-clojure

Template project for building a Robocode Robot in Clojure
Clojure
8
star
28

hack-her-way

Repositório para o programa de contratamento de mulheres em segurança do N
7
star
29

cljnvim

A Neovim config to develop woth Clojure!
Nix
4
star
30

mobile-pairing-exercises

Base project for Nubank's mobile pairing exercises
Swift
3
star
31

games

Mistura de Prática Deliberada e Gamefication
JavaScript
2
star
32

facturama-clojure-sdk

Clojure library for developing with Facturama's REST APIs
Clojure
2
star
33

tekton-watcher

Watcher for Tekton APIs
Clojure
2
star
34

desafio-cocoaheads

2
star
35

react-native-manifest

Electrode Native - Starter Manifest
Java
1
star
36

juntos-separados

Conversations media
1
star
37

prismatic-graphql

Library to create Prismatic schema from GraphQL queries
Clojure
1
star
38

spec-spi-code

Código referente a especificação de SPI
Java
1
star