mruoss

mruoss

Kubegen - Generate resource based Kubernetes clients

Kubegen generates Kubernetes clients in the form of resource based client modules directly into your project.

I have been co-maintaining the k8s library for some time now and while it is very dynamic and mighty, I always found it a bit big and clumsy for simple use cases. With Kubegen I went down a different road. Kubegen generates per resource client modules into your project. They are super straight-forward to use:

# list ConfigMaps in the default namespace:
{:ok, resp} = MyApp.K8sClient.Core.V1.ConfigMap.list("default")

# get the ConfigMap with name "my-config" in namespace "default":
{:ok, resp} = MyApp.K8sClient.Core.V1.ConfigMap.get("default", "my-config")

The generated modules use Kubereq to load the Kubernetes configuration and prepare the Req.Request for operations on the resource. Finally, it’s plain Req to make the HTTP requests and most function return {:ok, Req.Response.t()} in the happy case.

Generate your first Client Module

Generating your first client is quite straight-foward. Have a look at the project’s README.md on detailed instructions. But in a nutshell, the library offers a Mix task (mix kubegen) which reads some entries from your application configuration and generates the configured modules.

Generating clients for ConfigMap, Deployment, ClusterRole and a CRD looks like this:

Where’s the Kubernetes Configuration?

As part of the configuration you need to tell Kubegen how the Kubeconfig is loaded. Kubereq comes with a default loading pipeline which does the job in most basic setups (i.e. load the current context from $HOME/.kube/config or when running on a Kuberenetes cluster).

Most Liked

mruoss

mruoss

kubereq v0.4.0

I have released kubereq v0.4.0 today. See the changelog below. BTW: kino_k8s v2.0.0 was also released today. It uses kubereq now and all smart cells were consolidated into a single cell.

:warning: Breaking Changes :warning:

  • Kubereq.watch/3 and Kubereq.watch_single/4 now also return t:Kubereq.response/0.
    The stream which was returned directly before is now accessible through the :body
    key of the returned t:Req.Response.t/0 struct. The :stream_to option was removed.
    Kubereq.Watcher was added for implementing long running watch event handlers.

Changes

  • Kubereq.wait_until/5 gets by without Task.async/1.
  • Kubereq.create/3, Kubereq.update/3 and Kubereq.apply/5: Extract api_verison and kind from passed resource.

Added

  • Kubereq.Watcher - A behaviour module for implementing a Kubernetes watch event handler.
  • Streaming for paginated list operation via the :into option of Kubereq.list/3
    #46
  • Kubereq.can_i/3 - Checks whether the authenticated user is authorized to perform a specific action.
  • Error raising variants for all functions in Kubereq except Kubereq.wait_until/5.

Where Next?

Popular in Libraries Top

Qqwy
TypeCheck: Fast and flexible runtime type-checking for your Elixir projects. Core ideas Type- and function specifications are const...
336 13801 100
New
hpopp
After just over two years in development, this latest version of Pigeon is what I finally consider done in regards to my original vision ...
New
pkrawat1
Hey guyz We at @aviabird are working on a payment library in elixir/phoenix. We are targeting March 2018 to add 56 Gateways to it. Have...
New
devonestes
Introducing assertions, the library that helps you write really great test assertions! GitHub: https://github.com/devonestes/assertions ...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. Features Unstyled Phoenix components. Storybook that can be added to...
New
mbuhot
Leverage Open Api 3.0 (Swagger) to document, test, validate and explore your Plug and Phoenix APIs. Generate and serve a JSON Open API ...
New
woutdp
Hi! I wanted to introduce my latest project LiveSvelte. It allows you to render Svelte inside LiveView with end-to-end reactivity. It’s ...
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
Hal9000
Here is my first stab at this. README pasted below. https://github.com/Hal9000/elixir_random Comments and critiques are welcome. Th...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
381 12391 119
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

Sub Categories:

We're in Beta

About us Mission Statement