Popularity
7.3
-
Activity
7.3
-
136
4
21

Programming language: Elixir
Latest version: v0.5.2

k8s alternatives and similar packages

Based on the "Cloud Infrastructure and Management" category

Do you think we are missing an alternative of k8s or a related project?

Add another 'Cloud Infrastructure and Management' Package

README

K8s

K8s - Kubernetes API Client for Elixir

Build Status Coverage Status Hex.pm Documentation Hex.pm

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, "~> 0.5"}
  ]
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

There are many ways to configure cluster connections. Check out the guide for additional options.

In config.exs:

config :k8s,
  clusters: %{
    prod_us_east1: %{ # <- this can be any name, used to load connections later
      # Path to kube config
      conn: "~/.kube/config",
      # By default current context will be used, you can change the user or cluster
      conn_opts: [user: "some-user", cluster: "prod-cluster"]
    }
  }

Creating a deployment

{:ok, conn} = K8s.Conn.lookup(:prod_us_east1)

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(operation, conn)

Listing deployments

In a namespace:

{:ok, conn} = K8s.Conn.lookup(:prod_us_east1)

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

Across all namespaces:

{:ok, conn} = K8s.Conn.lookup(:prod_us_east1)

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

Getting a deployment

{:ok, conn} = K8s.Conn.lookup(:prod_us_east1)

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