一个通用Python Library for Container Orchestrators
kubeshift的Python项目详细描述
#kubeshift
[![构建状态](https://travis-ci.org/cdrage/kubeshift.svg?branch=master)(https://travis ci.org/cdrage/kubeshift)
[![覆盖状态](https://coveralls.io/repos/github/cdrage/kubeshift/badge.svg?branch=master)(https://coveralls.io/github/cdrage/kubeshift?branch=master)
\introduction
uu功能:
-100%HTTP API
-自动解析` ~/.kube/config`
-`.kube/config`生成
-TLS身份验证
-100%测试覆盖率,功能和集成测试
安装
cd kubeshift
make install
```
《python需求
``sh
`` cat requirements.txt
anymarkup
requests
`
` `
`
` `
` ` ` `
《方法与示例
<
<
/><
/>makeinstall
/>makeinstall
/>` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `对象。目前我们支持导入和生成kubernetes和openshift配置文件。
``python
import kubeshift
“kubernetes”)
“kubernetes”)
```
每个调用返回一个dictionary对象容器所有信息。这些方法是从“http://localhost:8080/api”的调用列表中创建的。有些调用*需要*提供名称空间。否则,将使用“默认”。
**API调用方法:**
```
。组件状态
。命名空间
。节点
。持久卷
。第三方资源
```
**命名空间API调用方法:**
```
.configmaps(namespace=“default”)
.endpoints(namespace=“default”)
.events(namespace=“default”)
.limitranges(namespace=“default”)
.persistentVolumeClaims(namespace=“default”)
.pods(namespace=“default”)
.podtemplates(namespace=“default”)
.resourceQuotas(namespace=“default”)
.secrets(namespace=“default“)
.服务帐户(namespace=”default“)
.服务(namespace=”default“)
.守护进程(namespace=”default“)
.部署(namespace=”default“)
.水平播客自动缩放程序(namespace=”default“)
.入口(namespace=”default“)
.作业(namespace=”default“)
.网络策略(namespace=”default“)
.复制集(namespace=”default“)
.petsets(namespace=”default“)
.podsruptionbudgets(namespace=”default“)
`````
**这些api调用可以通过以下方法进一步过滤:**
```
.filter(namespace=”foo“,status=“running”)
.all()
.metadata()
.items()
`````
**完整示例:**
```python
import kubeshift
import getpass
“spec”:{
“containers”:[{“image”:“nginx”,“name”:“helloapache”,“ports”:[{“containerport”:80,“hostport”:80,“protocol”:“tcp”}]}}}
客户端配置
user=getpass.getuser()
config=kubeshift.config.from_file(“/home/%s/.kube/config%”user)
client=kubeshift.client(config,“kubernetes”)
replicas=3)缩放k8s对象(如果是服务的话)
client.delete删除k8s对象
>客户端.pods().items()
```
[![构建状态](https://travis-ci.org/cdrage/kubeshift.svg?branch=master)(https://travis ci.org/cdrage/kubeshift)
[![覆盖状态](https://coveralls.io/repos/github/cdrage/kubeshift/badge.svg?branch=master)(https://coveralls.io/github/cdrage/kubeshift?branch=master)
\introduction
uu功能:
-100%HTTP API
-自动解析` ~/.kube/config`
-`.kube/config`生成
-TLS身份验证
-100%测试覆盖率,功能和集成测试
安装
cd kubeshift
make install
```
《python需求
``sh
`` cat requirements.txt
anymarkup
requests
`
` `
`
` `
` ` ` `
《方法与示例
<
<
/><
/>makeinstall
/>makeinstall
/>` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `对象。目前我们支持导入和生成kubernetes和openshift配置文件。
``python
import kubeshift
“kubernetes”)
“kubernetes”)
```
每个调用返回一个dictionary对象容器所有信息。这些方法是从“http://localhost:8080/api”的调用列表中创建的。有些调用*需要*提供名称空间。否则,将使用“默认”。
**API调用方法:**
```
。组件状态
。命名空间
。节点
。持久卷
。第三方资源
```
**命名空间API调用方法:**
```
.configmaps(namespace=“default”)
.endpoints(namespace=“default”)
.events(namespace=“default”)
.limitranges(namespace=“default”)
.persistentVolumeClaims(namespace=“default”)
.pods(namespace=“default”)
.podtemplates(namespace=“default”)
.resourceQuotas(namespace=“default”)
.secrets(namespace=“default“)
.服务帐户(namespace=”default“)
.服务(namespace=”default“)
.守护进程(namespace=”default“)
.部署(namespace=”default“)
.水平播客自动缩放程序(namespace=”default“)
.入口(namespace=”default“)
.作业(namespace=”default“)
.网络策略(namespace=”default“)
.复制集(namespace=”default“)
.petsets(namespace=”default“)
.podsruptionbudgets(namespace=”default“)
`````
**这些api调用可以通过以下方法进一步过滤:**
```
.filter(namespace=”foo“,status=“running”)
.all()
.metadata()
.items()
`````
**完整示例:**
```python
import kubeshift
import getpass
“spec”:{
“containers”:[{“image”:“nginx”,“name”:“helloapache”,“ports”:[{“containerport”:80,“hostport”:80,“protocol”:“tcp”}]}}}
客户端配置
user=getpass.getuser()
config=kubeshift.config.from_file(“/home/%s/.kube/config%”user)
client=kubeshift.client(config,“kubernetes”)
replicas=3)缩放k8s对象(如果是服务的话)
client.delete删除k8s对象
>客户端.pods().items()
```