Fixing port finding script
This commit is contained in:
parent
7f2ee6d35b
commit
5d03f6b218
@ -22,15 +22,16 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
# Setting up k8s stuff
|
# Setting up k8s stuff
|
||||||
api = k8s_api('../config.yaml')
|
api = k8s_api('../config.yaml')
|
||||||
print(type(api))
|
|
||||||
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
|
||||||
|
|
||||||
# Now we collect specific data about the game server we requested
|
services = api.list_service_for_all_namespaces(label_selector=f'app={args.game}')
|
||||||
port = pods.items[0].spec.containers[0].ports[0].container_port
|
port = services.items[0].spec.ports[0].port
|
||||||
|
|
||||||
# Collecting the IPV4 of the node that contains the pod(container)
|
# Collecting the IPV4 of the node that contains the pod(container)
|
||||||
# we actually care about. Since these pods only have 1 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))
|
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
|
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
|
ipv6 = list(filter(lambda item: re.match('[\d\.]{3}\d', item.address), node_ips))[0].address
|
||||||
|
Loading…
Reference in New Issue
Block a user