Discussion:
[Twisted-Python] [ANN] txkube 0.1.0
Jean-Paul Calderone
2017-04-10 18:11:57 UTC
Permalink
Hello all,

I'm pleased to announce the first release of txkube, a Twisted-based
library for interacting with Kubernetes using the HTTP API.

This release supports several of the most commonly used basic Kubernetes
objects, including Services, ConfigMaps, Deployments, ReplicaSets, and
Pods. While Kubernetes has many, many more object kinds, this collection
of kinds already supports a very useful set of interactions.

Here is an example of txkube usage, taken from the README:

from __future__ import print_function
from twisted.internet.task import react

from txkube import v1, network_kubernetes_from_context

@react
def main(reactor):
k8s = network_kubernetes_from_context(reactor, u"minikube")
client = k8s.client()
d = client.list(v1.Namespace)
d.addCallback(print)
return d

You can download txkube from PyPI <https://pypi.python.org/pypi>.
You can contribute to its development on GitHub
<https://github.com/LeastAuthority/txkube>.

Thanks to Least Authority Enterprises <https://leastauthority.com/> for
sponsoring this development.

Jean-Paul Calderone
http://as.ynchrono.us/
Glyph Lefkowitz
2017-04-11 05:15:56 UTC
Permalink
Post by Jean-Paul Calderone
Hello all,
I'm pleased to announce the first release of txkube, a Twisted-based library for interacting with Kubernetes using the HTTP API.
✚³✚🎉
Post by Jean-Paul Calderone
This release supports several of the most commonly used basic Kubernetes objects, including Services, ConfigMaps, Deployments, ReplicaSets, and Pods. While Kubernetes has many, many more object kinds, this collection of kinds already supports a very useful set of interactions.
Thanks for the announcement!

I do have one question about txkube, since this comes up periodically in every higher-level networking layer, and it's a place where I think Twisted has some advantages over other HTTP clients: is there a way to specify custom trust roots, or construct a custom Agent to pass in to txkube?
Post by Jean-Paul Calderone
from __future__ import print_function
from twisted.internet.task import react
from txkube import v1, network_kubernetes_from_context
@react
btw, don't think I didn't notice this <https://github.com/twisted/twisted/pull/646#discussion_r96104930>...
Post by Jean-Paul Calderone
k8s = network_kubernetes_from_context(reactor, u"minikube")
client = k8s.client()
d = client.list(v1.Namespace)
d.addCallback(print)
return d
You can download txkube from PyPI <https://pypi.python.org/pypi>.
You can contribute to its development on GitHub <https://github.com/LeastAuthority/txkube>.
Thanks to Least Authority Enterprises <https://leastauthority.com/> for sponsoring this development.
Thanks, LAE!

-glyph
Jean-Paul Calderone
2017-04-11 11:14:27 UTC
Permalink
On Apr 10, 2017, at 11:11 AM, Jean-Paul Calderone <
Hello all,
I'm pleased to announce the first release of txkube, a Twisted-based
library for interacting with Kubernetes using the HTTP API.
✚³✚🎉
This release supports several of the most commonly used basic Kubernetes
objects, including Services, ConfigMaps, Deployments, ReplicaSets, and
Pods. While Kubernetes has many, many more object kinds, this collection
of kinds already supports a very useful set of interactions.
Thanks for the announcement!
I do have one question about txkube, since this comes up periodically in
every higher-level networking layer, and it's a place where I think Twisted
has some advantages over other HTTP clients: is there a way to specify
custom trust roots, or construct a custom Agent to pass in to txkube?
There's another constructor for IKubernetesService
<https://github.com/LeastAuthority/txkube/blob/b2e81400e40989696f82cabfd575d5283f7180e8/src/txkube/_interface.py>,
network_kubernetes
<https://github.com/LeastAuthority/txkube/blob/b2e81400e40989696f82cabfd575d5283f7180e8/src/txkube/_network.py#L41-L56>.
It takes an IAgent. So one can do:

network_kubernetes(base_url=url, agent=Agent(contextFactory=...))

