• Stars
    star
    283
  • Rank 146,031 (Top 3 %)
  • Language
    Elixir
  • License
    MIT License
  • Created almost 6 years ago
  • Updated about 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

K8s

Module Version Coverage Status Last Updated

Build Status CI Build Status Elixir Build Status K8s

Hex Docs Total Download License

K8s - Kubernetes API Client for Elixir

Features

  • A client API for humans 👩đŸŧ🧑👩đŸģ👩đŸŊ👩🏾🧑đŸģ🧑đŸŊ🧑🧑🏾👨đŸŧ👨🏾👨đŸŋ
  • 🔮 Kubernetes resources, groups, and CRDs are autodiscovered at boot time. No swagger file to include or override.
  • Client supports standard HTTP calls, async batches, wait on status ⏲ī¸, and watchers 👀
  • ⚙ī¸ HTTP Request middleware
  • Multiple clusters ⚓ ⚓ ⚓
  • 🔐 Multiple authentication credentials
    • 🤖 serviceaccount
    • token
    • 📜 certificate
    • auth-provider
    • Pluggable auth providers!
  • 🆗 Tested against Kubernetes versions 1.10+ and master
  • 🛠ī¸ CRD support
  • 📈 Integrated with :telemetry
  • ℹī¸ Kubernetes resource and version helper functions
  • 🧰 Kube config file parsing
  • 🏎ī¸ Macro free; fast compile & fast startup

Installation

The package can be installed by adding :k8s to your list of dependencies in mix.exs:

def deps do
  [
    {:k8s, "~> 2.0"}
  ]
end

Usage

Check out the Usage Guide for in-depth examples.

Most functions are also written using doctests.

If you are interested in building Kubernetes Operators or Schedulers, check out Bonny.

tl;dr Examples

Configure a cluster connection

Cluster connections can be created using the K8s.Conn module.

K8s.Conn.from_file/1 will use the current context in your kubeconfig.

{:ok, conn} = K8s.Conn.from_file("path/to/kubeconfig.yaml")

K8s.Conn.from_file/2 accepts a keyword list to set the :user, :cluster, and/or :context

Connections can also be created in-cluster from a service account.

{:ok, conn} = K8s.Conn.from_service_account("/path/to/service-account/directory")

Check out the connection guide for additional details.

Creating a deployment

{:ok, conn} = K8s.Conn.from_file("path/to/kubeconfig.yaml")

opts = [namespace: "default", name: "nginx", image: "nginx:nginx:1.7.9"]
{:ok, resource} = K8s.Resource.from_file("priv/deployment.yaml", opts)

operation = K8s.Client.create(resource)
{:ok, deployment} = K8s.Client.run(conn, operation)

Listing deployments

In a namespace:

{:ok, conn} = K8s.Conn.from_file("path/to/kubeconfig.yaml")

operation = K8s.Client.list("apps/v1", "Deployment", namespace: "prod")
{:ok, deployments} = K8s.Client.run(conn, operation)

Across all namespaces:

{:ok, conn} = K8s.Conn.from_file("path/to/kubeconfig.yaml")

operation = K8s.Client.list("apps/v1", "Deployment", namespace: :all)
{:ok, deployments} = K8s.Client.run(conn, operation)

Getting a deployment

{:ok, conn} = K8s.Conn.from_file("path/to/kubeconfig.yaml")

operation = K8s.Client.get("apps/v1", :deployment, [namespace: "default", name: "nginx-deployment"])
{:ok, deployment} = K8s.Client.run(conn, operation)

More Repositories

1

bonny

The Elixir based Kubernetes Development Framework
Elixir
320
star
2

arbor

Ecto elixir adjacency list and tree traversal. Supports Ecto versions 2 and 3.
Elixir
233
star
3

speakeasy

Middleware based authorization for Absinthe GraphQL powered by Bodyguard
Elixir
81
star
4

klepto

A mean little DSL'd poltergeist (capybara) based web crawler that stuffs data into your Rails app.
Ruby
21
star
5

terraform-aws-cloudwatch_widget

Terraform AWS Cloudwatch Alarm with Dashboard Widget JSON Outputs
HCL
18
star
6

munson

JSON API Spec client for Ruby
Ruby
17
star
7

apocryphal

Swagger based document driven development for ExUnit
Elixir
17
star
8

ballast

Ballast manages kubernetes node pools to give you the cost of preemptible nodes with the confidence of on demand nodes.
Elixir
16
star
9

regulator

Controller-based minimal authorization through OO design and pure Ruby classes
Ruby
15
star
10

ruby-yui

Ruby wrapper for the YUI Compressor.
JavaScript
12
star
11

notion

Notion is a thin wrapper around telemetry that defines functions that dispatch telemetry events, documentation, and specs for your applications events.
Elixir
9
star
12

warningshot

Dependency Resolution Framework
Ruby
8
star
13

talks

Elixir
8
star
14

docker-kinesis-agent

AWS Kinesis Agent on Debian Slim 9
Makefile
7
star
15

dm-property-manager

Model ancestry and property management
Ruby
5
star
16

jquery.babysteps

A simple tool for turning long forms into baby steps.
5
star
17

federated-absinthe

Federating absinthe graphql with GraphQL Mesh.
Elixir
5
star
18

hello_operator

A greeting-server operator created with Bonny
Elixir
5
star
19

k8s-psp-rbac

Assigning kubernetes pod security policies with RBAC
4
star
20

k8s-elixir-schedulers

This is an example app used to illustrate how online schedulers are configured post OTP23 running in kubernetes.
Elixir
4
star
21

ingestor

Tool for ingesting plain text files in ActiveRecord
Ruby
3
star
22

activity_pub

ActivityPub is a decentralized social networking protocol
Elixir
3
star
23

k8s_conf

Parse Kubernetes' config files and generate HTTP headers/options for authenticating to the k8s API.
Elixir
3
star
24

merb_threshold

Access thresholding for controllers and actions. Set reasonable limits and stop constantly captchaing your users.
Ruby
3
star
25

k8s_client

Experimental kubernetes client in elixir
Elixir
3
star
26

petz

Phoenix app using Apocryphal / Swagger for testing
JavaScript
2
star
27

collectively

Add methods to ActiveRecord relations and collections.
Ruby
2
star
28

MerbMax

A collection of plugins for merb. Get your SEO on with meta, configure your instances with roles.
Ruby
2
star
29

res

Elixir state machine demo
Elixir
2
star
30

activity_streams

ActivityStreams 2.0 Validator
Elixir
2
star
31

merb_meta

SEO your merb, easy access to meta tags on a controller-by-controller or action-by-action basis, wee.
Ruby
2
star
32

try_git

1
star
33

images

Some of the best images on the planet.
1
star
34

metrics-mock

A simple prometheus metrics mock service
Go
1
star
35

kinesis-parser

Parse kinesis events
JavaScript
1
star
36

tf_modules

Terraform modules
HCL
1
star
37

yodeler

A generic instrumentation library with a multiple pluggable backend adapters.
Ruby
1
star
38

sacred

A CLI to sync markdown to the Confluence REST API
Go
1
star
39

json-schema-rails-rspec-demo

JSON Schema demo with Rails, RSpec, prmd, committee and active model serializers
Ruby
1
star
40

drinks

A boozy app to teach JSONAPI and some other stuff on Nerd Nights.
Ruby
1
star
41

phoenix-demo-project

Just a demo project for Phoenix
JavaScript
1
star
42

greeting-server

A greeting server for demoing the Bonny SDK
Go
1
star