Python 官方文档:入门教程 => 点击学习
pip install kubernetes mkdir deamon/config cp $HOME/.kube/config deamon/config/kubeconfig.yamlfrom kubernetes im
pip install kubernetes
mkdir deamon/config
cp $HOME/.kube/config deamon/config/kubeconfig.yaml
from kubernetes import client, config
config.kube_config.load_kube_config(config_file="./config/kubeconfig.yaml")
class Kubernetes:
def __init__(self):
self.Connect = client.CoreV1api()
def ListNameSpace(self):
data = []
for ns in self.Connect.list_namespace().items:
data.append(ns)
return data
def CreateNameSpace(self,name):
body = client.V1Namespace()
body.metadata = client.V1ObjectMeta(name=name)
return self.Connect.create_namespace(body=body)
k = Kubernetes()
print k.ListNameSpace()
--结束END--
本文标题: python 操作 K8S
本文链接: https://lsjlt.com/news/191391.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0