Does that approach fit with any emerging conventions for exposing this kind
of functionality? I'd be happy to adapt it if there's a better pattern.

Also note that it's common for Kubernetes to be deployed with a self-signed
or other non-cartel certificate. So even the API in the example,
network_kubernetes_from_context, doesn't trust the usual web-oriented
collection of CAs. It only respects the certificate found in the local
Kubernetes configuration. This means that there's another way to control
this - edit ~/.kube/config and put the desired CA certificate there.
from __future__ import print_function
from twisted.internet.task import react
from txkube import v1, network_kubernetes_from_context
@react
btw, don't think I didn't notice this
<https://github.com/twisted/twisted/pull/646#discussion_r96104930>...
😂

Jean-Paul
k8s = network_kubernetes_from_context(reactor, u"minikube")
client = k8s.client()
d = client.list(v1.Namespace)
d.addCallback(print)
return d
You can download txkube from PyPI <https://pypi.python.org/pypi>.
You can contribute to its development on GitHub
<https://github.com/LeastAuthority/txkube>.
Thanks to Least Authority Enterprises <https://leastauthority.com/> for
sponsoring this development.
Thanks, LAE!
-glyph
_______________________________________________
Twisted-Python mailing list
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Glyph Lefkowitz
2017-04-12 01:56:38 UTC
Permalink
Post by Glyph Lefkowitz
Post by Jean-Paul Calderone
Hello all,
I'm pleased to announce the first release of txkube, a Twisted-based library for interacting with Kubernetes using the HTTP API.
✚³✚🎉
Post by Jean-Paul Calderone
This release supports several of the most commonly used basic Kubernetes objects, including Services, ConfigMaps, Deployments, ReplicaSets, and Pods. While Kubernetes has many, many more object kinds, this collection of kinds already supports a very useful set of interactions.
Thanks for the announcement!
I do have one question about txkube, since this comes up periodically in every higher-level networking layer, and it's a place where I think Twisted has some advantages over other HTTP clients: is there a way to specify custom trust roots, or construct a custom Agent to pass in to txkube?
network_kubernetes(base_url=url, agent=Agent(contextFactory=...))
Does that approach fit with any emerging conventions for exposing this kind of functionality? I'd be happy to adapt it if there's a better pattern.
I think that's the state of the art, and it's a good primitive to build upon. If something needs to change, it's not the way txkube (et. al.) accept their argument, but rather a function in Twisted somewhere that computes the Towers of Hanoi Agent-stacking solution that Treq contains: https://github.com/twisted/treq/blob/b436c6c89b3a1b7fb2ecb5300ae24bcbea20fad0/src/treq/client.py#L198-L217
Post by Glyph Lefkowitz
Also note that it's common for Kubernetes to be deployed with a self-signed or other non-cartel certificate. So even the API in the example, network_kubernetes_from_context, doesn't trust the usual web-oriented collection of CAs. It only respects the certificate found in the local Kubernetes configuration. This means that there's another way to control this - edit ~/.kube/config and put the desired CA certificate there.
Cool. Although this is actually exactly what I'd expect (as I would imagine most Kubernetes users) this behavior sounds like something that might be worth calling out in the README.
Post by Glyph Lefkowitz
Post by Jean-Paul Calderone
from __future__ import print_function
from twisted.internet.task import react
from txkube import v1, network_kubernetes_from_context
@react
btw, don't think I didn't notice this <https://github.com/twisted/twisted/pull/646#discussion_r96104930>...
😂
Jean-Paul
Post by Jean-Paul Calderone
k8s = network_kubernetes_from_context(reactor, u"minikube")
client = k8s.client()
d = client.list(v1.Namespace)
d.addCallback(print)
return d
You can download txkube from PyPI <https://pypi.python.org/pypi>.
You can contribute to its development on GitHub <https://github.com/LeastAuthority/txkube>.
Thanks to Least Authority Enterprises <https://leastauthority.com/> for sponsoring this development.
Thanks, LAE!
-glyph
_______________________________________________
Twisted-Python mailing list
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python <http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python>
_______________________________________________
Twisted-Python mailing list
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python <http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python>
Loading...