diff --git a/docs/ansible.rst b/docs/ansible.rst index d2138f21..529dd4a6 100644 --- a/docs/ansible.rst +++ b/docs/ansible.rst @@ -155,6 +155,7 @@ Noteworthy Differences * The `docker `_, `jail `_, + `kubectl `_, `local `_, `lxc `_, `lxd `_, @@ -681,6 +682,8 @@ connection delegation is supported. * ``ansible_user``: Name of user within the container to execute as. +.. _method-jail: + FreeBSD Jail ~~~~~~~~~~~~ @@ -692,6 +695,19 @@ connection delegation is supported. * ``ansible_user``: Name of user within the jail to execute as. +.. _method-kubectl: + +Kubernetes Pod +~~~~~~~~~~~~~~ + +Like `kubectl +`_ except +connection delegation is supported. + +* ``ansible_host``: Name of pod (default: inventory hostname). +* ``ansible_user``: Name of user to authenticate to API as. + + Local ~~~~~ diff --git a/docs/api.rst b/docs/api.rst index c74193e3..f365372d 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -589,6 +589,26 @@ Router Class Filename or complete path to the ``jexec`` binary. ``PATH`` will be searched if given as a filename. Defaults to ``/usr/sbin/jexec``. + .. method:: kubectl (pid=None, container=None, kubectl_path=None, username=None, \**kwargs) + + Construct a context in a container via the Kubernetes ``kubectl`` + program. + + Accepts all parameters accepted by :meth:`local`, in addition to: + + :param str pod: + Kubernetes pod to connect to. + :param str container: + Optional container within pod to connect to. If the pod has only + one container, this parameter is not required. Defaults to + :data:`None`. + :param str kubectl_path: + Filename or complete path to the ``kubectl`` binary. ``PATH`` will + be searched if given as a filename. Defaults to ``kubectl``. + :param str username: + Optional username to authenticate to the Kubernetes API server + with. within the container to :func:`setuid` to. + .. method:: lxc (container, lxc_attach_path=None, \**kwargs) Construct a context on the local machine within an LXC classic diff --git a/docs/changelog.rst b/docs/changelog.rst index 0027ee7d..4ba20f8b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -41,6 +41,9 @@ Enhancements `uri `_). See :ref:`ansible_tempfiles` for a complete description. +* `#376 `_: the ``kubectl`` connection + type is now supported. Contributed by Yannig Perré. + * `084c0ac0 `_: avoid a roundtrip in `copy `_ and @@ -170,6 +173,10 @@ Core Library * `#345 `_: the SSH connection method allows optionally disabling ``IdentitiesOnly yes``. +* `#371 `_: the LXC connection method + uses a more compatible method to establish an non-interactive session. + Contributed by Brian Candler. + * `af2ded66 `_: add :func:`mitogen.fork.on_fork` to allow non-Mitogen managed process forks to clean up Mitogen resources in the child. @@ -191,6 +198,7 @@ the bug reports in this release contributed by `Alex Russu `_, `atoom `_, `Berend De Schouwer `_, +`Brian Candler `_, `Dan Quackenbush `_, `dsgnr `_, `Jesse London `_, @@ -203,8 +211,9 @@ the bug reports in this release contributed by `Pierre-Louis Bonicoli `_, `Prateek Jain `_, `Rick Box `_, -`Tawana Musewe `_, and -`Timo Beckers `_. +`Tawana Musewe `_, +`Timo Beckers `_, and +`Yannig Perré `_. v0.2.2 (2018-07-26) diff --git a/mitogen/kubectl.py b/mitogen/kubectl.py index 2dfaa232..26480f7d 100644 --- a/mitogen/kubectl.py +++ b/mitogen/kubectl.py @@ -48,13 +48,10 @@ class Stream(mitogen.parent.Stream): 'merge_stdio': True } - def construct(self, pod = None, container=None, - kubectl_path=None, username=None, + def construct(self, pod, container=None, kubectl_path=None, username=None, **kwargs): - assert pod super(Stream, self).construct(**kwargs) - if pod: - self.pod = pod + self.pod = pod if container: self.container = container if kubectl_path: