Closed jacobtomlinson closed 10 months ago
Hi, thanks for including lightkube
in this comparison.
I just want to point out that in the example of scaling a deployment, kr8s
is first fetching the deployment object and then scale it. This is different from what is done from the other 3 library that just do a single API call.
I also realized that when calling update on lightkube
, it's not necessary to provide name and namespace if they are already provided in the object definition (need to update the documentation).
So corrected example of scale directly would be:
from lightkube import Client
from lightkube.resources.apps_v1 import Deployment
from lightkube.models.meta_v1 import ObjectMeta
from lightkube.models.autoscaling_v1 import ScaleSpec
client = Client()
obj = Deployment.Scale(
metadata=ObjectMeta(name='metrics-server', namespace='kube-system'),
spec=ScaleSpec(replicas=1)
)
client.replace(obj)
Example of fetch and scale:
from lightkube import Client
from lightkube.resources.apps_v1 import Deployment
client = Client()
obj = client.get(Deployment.Scale, 'metrics-server', namespace='kube-system')
obj.spec.replicas = 1
client.replace(obj)
Regarding the notice of "non production ready", I was not so sure about the stability of httpx
(main dependency) as it was a young project with frequent breaking changes in the API. Maybe is time to revisit that statement (for sure remove the sentence This project is still under development
). Thanks for bringing this to my attention.
Hey @gtsystem thanks for getting back to me and for taking the time to look over the post.
You're right I am accidentally getting the resource in the kr8s
example, I've updated that. I've also removed the name and namespace from replace in the lightkube
examples in https://github.com/jacobtomlinson/website/commit/78052fe5a804ae7ea074a9bb37a10cb7e4635f17. Thanks so much for the feedback.
Also thought you might like to know that all kr8s
objects support casting to/from lightkube
objects so if folks ever want to use both in a project or migrate from one to the other in either direction it should be pretty low friction.
# Get a resource with lightkube
from lightkube import Client
from lightkube.resources.apps_v1 import Deployment
client = Client()
obj = client.get(Deployment, 'foo', namespace='bar')
# Convert it to kr8s
import kr8s
obj = kr8s.objects.Deployment(obj)
# Convert it back to lightkube
obj = obj.to_lightkube()
I'll close this issue out but if you have any more feedback or if you ever want to compare notes don't hesitate to contact me. Cheers!
Hey there 👋. I'm the author of
kr8s
, another Python library for Kubernetes.The goal of
kr8s
is a little different tolightkube
, it's intended to be a batteries-included kubectl-inspired Python library that has a very shallow learning curve and reduces boilerplate. I built it to solve some specific challenges we were having indask-kubernetes
with using the officialkubernetes
library (and especiallykubernetes_asyncio
).We are at the point in development where
dask-kubernetes
has been fully migrated over to it and the API is getting pretty stable, so I decided to take a step back and assess how well we are doing in terms of hitting our design goals. In doing so I wrote up a blog post comparing thekr8s
API with other Python Kubernetes libraries includinglightkube
.The comparison is intended to check how well
kr8s
is meeting it's goals and to discuss the tradeoffs we make to achieve those goals compared with other libraries, rather than trying to show which is "better".I wanted to stop by here and open an issue to ask for feedback on the
lightkube
description and examples I've included in the post. I want to make sure I'm highlighting the strengths oflightkube
accurately so that if folks do use the post to choose between the libraries they can make an informed decision based on their own requirements.If you do have any feedback feel free to reply here, send me an email to jacob@tomlinson.email or open a PR directly on the blog post.
Thank you!