帮助将项目部署到Portainer的包
portainer-p的Python项目详细描述
安装
portainer py作为一个通用的 wheel和在linux/macos和windows上可用,并支持 python 3.5+。
$ pip install portainer-py
用法
从命令行
当前支持的唯一命令是deploy。 使用“帮助”功能了解如何使用它:
$ portainerpy deploy --help Usage: portainerpy deploy [OPTIONS] Update and deploy a portainer stack. To ease automation, this utility also support using environment variables instead of using these command line options: --user PORTAINER_USERNAME --password PORTAINER_PASSWORD --host PORTAINER_HOST --stackname PORTAINER_STACK_NAME --stackfile PORTAINER_STACKFILE Options: -f, --stackfile PATH Path to the stackfile.yml [required] -h, --host TEXT URL to Portainer host [required] -u, --user TEXT Portainer username [required] -p, --password TEXT Portainer password -n, --stackname TEXT Name of the Portainer stack [required] -e, --env TEXT Environment variables to add to the stack --prune-env If true, will remove existing environment variables from the stack --prune-stack Prune services that are no longer referenced --help Show this message and exit.
来自python
如果您在本地运行portainer,这应该很容易使用 Docker,按如下方式连接:
fromportainer_pyimportportainer_for_hostportainer=portainer_for_host("http://localhost:9000")portainer.login("<username>","<password>")stack=portainer.stack_with_name("my-stack")try:portainer.update_stack(stack["Id"],"path/to/stackfile.yml",env_vars={"foo":"bar"})except:PortainerErroraserror:print(error.message)
许可证
portainer py是根据 MIT License。