diff --git a/infra/vultr-kubernetes/dev/find-server.py b/infra/vultr-kubernetes/dev/find-server.py index 81a7b22..6d4f2c9 100644 --- a/infra/vultr-kubernetes/dev/find-server.py +++ b/infra/vultr-kubernetes/dev/find-server.py @@ -22,15 +22,16 @@ if __name__ == '__main__': # Setting up k8s stuff api = k8s_api('../config.yaml') - print(type(api)) + pods = api.list_pod_for_all_namespaces(label_selector=f'app={args.game}') + node_name = pods.items[0].spec.node_name - # Now we collect specific data about the game server we requested - port = pods.items[0].spec.containers[0].ports[0].container_port + services = api.list_service_for_all_namespaces(label_selector=f'app={args.game}') + port = services.items[0].spec.ports[0].port # Collecting the IPV4 of the node that contains the pod(container) # we actually care about. Since these pods only have 1 container - node_name = pods.items[0].spec.node_name + # Now we collect specific data about the game server we requested node_ips = list(filter(lambda a: a.type == 'ExternalIP', api.list_node().items[0].status.addresses)) 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