Slowly prepping dev tool to find admin services too
This commit is contained in:
parent
6d642a7359
commit
f5f670e5f2
@ -8,21 +8,21 @@ def get_args() -> Namespace:
|
|||||||
prog="Cluster Search Thing",
|
prog="Cluster Search Thing",
|
||||||
description="General utility for finding resources for game server bot"
|
description="General utility for finding resources for game server bot"
|
||||||
)
|
)
|
||||||
games = {"reflex", "minecraft", "nginx"}
|
games = {"reflex", "minecraft"}
|
||||||
parser.add_argument('-g', '--game', required=True, choices=games)
|
parser.add_argument('-g', '--game', required=False, choices=games)
|
||||||
|
|
||||||
|
admin = {"health"}
|
||||||
|
parser.add_argument('-a', '--admin', required=False, choices=admin)
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
def k8s_api(config_path: str) -> client.api.core_v1_api.CoreV1Api:
|
def k8s_api(config_path: str) -> client.api.core_v1_api.CoreV1Api:
|
||||||
config.load_kube_config("../config.yaml")
|
config.load_kube_config("../config.yaml")
|
||||||
print("Getting pod name of our game requested")
|
|
||||||
return client.CoreV1Api()
|
return client.CoreV1Api()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def get_admin_service_details(args: ArgumentParser, api: client.api.core_v1_api.CoreV1Api):
|
||||||
args = get_args()
|
print('admin thing requested', args.admin)
|
||||||
|
|
||||||
# Setting up k8s stuff
|
|
||||||
api = k8s_api('../config.yaml')
|
|
||||||
|
|
||||||
|
def get_game_server_ip(args: ArgumentParser, api: client.api.core_v1_api.CoreV1Api):
|
||||||
pods = api.list_pod_for_all_namespaces(label_selector=f'app={args.game}')
|
pods = api.list_pod_for_all_namespaces(label_selector=f'app={args.game}')
|
||||||
node_name = pods.items[0].spec.node_name
|
node_name = pods.items[0].spec.node_name
|
||||||
|
|
||||||
@ -37,3 +37,15 @@ if __name__ == '__main__':
|
|||||||
ipv6 = list(filter(lambda item: re.match('[\d\.]{3}\d', item.address), node_ips))[0].address
|
ipv6 = list(filter(lambda item: re.match('[\d\.]{3}\d', item.address), node_ips))[0].address
|
||||||
|
|
||||||
print(f'{args.game} --> {ipv4}:{port} ~~> {ipv6}:{port}')
|
print(f'{args.game} --> {ipv4}:{port} ~~> {ipv6}:{port}')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
args = get_args()
|
||||||
|
api = k8s_api('../config.yaml')
|
||||||
|
|
||||||
|
if args.game:
|
||||||
|
get_game_server_ip(args, api)
|
||||||
|
|
||||||
|
if args.admin:
|
||||||
|
get_admin_service_details(args, api)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user