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",
|
||||
description="General utility for finding resources for game server bot"
|
||||
)
|
||||
games = {"reflex", "minecraft", "nginx"}
|
||||
parser.add_argument('-g', '--game', required=True, choices=games)
|
||||
games = {"reflex", "minecraft"}
|
||||
parser.add_argument('-g', '--game', required=False, choices=games)
|
||||
|
||||
admin = {"health"}
|
||||
parser.add_argument('-a', '--admin', required=False, choices=admin)
|
||||
return parser.parse_args()
|
||||
|
||||
def k8s_api(config_path: str) -> client.api.core_v1_api.CoreV1Api:
|
||||
config.load_kube_config("../config.yaml")
|
||||
print("Getting pod name of our game requested")
|
||||
return client.CoreV1Api()
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = get_args()
|
||||
def get_admin_service_details(args: ArgumentParser, api: client.api.core_v1_api.CoreV1Api):
|
||||
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}')
|
||||
node_name = pods.items[0].spec.node_name
|
||||
|
||||
@ -36,4 +36,16 @@ if __name__ == '__main__':
|
||||
ipv4 = list(filter(lambda item: not 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