Add k8s client - test

This commit is contained in:
Jonathan Ervine 2020-12-15 13:57:50 +08:00
parent 6b8562662c
commit 71ee0cfe7c

View File

@ -13,10 +13,15 @@ from routes import *
from logging import error, info from logging import error, info
from subprocess import STDOUT, CalledProcessError, check_output from subprocess import STDOUT, CalledProcessError, check_output
from itertools import islice from itertools import islice
from kubernetes import client, config
app.register_blueprint(routes) app.register_blueprint(routes)
def get_namespaces(): def get_namespaces():
config.load_incluster_config()
v1 = client.Corev1Api()
ns = v1.list_namespace()
print(ns)
command = "/usr/local/bin/kubectl get ns -ojson" command = "/usr/local/bin/kubectl get ns -ojson"
info(f"Running command: {command}") info(f"Running command: {command}")
try: try: