Is there a way to distinguish two pods that have turned on hostnetwork by IP or DNS?

12/4/2018

I have yaml file. It creates two deployments, both pods inside turned on the hostnetwork.

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: busybox
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: busybox
    spec:
      hostNetwork: true
      hostname: busybox-1
      subdomain: default-subdomain
      containers:
      - image: busybox
        command:
          - sleep
          - "3600"
        name: busybox

---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: influxdb-deployment
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: influxdb-deployment
    spec:
      hostNetwork: true
      containers:
      - name: influxdb-deployment
        image: influxdb

In this case, the pods will have the same clusterIP or DNS name. I want to connect the PODs by DNS or IP, and use SNMP to monitor their CPU metrics; but the problem is that, the IP or DNS cannot distinguish the two PODs anymore, cause it always goes to the host. Is there any solution for this case?

-- Howard
hostnetwork
kubernetes

0 Answers