From 176ebfd47107b56673f0b2d808f8d06253b3d200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Mon, 23 Apr 2018 13:51:33 +0200 Subject: [PATCH] k8s inventory: add pod nodeport (#39107) Node port field is not populated on K8S pods, and it's certainely the most useful port to use in pod when we need to interact with ansible outside of the cluster --- lib/ansible/module_utils/k8s/inventory.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/k8s/inventory.py b/lib/ansible/module_utils/k8s/inventory.py index 9cc4301758f..c8c48c39c0b 100644 --- a/lib/ansible/module_utils/k8s/inventory.py +++ b/lib/ansible/module_utils/k8s/inventory.py @@ -212,7 +212,8 @@ class K8sInventoryHelper(object): ports = [{'name': port.name, 'port': port.port, 'protocol': port.protocol, - 'targetPort': port.target_port} for port in service.spec.ports] + 'targetPort': port.target_port, + 'nodePort': port.node_port} for port in service.spec.ports] # add hostvars self.inventory.set_variable(service_name, 'object_type', 'service')