Kubernetes Pods accessible from outside cluster

  docker, kubernetes, nginx

I have two Kubernetes clusters. I have run an Nginx server pod on one cluster. Its pod IP is 10.40.0.1. When I ping 10.40.0.1 from this cluster nodes it can ping easily from any node of this cluster.

when I ping from the second cluster node to the first cluster pod it is not working. How should I make a pod so, that it is accessible from the second cluster node as well?

I have deployed Nginx server with the below YAML file.

apiVersion: v1     

kind: Pod

metadata:          
  name: Serverpod  
spec:               
  containers:
  - name: Nginx  
    image: nginx:latest 
    ports:               
    - containerPort: 80
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/hostname
            operator: In
            values:
            - Node1

I have tried the hostnetwork: true but it is not working well.

Source: Docker Questions

LEAVE A COMMENT