I'm setting up an gke nodeport service and want to...
# python
w
I'm setting up an gke nodeport service and want to add the new node_port to a firewall rule, so the default health check works. I'm trying to get the port like this:
my_nodeport = my_svc.spec.apply(lambda p: p.ports[0]['node_port'])
But this failes with an
KeyError: 'node_port'
in outputs.py. It works, if I first create the NodePort and create the firewall in a second run. I would like to avoid setting a fixed node_port in the service. Is there a way to do that?
w
Try putting the ‘my_svc…apply’ block directly in the firewall rule declaration where you currently reference my_nodeport.