• Stars
    star
    140
  • Rank 261,473 (Top 6 %)
  • Language
    Elixir
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

Kubernetes API client for Elixir

Kazan

Kazan is a Kubernetes API client for Elixir. It uses the OpenAPI specifications provided by kube to generate most of it's functions and datastructures. This allows the whole kube API to be supported with relatively little effort.

Kazan should mostly work though it's not thoroughly tested against the actual kubernetes API. If you find a bug in the library please file an issue (or submit a PR) and I'll try and get it fixed.

I'm reasonably happy with the API at the moment so I don't expect to change it too drastically. However I can't speak for the k8s API specifications that the kazan code is generated from. Also the library is still pre-1.0 so if I find a better way to put it together I may end up changing things.

Looking for some help? Check out kazan's Gitter chatroom.

Features

  • Support for most Kubernetes API calls.
  • Structs for most Kubernetes API structures.
  • Documentation of all models & calls.
  • Client certificate, token and auth provider based authentication.
  • Loading config from kubeconfig files.
  • Support for watch requests.
  • Typespecs for functions and structs (though dialyzer outputs a lot of warnings when run on Kazan)
  • Limited support for custom resources. See the Kazan.Model documentation for more details.

Not Implemented

  • Other forms of authentication
  • Patching with application/json-patch+json or application/strategic-merge-patch+json content types.
  • Removing fields when patching with application/merge-patch+json.
  • Comprehensive tests.
  • Validation of requests.
  • Probably some other things.

Installation

If available in Hex, the package can be installed as:

  1. Add kazan to your list of dependencies in mix.exs:
def deps do
  [{:kazan, "~> 0.11"}]
end
  1. Ensure kazan is started before your application:
def application do
  [applications: [:kazan]]
end

Configuration

Kazan uses the Kazan.Server struct to contain server & authentication configuration details. Kazan.Server also provides some convenience functions to create a Kazan.Server from external sources such as a kube config file, or a kube service account.

If your application is only going to be talking to a single kubernetes cluster, then it's recommended to configure that cluster in your mix config. This makes working with kazan slightly easier, as you can call Kazan.run without providing a server every time.

In Cluster Authentication

If your code is going to be running on a kubernetes cluster and you wish to use the kubernetes service account that can be configured like this:

config :kazan, :server, :in_cluster

Alternatively, the Kazan.Server.in_cluster function can be used to create a server for passing straight into Kazan.run

Configuration via kube config file.

If you have a kube config file that contains the cluster & auth details you wish to use, kazan can use that:

config :kazan, :server, {:kubeconfig, "path/to/file"}

Alternatively, the Kazan.Server.from_kubeconfig function can be used to create a server for passing straight into Kazan.run

Configuring server details directly

If you wish to configure the server details manually, kazan can also accept a map of server parameters:

config :kazan, :server, %{url: "kubernetes.default" auth: %{token: "your_token"}}

See the Kazan.Server documentation to see what fields this supports.

Google Kubernetes Engine Config via gcloud

If developing against GKE, gcloud can create a kube config file that Kazan can understand. However, in this case you will need to call Kazan.Server.resolve_auth/2 in order to query gcloud for a valid token. See the docs for Kazan.Server.resolve_auth/2 for more details.

Usage

Making a request with Kazan is done in two stages.

  1. Build the request object using one of the functions in Kazan.Api.*.
  2. Run that request using Kazan.run.

For example, to get all of the pods from the server configured in the mix config:

Kazan.Apis.Core.V1.list_pod_for_all_namespaces!()
|> Kazan.run!()
# %Kazan.Models.V1.PodList{...}

Alternatively, you might want to specify the server to send the request to:

server = Kazan.Server.in_cluster()

Kazan.Apis.Core.V1.list_pod_for_all_namespaces!()
|> Kazan.run!(server: server)
# %Kazan.Apis.Core.V1.PodList{...}

More details on building requests can be found in the documentation for Kazan.Apis.

Details on creating watch requests can be found in the documentation for Kazan.Watcher.

More Repositories

1

cynic

A bring your own types GraphQL client library for Rust
Rust
375
star
2

graphql-ws-client

A GraphQL over Websockets implementation for Rust
Rust
39
star
3

libsysconfcpus

A github mirror of http://www.kev.pulo.com.au/libsysconfcpus/
Shell
32
star
4

erlang_port

A utility library for writing Erlang/Elixir ports in Rust
Rust
25
star
5

chunnel

A python client for phoenix channels.
Python
18
star
6

ex_unit_fixtures

A library for defining modular dependencies (fixtures) for ExUnit tests.
Elixir
13
star
7

exometer_datadog

An elixir library for pushing exometer metrics to datadog via the REST API.
Elixir
12
star
8

flask-should-dsl

A flask extension for testing with should-dsl
Python
10
star
9

serde_eetf

Erlang external term format support for serde
Rust
9
star
10

asdf-elm

Elm plugin for asdf version manager.
Shell
6
star
11

go-away

Generate go types from rust types
Rust
4
star
12

ractive-brunch

Adds ractive compilation support to brunch
JavaScript
4
star
13

gae-logstash-http

A flask application to allow GAE apps to post to logstash using urlfetch.
Python
4
star
14

dotfiles

My dotfiles
Vim Script
4
star
15

plug_fprof

An Elixir Plug for profiling code with fprof.
Elixir
4
star
16

flycheck-elixir-dogma

Elixir linting support for flycheck
Emacs Lisp
3
star
17

vassal

A task queue that emulates SQS for testing SQS based applications.
Elixir
3
star
18

git-lead-time

CLI for checking the lead time of a teams commits on GitHub
Rust
2
star
19

docker-python-web

Dockerfiles for hosting python web apps
Shell
2
star
20

elk

An elixir app for running google app engine pull queues.
Elixir
2
star
21

asdf-purescript

PureScript plugin for asdf version manager
Shell
2
star
22

cerberus_to_swagger

A hacky script for converting cerberus schemas to swagger data definitions
Python
1
star
23

synchg

Simple Mercurial Syncing
Python
1
star
24

docker-logstash-http-kibana

A docker logstash image, w/ kibana, nginx & gae-logstash-http
Shell
1
star
25

request_pot

A requestb.in clone using Elixir & Elm
Elixir
1
star
26

pypod

A simple command line podcatcher with a web interface
Python
1
star
27

docker-elixir

Shell
1
star
28

openapi-subgraph-example

Rust
1
star
29

elm-slow-test

A temporary project for demonstrating how slow elm compiles on CI
Elm
1
star
30

k8s-certbot-google-dns

Docker image & YAML for running certbot on k8s
Shell
1
star
31

growlproxy

A simple python based proxy for gntp notifications. A complete work in progress, anything may be broken at any time
JavaScript
1
star
32

syncro

An Android app & server for wireless file syncing
C++
1
star
33

action-graphql-introspect

1
star
34

resumr

A web-app for creating CVs with a git database backend
JavaScript
1
star