51 lines
1.1 KiB
Python
51 lines
1.1 KiB
Python
|
#!/usr/bin/env python3
|
||
|
# Connect to the router pod
|
||
|
# On Alpine: nb3:~# apk add py3-kubernetes
|
||
|
|
||
|
|
||
|
import sys
|
||
|
import os
|
||
|
from kubernetes import client, config
|
||
|
|
||
|
# ~/k8s contains the config files
|
||
|
K8SCONFIGDIR=os.path.join(os.environ['HOME'], "k8s")
|
||
|
|
||
|
routermap = {
|
||
|
"p5-r1": "server137",
|
||
|
"p5-r2": "server138",
|
||
|
"p6-r1": "server139",
|
||
|
"p6-r2": "server140",
|
||
|
"p10-r1": "server122",
|
||
|
"p10-r2": "server123",
|
||
|
"p15-r1": "server120",
|
||
|
"p15-r2": "server121",
|
||
|
}
|
||
|
|
||
|
|
||
|
if not len(sys.argv) == 2:
|
||
|
print(f"{sys.argv[0]} <pX-r1|r2>")
|
||
|
sys.exit(1)
|
||
|
|
||
|
router=sys.argv[1]
|
||
|
|
||
|
|
||
|
if not router in routermap:
|
||
|
print(f"Router {router} not known")
|
||
|
sys.exit(1)
|
||
|
|
||
|
|
||
|
k8sconfig = os.path.join(K8SCONFIGDIR, f"{routermap[router]}.conf")
|
||
|
|
||
|
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)
|
||
|
|
||
|
#app.kubernetes.io/instance=bird-router-server120
|
||
|
|
||
|
#POD=$(kubectl -n rook-ceph get pods \
|
||
|
# -l app=rook-ceph-tools --output=jsonpath={.items..metadata.name})
|
||
|
#
|
||
|
#kubectl -n rook-ceph exec -ti $POD -- bash
|