[k8s] update router script to connect to bird
This commit is contained in:
parent
163ec9f791
commit
71182ce550
1 changed files with 16 additions and 1 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
from kubernetes import client, config
|
||||
|
||||
# ~/k8s contains the config files
|
||||
|
@ -36,13 +37,27 @@ if not router in routermap:
|
|||
|
||||
k8sconfig = os.path.join(K8SCONFIGDIR, f"{routermap[router]}.conf")
|
||||
|
||||
print(f"Using KUBECONFIG={k8sconfig} for accessing {router} ...")
|
||||
|
||||
if not os.path.exists(k8sconfig):
|
||||
print(f"You need to have {k8sconfig} for accessing {router}")
|
||||
sys.exit(1)
|
||||
|
||||
config.load_kube_config(config_file=k8sconfig)
|
||||
v1 = client.CoreV1Api()
|
||||
|
||||
#app.kubernetes.io/instance=bird-router-server120
|
||||
pods = v1.list_pod_for_all_namespaces(watch=False,
|
||||
label_selector="app.kubernetes.io/component=bird")
|
||||
|
||||
print("Number of pods: " + str(len(pods.items)))
|
||||
for i in pods.items:
|
||||
pod=i.metadata.name
|
||||
print(f"Pod: {pod}")
|
||||
|
||||
os.environ["KUBECONFIG"] = k8sconfig
|
||||
|
||||
cmd = f"kubectl exec -ti {pod} -c bird -- sh"
|
||||
p = subprocess.run(cmd, shell=True)
|
||||
|
||||
#POD=$(kubectl -n rook-ceph get pods \
|
||||
# -l app=rook-ceph-tools --output=jsonpath={.items..metadata.name})
|
||||
|
|
Loading…
Reference in a new issue