How to use node IP address for Pod
search cancel

How to use node IP address for Pod

book

Article ID: 410470

calendar_today

Updated On:

Products

VMware vSphere Kubernetes Service

Issue/Introduction

In Kubernetes Pod will get IP address from its own isolated network namespace by default. For some purposes the Pod need to use the IP address the host node where it is running. This article is to discuss how to let pod obtain the node's IP address.

Environment

vSphere Kubernetes Service

Resolution

To use IP address of node other than isolated namespace for Pod, specify the setting 'hostNetwork: true' in the yaml of Pod. 

For example:

apiVersion: v1
kind: Pod
metadata:
  name: <pod-name>
  namespace: <pod-namespace>
spec:
  hostNetwork: true
  containers:
  - name: <container-name>
    image: <image-name>

Additional Information