Shiphelm


NameShiphelm JSON
Version 0.8.0 PyPI version JSON
download
home_pagehttps://gameplex-software.github.io/ShipHelm/
SummaryDocker and kubernetes integration library
upload_time2023-04-16 21:15:25
maintainer
docs_urlNone
authorGameplex Software
requires_python>=3.7
license
keywords skiffui kubernetes docker
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
<a href="https://gameplex-software.github.io/ShipHelm/">
<img src="https://user-images.githubusercontent.com/34868944/223447636-3e17dee3-ccdf-44cc-8d42-91378ced6708.png" width="400" />
</a>
</p>

# Shiphelm

## Table of Contents

- [Shiphelm](#shiphelm)
  - [Installation](#installation)
  - [Docker usage example](#docker-usage-example)
    - [Get a List of Running Containers](#get-a-list-of-running-containers)
    - [Get a running container by ID](#get-a-running-container-by-id)
    - [Get Stats and Ports for a Container by ID](#get-stats-and-ports-for-a-container-by-id)
    - [Search for Containers by Name](#search-for-containers-by-name)
    - [Change the Ports of a Container](#change-the-ports-of-a-container)
    - [Rename a Container](#rename-a-container)
    - [Add and Remove Containers from Networks](#add-and-remove-containers-from-networks)
    - [Create and Delete Networks](#create-and-delete-networks)
    - [Run a New Container](#run-a-new-container)
    - [Get and Set Environment Variables for a Container](#get-and-set-environment-variables-for-a-container)
    - [Get and Set Volumes for a Container](#get-and-set-volumes-for-a-container)
    - [Example code](#example-code)
  - [Kubernetes (K8S) usage example](#kubernetes-k8s-usage-example)
    - [Get a List of Running Containers](#get-a-list-of-running-containers-1)
    - [Get Stats and Ports for a Container by ID](#get-stats-and-ports-for-a-container-by-id-1)
    - [Search for Containers by Name](#search-for-containers-by-name-1)
    - [Change the Ports of a Container](#change-the-ports-of-a-container-1)
    - [Rename a Container](#rename-a-container-1)
    - [Add and Remove Containers from Networks](#add-and-remove-containers-from-networks-1)
    - [Create and Delete Networks](#create-and-delete-networks-1)
    - [Run a New Container](#run-a-new-container-1)
    - [Get and Set Environment Variables for a Container](#get-and-set-environment-variables-for-a-container-1)
    - [Get and Set Volumes for a Container](#get-and-set-volumes-for-a-container-1)
    - [Example code](#example-code-1)
    - [Dynamic engine selection](#dynamic-engine-selection)
    - [Remote engines via GUI](#remote-engines-via-gui)
- [Contributing](#contributing)


Shiphelm is a Python library for interacting with containers more easily. With Shiphelm, you can:

- Get a list of all running containers
- Get usage statistics and used ports for a given container by ID
- Search containers by name or ID
- Change the open ports of a container
- Run new containers
- Work with Docker, and Kubernetes
- Use Kubernetes clusters and Docker Swarm
- work on clusters, and swarms of container hosts

## Installation

You can install Shiphelm using pip:

```
pip install shiphelm
```
PyPI: [https://pypi.org/project/Shiphelm/]()

GitHub Releases [https://github.com/Gameplex-Software/ShipHelm/releases]()


<p align="center">
<img src="https://user-images.githubusercontent.com/34868944/231290469-900a253f-1236-4dd3-a126-85177931ce53.png" width="1000" />
</p>

## Docker usage example

This code will allow you to manage the local container engine


### Standalone Docker installation
```
from shiphelm.helm import helm

hd = helm() # create an instance of helm

helm.set_engine_manual("docker")
```

### Remote standalone Docker installation

This code will allow you to manage any compatible remote container engine
```
from shiphelm.helm import helm

hd = helm.reomte_connect('tcp://remote-docker-host:2375') # create an instance of helmdocker for romote management
```

### Remote Docker swarm installation

```
from shiphelm.helm import helm

hd = helm.helm() # create an instance of helm

helm.set_engine_manual(engine_select="docker", remoteAddress="YOUR ADDRESS HERE", remoteSecurity=<True|False>)
```

### Get a List of Running Containers

```
running_containers = hd.get_running_containers()
``` 

### Get a running container by ID

```
get_container_by_id(container_id)
```

### Get Stats and Ports for a Container by ID

```
container_stats = hd.get_container_stats(container_id)
container_ports = hd.get_container_ports(container_id)
```

### Search for Containers by Name

```
containers_by_name = hd.search_containers(name)
``` 

### Change the Ports of a Container
```
hd.change_container_ports(container_id, ports)
``` 

### Rename a Container

```
hd.rename_container(container_id, new_name)
``` 

### Add and Remove Containers from Networks

```
hd.add_container_to_network(container_id, network_name)
hd.remove_container_from_network(container_id, network_name)
``` 

### Create and Delete Networks

```
hd.create_network(network_name)
hd.delete_network(network_name)
``` 

### Run a New Container

```
container = hd.run_container(
    image=image,
    command=command,
    detach=detach,
    ports=ports,
    environment=environment,
    volumes=volumes
)
``` 

### Get and Set Environment Variables for a Container

```
container_environment = hd.get_container_environment(container_id)
hd.set_container_environment(container_id, environment)
``` 

### Get and Set Volumes for a Container

```
container_volumes = hd.get_container_volumes(container_id)
hd.set_container_volumes(container_id, volumes)
```
### Example code
This example runs 4 instances of the Docker "Getting Started" container

```
from shiphelm.helmdocker import helmdocker

hd = helmdocker() # create an instance of helmdocker
container_list = hd.get_running_containers() # call the method on the instance
print(container_list)
w=0

print("Preparing new server...")
while w<3:
    hd.run_container(image="docker/getting-started", detach=1)
    w=w+1

print("Your server is up and ready for connection!")
```

<p align="center">
<img src="https://user-images.githubusercontent.com/34868944/231290322-e18c1082-89e2-4b8a-abb3-8aee93f57bf9.png" width="1000" />
</p>

## Kubernetes (K8S) usage example

This code will allow you to manage the local container engine

```
from shiphelm.helm import helm

hd = helm.helm() # create an instance of helm

helm.set_engine_manual("kubernetes")
```

This code will allow you to manage any compatible remote container engine
```
from shiphelm.helm import helm

hd = helm.reomte_connect('tcp://remote--host:2375') # create an instance of helm for romote management
```

### Get a List of Running Containers

```
running_containers = hd.get_running_containers()
``` 

### Get Stats and Ports for a Container by ID

```
container_stats = hd.get_container_stats(container_id)
container_ports = hd.get_container_ports(container_id)
```

### Search for Containers by Name

```
containers_by_name = hd.search_containers(name)
``` 

### Change the Ports of a Container

```
hd.change_container_ports(container_id, ports)
``` 

### Rename a Container

```
hd.rename_container(container_id, new_name)
``` 

### Add and Remove Containers from Networks

```
hd.add_container_to_network(container_id, network_name)
hd.remove_container_from_network(container_id, network_name)
``` 

### Create and Delete Networks

```
hd.create_network(network_name)
hd.delete_network(network_name)
``` 

### Run a New Container

```
container = hd.run_container(
    image=image,
    command=command,
    detach=detach,
    ports=ports,
    environment=environment,
    volumes=volumes
)
``` 

### Get and Set Environment Variables for a Container

```
container_environment = hd.get_container_environment(container_id)
hd.set_container_environment(container_id, environment)
``` 

### Get and Set Volumes for a Container

```
container_volumes = hd.get_container_volumes(container_id)
hd.set_container_volumes(container_id, volumes)
```
### Example code
This example runs 4 instances of the  "Getting Started" container

```
from shiphelm.helm import helm

hd = helm() # create an instance of helm
container_list = hd.get_running_containers() # call the method on the instance
print(container_list)
w=0

print("Preparing new server...")
while w<3:
    hd.run_container(image="ollyw123/helloworld", detach=1)
    w=w+1

print("Your server is up and ready for connection!")
```

## Dynamic engine selection
You may have noticed that the syntax for controling both Docker and Kubernetes are identical, the way the code you write for ShipHelm is run depends on the engine you selected last.

In the last example we used the follwing code to initilise ShipHelm, create an alias, and select a container engine:

```
from shiphelm.helm import helm

hd = helm.helm() # create an instance of helm

helm.set_engine_manual("kubernetes")
```

f you want your cod to be able to use either engine that it detects locally you can use the following code instead:

```
from shiphelm.helm import helm

hd = helm.helm() # create an instance of helm

helm.set_engine_auto()
```

## Remote engines via GUI

To use remote engines you can use the following the examples above to connect programatically or use the below code to open a GUI configuration wizard:

```
from shiphelm.helm import helm

hd = helm.helm() # create an instance of helm

helm.remote_popup()
```

# Contributing

If you would like to contribute to SkiffUI, please feel free to open a pull request or issue on the [GitHub repository](https://github.com/Gameplex-Software/SkiffUI).

<script src="https://giscus.app/client.js"
        data-repo="Gameplex-Software/ShipHelm"
        data-repo-id="R_kgDOJGgWLg"
        data-category="General"
        data-category-id="DIC_kwDOJGgWLs4CVv98"
        data-mapping="pathname"
        data-strict="0"
        data-reactions-enabled="1"
        data-emit-metadata="0"
        data-input-position="bottom"
        data-theme="light"
        data-lang="en"
        data-loading="lazy"
        crossorigin="anonymous"
        async>
</script>

            

Raw data

            {
    "_id": null,
    "home_page": "https://gameplex-software.github.io/ShipHelm/",
    "name": "Shiphelm",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "SkiffUI,kubernetes,docker",
    "author": "Gameplex Software",
    "author_email": "info@gameplexsoftware.com",
    "download_url": "https://files.pythonhosted.org/packages/03/b8/f09975d562a4502db2e887f399a03e83f902d0cc5ef94bc47bc65fd816fe/Shiphelm-0.8.0.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n<a href=\"https://gameplex-software.github.io/ShipHelm/\">\n<img src=\"https://user-images.githubusercontent.com/34868944/223447636-3e17dee3-ccdf-44cc-8d42-91378ced6708.png\" width=\"400\" />\n</a>\n</p>\n\n# Shiphelm\n\n## Table of Contents\n\n- [Shiphelm](#shiphelm)\n  - [Installation](#installation)\n  - [Docker usage example](#docker-usage-example)\n    - [Get a List of Running Containers](#get-a-list-of-running-containers)\n    - [Get a running container by ID](#get-a-running-container-by-id)\n    - [Get Stats and Ports for a Container by ID](#get-stats-and-ports-for-a-container-by-id)\n    - [Search for Containers by Name](#search-for-containers-by-name)\n    - [Change the Ports of a Container](#change-the-ports-of-a-container)\n    - [Rename a Container](#rename-a-container)\n    - [Add and Remove Containers from Networks](#add-and-remove-containers-from-networks)\n    - [Create and Delete Networks](#create-and-delete-networks)\n    - [Run a New Container](#run-a-new-container)\n    - [Get and Set Environment Variables for a Container](#get-and-set-environment-variables-for-a-container)\n    - [Get and Set Volumes for a Container](#get-and-set-volumes-for-a-container)\n    - [Example code](#example-code)\n  - [Kubernetes (K8S) usage example](#kubernetes-k8s-usage-example)\n    - [Get a List of Running Containers](#get-a-list-of-running-containers-1)\n    - [Get Stats and Ports for a Container by ID](#get-stats-and-ports-for-a-container-by-id-1)\n    - [Search for Containers by Name](#search-for-containers-by-name-1)\n    - [Change the Ports of a Container](#change-the-ports-of-a-container-1)\n    - [Rename a Container](#rename-a-container-1)\n    - [Add and Remove Containers from Networks](#add-and-remove-containers-from-networks-1)\n    - [Create and Delete Networks](#create-and-delete-networks-1)\n    - [Run a New Container](#run-a-new-container-1)\n    - [Get and Set Environment Variables for a Container](#get-and-set-environment-variables-for-a-container-1)\n    - [Get and Set Volumes for a Container](#get-and-set-volumes-for-a-container-1)\n    - [Example code](#example-code-1)\n    - [Dynamic engine selection](#dynamic-engine-selection)\n    - [Remote engines via GUI](#remote-engines-via-gui)\n- [Contributing](#contributing)\n\n\nShiphelm is a Python library for interacting with containers more easily. With Shiphelm, you can:\n\n- Get a list of all running containers\n- Get usage statistics and used ports for a given container by ID\n- Search containers by name or ID\n- Change the open ports of a container\n- Run new containers\n- Work with Docker, and Kubernetes\n- Use Kubernetes clusters and Docker Swarm\n- work on clusters, and swarms of container hosts\n\n## Installation\n\nYou can install Shiphelm using pip:\n\n```\npip install shiphelm\n```\nPyPI: [https://pypi.org/project/Shiphelm/]()\n\nGitHub Releases [https://github.com/Gameplex-Software/ShipHelm/releases]()\n\n\n<p align=\"center\">\n<img src=\"https://user-images.githubusercontent.com/34868944/231290469-900a253f-1236-4dd3-a126-85177931ce53.png\" width=\"1000\" />\n</p>\n\n## Docker usage example\n\nThis code will allow you to manage the local container engine\n\n\n### Standalone Docker installation\n```\nfrom shiphelm.helm import helm\n\nhd = helm() # create an instance of helm\n\nhelm.set_engine_manual(\"docker\")\n```\n\n### Remote standalone Docker installation\n\nThis code will allow you to manage any compatible remote container engine\n```\nfrom shiphelm.helm import helm\n\nhd = helm.reomte_connect('tcp://remote-docker-host:2375') # create an instance of helmdocker for romote management\n```\n\n### Remote Docker swarm installation\n\n```\nfrom shiphelm.helm import helm\n\nhd = helm.helm() # create an instance of helm\n\nhelm.set_engine_manual(engine_select=\"docker\", remoteAddress=\"YOUR ADDRESS HERE\", remoteSecurity=<True|False>)\n```\n\n### Get a List of Running Containers\n\n```\nrunning_containers = hd.get_running_containers()\n``` \n\n### Get a running container by ID\n\n```\nget_container_by_id(container_id)\n```\n\n### Get Stats and Ports for a Container by ID\n\n```\ncontainer_stats = hd.get_container_stats(container_id)\ncontainer_ports = hd.get_container_ports(container_id)\n```\n\n### Search for Containers by Name\n\n```\ncontainers_by_name = hd.search_containers(name)\n``` \n\n### Change the Ports of a Container\n```\nhd.change_container_ports(container_id, ports)\n``` \n\n### Rename a Container\n\n```\nhd.rename_container(container_id, new_name)\n``` \n\n### Add and Remove Containers from Networks\n\n```\nhd.add_container_to_network(container_id, network_name)\nhd.remove_container_from_network(container_id, network_name)\n``` \n\n### Create and Delete Networks\n\n```\nhd.create_network(network_name)\nhd.delete_network(network_name)\n``` \n\n### Run a New Container\n\n```\ncontainer = hd.run_container(\n    image=image,\n    command=command,\n    detach=detach,\n    ports=ports,\n    environment=environment,\n    volumes=volumes\n)\n``` \n\n### Get and Set Environment Variables for a Container\n\n```\ncontainer_environment = hd.get_container_environment(container_id)\nhd.set_container_environment(container_id, environment)\n``` \n\n### Get and Set Volumes for a Container\n\n```\ncontainer_volumes = hd.get_container_volumes(container_id)\nhd.set_container_volumes(container_id, volumes)\n```\n### Example code\nThis example runs 4 instances of the Docker \"Getting Started\" container\n\n```\nfrom shiphelm.helmdocker import helmdocker\n\nhd = helmdocker() # create an instance of helmdocker\ncontainer_list = hd.get_running_containers() # call the method on the instance\nprint(container_list)\nw=0\n\nprint(\"Preparing new server...\")\nwhile w<3:\n    hd.run_container(image=\"docker/getting-started\", detach=1)\n    w=w+1\n\nprint(\"Your server is up and ready for connection!\")\n```\n\n<p align=\"center\">\n<img src=\"https://user-images.githubusercontent.com/34868944/231290322-e18c1082-89e2-4b8a-abb3-8aee93f57bf9.png\" width=\"1000\" />\n</p>\n\n## Kubernetes (K8S) usage example\n\nThis code will allow you to manage the local container engine\n\n```\nfrom shiphelm.helm import helm\n\nhd = helm.helm() # create an instance of helm\n\nhelm.set_engine_manual(\"kubernetes\")\n```\n\nThis code will allow you to manage any compatible remote container engine\n```\nfrom shiphelm.helm import helm\n\nhd = helm.reomte_connect('tcp://remote--host:2375') # create an instance of helm for romote management\n```\n\n### Get a List of Running Containers\n\n```\nrunning_containers = hd.get_running_containers()\n``` \n\n### Get Stats and Ports for a Container by ID\n\n```\ncontainer_stats = hd.get_container_stats(container_id)\ncontainer_ports = hd.get_container_ports(container_id)\n```\n\n### Search for Containers by Name\n\n```\ncontainers_by_name = hd.search_containers(name)\n``` \n\n### Change the Ports of a Container\n\n```\nhd.change_container_ports(container_id, ports)\n``` \n\n### Rename a Container\n\n```\nhd.rename_container(container_id, new_name)\n``` \n\n### Add and Remove Containers from Networks\n\n```\nhd.add_container_to_network(container_id, network_name)\nhd.remove_container_from_network(container_id, network_name)\n``` \n\n### Create and Delete Networks\n\n```\nhd.create_network(network_name)\nhd.delete_network(network_name)\n``` \n\n### Run a New Container\n\n```\ncontainer = hd.run_container(\n    image=image,\n    command=command,\n    detach=detach,\n    ports=ports,\n    environment=environment,\n    volumes=volumes\n)\n``` \n\n### Get and Set Environment Variables for a Container\n\n```\ncontainer_environment = hd.get_container_environment(container_id)\nhd.set_container_environment(container_id, environment)\n``` \n\n### Get and Set Volumes for a Container\n\n```\ncontainer_volumes = hd.get_container_volumes(container_id)\nhd.set_container_volumes(container_id, volumes)\n```\n### Example code\nThis example runs 4 instances of the  \"Getting Started\" container\n\n```\nfrom shiphelm.helm import helm\n\nhd = helm() # create an instance of helm\ncontainer_list = hd.get_running_containers() # call the method on the instance\nprint(container_list)\nw=0\n\nprint(\"Preparing new server...\")\nwhile w<3:\n    hd.run_container(image=\"ollyw123/helloworld\", detach=1)\n    w=w+1\n\nprint(\"Your server is up and ready for connection!\")\n```\n\n## Dynamic engine selection\nYou may have noticed that the syntax for controling both Docker and Kubernetes are identical, the way the code you write for ShipHelm is run depends on the engine you selected last.\n\nIn the last example we used the follwing code to initilise ShipHelm, create an alias, and select a container engine:\n\n```\nfrom shiphelm.helm import helm\n\nhd = helm.helm() # create an instance of helm\n\nhelm.set_engine_manual(\"kubernetes\")\n```\n\nf you want your cod to be able to use either engine that it detects locally you can use the following code instead:\n\n```\nfrom shiphelm.helm import helm\n\nhd = helm.helm() # create an instance of helm\n\nhelm.set_engine_auto()\n```\n\n## Remote engines via GUI\n\nTo use remote engines you can use the following the examples above to connect programatically or use the below code to open a GUI configuration wizard:\n\n```\nfrom shiphelm.helm import helm\n\nhd = helm.helm() # create an instance of helm\n\nhelm.remote_popup()\n```\n\n# Contributing\n\nIf you would like to contribute to SkiffUI, please feel free to open a pull request or issue on the [GitHub repository](https://github.com/Gameplex-Software/SkiffUI).\n\n<script src=\"https://giscus.app/client.js\"\n        data-repo=\"Gameplex-Software/ShipHelm\"\n        data-repo-id=\"R_kgDOJGgWLg\"\n        data-category=\"General\"\n        data-category-id=\"DIC_kwDOJGgWLs4CVv98\"\n        data-mapping=\"pathname\"\n        data-strict=\"0\"\n        data-reactions-enabled=\"1\"\n        data-emit-metadata=\"0\"\n        data-input-position=\"bottom\"\n        data-theme=\"light\"\n        data-lang=\"en\"\n        data-loading=\"lazy\"\n        crossorigin=\"anonymous\"\n        async>\n</script>\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Docker and kubernetes integration library",
    "version": "0.8.0",
    "project_urls": {
        "Homepage": "https://gameplex-software.github.io/ShipHelm/"
    },
    "split_keywords": [
        "skiffui",
        "kubernetes",
        "docker"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "22cac81da9f1b0c0b6218dc72099418a2534764728bf137885f5130eee2bea99",
                "md5": "c224e2d079fb60a1b626e96596dd2c0e",
                "sha256": "b5963372bb847ab016ee7a5aab9e5d4dd922e33dbad1ac7ba497816393c9a94f"
            },
            "downloads": -1,
            "filename": "Shiphelm-0.8.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c224e2d079fb60a1b626e96596dd2c0e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 13911,
            "upload_time": "2023-04-16T21:15:23",
            "upload_time_iso_8601": "2023-04-16T21:15:23.607664Z",
            "url": "https://files.pythonhosted.org/packages/22/ca/c81da9f1b0c0b6218dc72099418a2534764728bf137885f5130eee2bea99/Shiphelm-0.8.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "03b8f09975d562a4502db2e887f399a03e83f902d0cc5ef94bc47bc65fd816fe",
                "md5": "10f44f5a58268d117f4e662511547f45",
                "sha256": "a14333c4a46c80e612a6ebae33b3bf39a253e8ca12749764445077abab23da88"
            },
            "downloads": -1,
            "filename": "Shiphelm-0.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "10f44f5a58268d117f4e662511547f45",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 12007,
            "upload_time": "2023-04-16T21:15:25",
            "upload_time_iso_8601": "2023-04-16T21:15:25.229306Z",
            "url": "https://files.pythonhosted.org/packages/03/b8/f09975d562a4502db2e887f399a03e83f902d0cc5ef94bc47bc65fd816fe/Shiphelm-0.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-16 21:15:25",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "shiphelm"
}
        
Elapsed time: 0.06532s