在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):kelproject/pykube开源软件地址(OpenSource Url):https://github.com/kelproject/pykube开源编程语言(OpenSource Language):Python 100.0%开源软件介绍(OpenSource Introduction):pykubePython client library for Kubernetes Kel is an open source Platform as a Service (PaaS) from Eldarion, Inc. that makes it easy to manage web application deployment and hosting through the entire lifecycle from development through testing to production. It adds components and tools on top of Kubernetes that help developers manage their application infrastructure. Kel builds on Eldarion's 7+ years experience running one of the leading Python and Django PaaSes. For more information about Kel, see kelproject.com, follow us on Twitter @projectkel, and join our Slack team. Features
InstallationTo install pykube, use pip: pip install pykube UsageQuery for all ready pods in a custom namespace: import operator
import pykube
api = pykube.HTTPClient(pykube.KubeConfig.from_file("/Users/<username>/.kube/config"))
pods = pykube.Pod.objects(api).filter(namespace="gondor-system")
ready_pods = filter(operator.attrgetter("ready"), pods) Access any attribute of the Kubernetes object: pod = pykube.Pod.objects(api).filter(namespace="gondor-system").get(name="my-pod")
pod.obj["spec"]["containers"][0]["image"] Selector query: pods = pykube.Pod.objects(api).filter(
namespace="gondor-system",
selector={"gondor.io/name__in": {"api-web", "api-worker"}},
)
pending_pods = pykube.objects.Pod.objects(api).filter(
field_selector={"status.phase": "Pending"}
) Watch query: watch = pykube.Job.objects(api, namespace="gondor-system")
watch = watch.filter(field_selector={"metadata.name": "my-job"}).watch()
# watch is a generator:
for watch_event in watch:
print(watch_event.type) # 'ADDED', 'DELETED', 'MODIFIED'
print(watch_event.object) # pykube.Job object Create a ReplicationController: obj = {
"apiVersion": "v1",
"kind": "ReplicationController",
"metadata": {
"name": "my-rc",
"namespace": "gondor-system"
},
"spec": {
"replicas": 3,
"selector": {
"app": "nginx"
},
"template": {
"metadata": {
"labels": {
"app": "nginx"
}
},
"spec": {
"containers": [
{
"name": "nginx",
"image": "nginx",
"ports": [
{"containerPort": 80}
]
}
]
}
}
}
}
pykube.ReplicationController(api, obj).create() Delete a ReplicationController: obj = {
"apiVersion": "v1",
"kind": "ReplicationController",
"metadata": {
"name": "my-rc",
"namespace": "gondor-system"
}
}
pykube.ReplicationController(api, obj).delete() Check server version: api = pykube.HTTPClient(pykube.KubeConfig.from_file("/Users/<username>/.kube/config"))
api.version HTTPiepykube can be used together with HTTPie for Kubernetes command line querying goodness. For example: pip install httpie
http pykube://minikube/api/v1/services The above example will construct an HTTP request to the cluster behind the Requirements
LicenseThe code in this project is licensed under the Apache License, version 2.0 (included in this repository under LICENSE). ContributingBy making a contribution to this project, you are agreeing to the Developer Certificate of Origin v1.1 (also included in this repository under DCO.txt). Code of ConductIn order to foster a kind, inclusive, and harassment-free community, the Kel Project follows the Contributor Covenant Code of Conduct. Commercial SupportCommercial support for Kel is available through Eldarion, please contact [email protected]. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论