Kubernetes

python中调用k8s的API

本文主要是介绍python中调用k8s的API,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
 1 import kubernetes.client
 2 import kubernetes.config
 3 from flask import current_app
 4 import time
 5 
 6 
 7 class K8sDispatcher():
 8     def __init__(self):
 9         kubernetes.config.load_kube_config(current_app.config["KUBE_CONFIG"])
10         current_app.logger.info(
11             "=== config file is: {}".format(
12                 current_app.config["KUBE_CONFIG"]))
13         self.batch_v1 = kubernetes.client.BatchV1Api()
14         self.core_v1 = kubernetes.client.CoreV1Api()
15         self.NAMESPACE = "calibration"
16         self.volumes = {}
17         self.image = None

 

这篇关于python中调用k8s的API的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!