Docs for the kubernetes driver. Fixed provider factory not referencing the correct class name.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/c8c6c2f7 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/c8c6c2f7 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/c8c6c2f7 Branch: refs/heads/trunk Commit: c8c6c2f7c8ccef8cbf704fe4595f4ca350ba4fdd Parents: 0b87588 Author: anthony-shaw <[email protected]> Authored: Wed Jan 13 16:31:15 2016 +1100 Committer: anthony-shaw <[email protected]> Committed: Wed Jan 13 16:31:15 2016 +1100 ---------------------------------------------------------------------- .../images/provider_logos/kubernetes.png | Bin 0 -> 6357 bytes docs/container/_supported_methods.rst | 4 +- docs/container/_supported_providers.rst | 16 +++---- docs/container/drivers/kubernetes.rst | 42 +++++++++++++++++++ .../examples/container/kubernetes/docker_hub.py | 20 +++++++++ .../container/kubernetes/instantiate_driver.py | 14 +++++++ libcloud/container/drivers/kubernetes.py | 32 +++----------- libcloud/container/providers.py | 2 +- 8 files changed, 94 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/c8c6c2f7/docs/_static/images/provider_logos/kubernetes.png ---------------------------------------------------------------------- diff --git a/docs/_static/images/provider_logos/kubernetes.png b/docs/_static/images/provider_logos/kubernetes.png new file mode 100644 index 0000000..08da3fd Binary files /dev/null and b/docs/_static/images/provider_logos/kubernetes.png differ http://git-wip-us.apache.org/repos/asf/libcloud/blob/c8c6c2f7/docs/container/_supported_methods.rst ---------------------------------------------------------------------- diff --git a/docs/container/_supported_methods.rst b/docs/container/_supported_methods.rst index ea52dfc..4361d25 100644 --- a/docs/container/_supported_methods.rst +++ b/docs/container/_supported_methods.rst @@ -4,10 +4,12 @@ Provider install image list images deploy container get container start container stop container restart container destroy container list containers list locations create cluster destroy cluster list clusters =================================== ============= =========== ================ ============= =============== ============== ================= ================= =============== ============== ============== =============== ============= `Docker`_ yes yes yes yes yes yes yes yes yes no no no no -`Amazon Elastic Container Service`_ no no yes yes yes yes yes yes yes no yes yes yes +`Amazon Elastic Container Service`_ no yes yes yes yes yes yes yes yes no yes yes yes `Joyent Triton`_ yes yes yes yes yes yes yes yes yes no no no no +`Kubernetes`_ no no yes yes no no no yes yes no yes yes yes =================================== ============= =========== ================ ============= =============== ============== ================= ================= =============== ============== ============== =============== ============= .. _`Docker`: http://docker.io .. _`Amazon Elastic Container Service`: https://aws.amazon.com/ecs/details/ .. _`Joyent Triton`: http://joyent.com +.. _`Kubernetes`: http://kubernetes.io http://git-wip-us.apache.org/repos/asf/libcloud/blob/c8c6c2f7/docs/container/_supported_providers.rst ---------------------------------------------------------------------- diff --git a/docs/container/_supported_providers.rst b/docs/container/_supported_providers.rst index ebf4d82..3c400c6 100644 --- a/docs/container/_supported_providers.rst +++ b/docs/container/_supported_providers.rst @@ -1,13 +1,15 @@ .. NOTE: This file has been generated automatically using generate_provider_feature_matrix_table.py script, don't manually edit it -=================================== ======================================== ================= ======================================== =============================== -Provider Documentation Provider constant Module Class Name -=================================== ======================================== ================= ======================================== =============================== -`Docker`_ :doc:`Click </container/drivers/docker>` DOCKER :mod:`libcloud.container.drivers.docker` :class:`DockerContainerDriver` -`Amazon Elastic Container Service`_ :doc:`Click </container/drivers/ecs>` ECS :mod:`libcloud.container.drivers.ecs` :class:`ElasticContainerDriver` -`Joyent Triton`_ :doc:`Click </container/drivers/joyent>` JOYENT :mod:`libcloud.container.drivers.joyent` :class:`JoyentContainerDriver` -=================================== ======================================== ================= ======================================== =============================== +=================================== ============================================ ================= ============================================ ================================== +Provider Documentation Provider constant Module Class Name +=================================== ============================================ ================= ============================================ ================================== +`Docker`_ :doc:`Click </container/drivers/docker>` DOCKER :mod:`libcloud.container.drivers.docker` :class:`DockerContainerDriver` +`Amazon Elastic Container Service`_ :doc:`Click </container/drivers/ecs>` ECS :mod:`libcloud.container.drivers.ecs` :class:`ElasticContainerDriver` +`Joyent Triton`_ :doc:`Click </container/drivers/joyent>` JOYENT :mod:`libcloud.container.drivers.joyent` :class:`JoyentContainerDriver` +`Kubernetes`_ :doc:`Click </container/drivers/kubernetes>` KUBERNETES :mod:`libcloud.container.drivers.kubernetes` :class:`KubernetesContainerDriver` +=================================== ============================================ ================= ============================================ ================================== .. _`Docker`: http://docker.io .. _`Amazon Elastic Container Service`: https://aws.amazon.com/ecs/details/ .. _`Joyent Triton`: http://joyent.com +.. _`Kubernetes`: http://kubernetes.io http://git-wip-us.apache.org/repos/asf/libcloud/blob/c8c6c2f7/docs/container/drivers/kubernetes.rst ---------------------------------------------------------------------- diff --git a/docs/container/drivers/kubernetes.rst b/docs/container/drivers/kubernetes.rst new file mode 100644 index 0000000..e0253bd --- /dev/null +++ b/docs/container/drivers/kubernetes.rst @@ -0,0 +1,42 @@ +Kubernetes Documentation +======================== + +Kubernetes is an open source orchestration system for Docker containers. It handles scheduling onto nodes in a compute cluster and actively manages workloads to ensure that their state matches the users declared intentions. Using the concepts of "labels" and "pods", +it groups the containers which make up an application into logical units for easy management and discovery. + +.. figure:: /_static/images/provider_logos/kubernetes.png + :align: center + :width: 300 + :target: http://kubernetes.io/ + + +Authentication +-------------- + +Authentication currently supported with the following methods: + +* Basic HTTP Authentication - http://kubernetes.io/v1.1/docs/admin/authentication.html +* No authentication (testing only) + +Instantiating the driver +------------------------ + +.. literalinclude:: /examples/container/kubernetes/instantiate_driver.py + :language: python + +Deploying a container from Docker Hub +------------------------------------- + +Docker Hub Client :class:`~libcloud.container.utils.docker.HubClient` is a shared utility class for interfacing to the public Docker Hub Service. + +You can use this class for fetching images to deploy to services like ECS + +.. literalinclude:: /examples/container/kubernetes/docker_hub.py + :language: python + +API Docs +-------- + +.. autoclass:: libcloud.container.drivers.kubernetes.KubernetesContainerDriver + :members: + :inherited-members: http://git-wip-us.apache.org/repos/asf/libcloud/blob/c8c6c2f7/docs/examples/container/kubernetes/docker_hub.py ---------------------------------------------------------------------- diff --git a/docs/examples/container/kubernetes/docker_hub.py b/docs/examples/container/kubernetes/docker_hub.py new file mode 100644 index 0000000..dce1bef --- /dev/null +++ b/docs/examples/container/kubernetes/docker_hub.py @@ -0,0 +1,20 @@ +from libcloud.container.types import Provider +from libcloud.container.providers import get_driver +from libcloud.container.utils.docker import HubClient + +cls = get_driver(Provider.KUBERNETES) + +conn = cls(key='my_username', + secret='THIS_IS)+_MY_SECRET_KEY+I6TVkv68o4H', + host='126.32.21.4') +hub = HubClient() + +image = hub.get_image('ubuntu', 'latest') + +for cluster in conn.list_clusters(): + print(cluster.name) + if cluster.name == 'default': + container = conn.deploy_container( + cluster=cluster, + name='my-simple-app', + image=image) http://git-wip-us.apache.org/repos/asf/libcloud/blob/c8c6c2f7/docs/examples/container/kubernetes/instantiate_driver.py ---------------------------------------------------------------------- diff --git a/docs/examples/container/kubernetes/instantiate_driver.py b/docs/examples/container/kubernetes/instantiate_driver.py new file mode 100644 index 0000000..95fe997 --- /dev/null +++ b/docs/examples/container/kubernetes/instantiate_driver.py @@ -0,0 +1,14 @@ +from libcloud.container.types import Provider +from libcloud.container.providers import get_driver + +cls = get_driver(Provider.KUBERNETES) + +conn = cls(key='my_username', + secret='THIS_IS)+_MY_SECRET_KEY+I6TVkv68o4H', + host='126.32.21.4') + +for container in conn.list_containers(): + print(container.name) + +for cluster in conn.list_clusters(): + print(cluster.name) http://git-wip-us.apache.org/repos/asf/libcloud/blob/c8c6c2f7/libcloud/container/drivers/kubernetes.py ---------------------------------------------------------------------- diff --git a/libcloud/container/drivers/kubernetes.py b/libcloud/container/drivers/kubernetes.py index 13f2a51..ed02112 100644 --- a/libcloud/container/drivers/kubernetes.py +++ b/libcloud/container/drivers/kubernetes.py @@ -103,7 +103,7 @@ class KubernetesContainerDriver(ContainerDriver): supports_clusters = True def __init__(self, key=None, secret=None, secure=False, host='localhost', - port=4243, key_file=None, cert_file=None): + port=4243): """ :param key: API key or username to used (required) :type key: ``str`` @@ -121,20 +121,12 @@ class KubernetesContainerDriver(ContainerDriver): :param port: Override port used for connections. :type port: ``int`` - :param key_file: Path to private key for TLS connection (optional) - :type key_file: ``str`` - - :param cert_file: Path to public key for TLS connection (optional) - :type cert_file: ``str`` - :return: ``None`` """ super(KubernetesContainerDriver, self).__init__(key=key, secret=secret, secure=secure, host=host, - port=port, - key_file=key_file, - cert_file=cert_file) + port=port) if host.startswith('https://'): secure = True @@ -144,23 +136,9 @@ class KubernetesContainerDriver(ContainerDriver): if host.startswith(prefix): host = host.strip(prefix) - if key_file or cert_file: - # docker tls authentication- - # https://docs.docker.com/articles/https/ - # We pass two files, a key_file with the - # private key and cert_file with the certificate - # libcloud will handle them through LibcloudHTTPSConnection - if not (key_file and cert_file): - raise Exception( - 'Needs both private key file and ' - 'certificate file for tls authentication') - self.connection.key_file = key_file - self.connection.cert_file = cert_file - self.connection.secure = True - else: - self.connection.secure = secure - self.connection.key = key - self.connection.secret = secret + self.connection.secure = secure + self.connection.key = key + self.connection.secret = secret self.connection.host = host self.connection.port = port http://git-wip-us.apache.org/repos/asf/libcloud/blob/c8c6c2f7/libcloud/container/providers.py ---------------------------------------------------------------------- diff --git a/libcloud/container/providers.py b/libcloud/container/providers.py index c39566f..47897ed 100644 --- a/libcloud/container/providers.py +++ b/libcloud/container/providers.py @@ -27,7 +27,7 @@ DRIVERS = { Provider.ECS: ('libcloud.container.drivers.ecs', 'ElasticContainerDriver'), Provider.KUBERNETES: - ('libcloud.container.drivers.kubernetes', 'KubenetesContainerDriver'), + ('libcloud.container.drivers.kubernetes', 'KubernetesContainerDriver'), }
