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).
Trending in Announcing
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #performance
- #security











First Post!
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.
Kubereq.watch/3andKubereq.watch_single/4now also returnt:Kubereq.response/0.The stream which was returned directly before is now accessible through the
:bodykey of the returned
t:Req.Response.t/0struct. The:stream_tooption was removed.Kubereq.Watcherwas added for implementing long running watch event handlers.Changes
Kubereq.wait_until/5gets by withoutTask.async/1.Kubereq.create/3,Kubereq.update/3andKubereq.apply/5: Extractapi_verisonandkindfrom passed resource.Added
Kubereq.Watcher- A behaviour module for implementing a Kubernetes watch event handler.:intooption ofKubereq.list/3#46
Kubereq.can_i/3- Checks whether the authenticated user is authorized to perform a specific action.KubereqexceptKubereq.wait_until/5.