Kubernetes network config

7/3/2019

Precondition: the kubernetes cluster have 1 master and 2 worker. The cluster uses one CIDR for all nodes. Question: how to configure network to pod on worker1 can communicate with pod on worker2?

-- Thai Nguyen
kubernetes

2 Answers

7/3/2019

A kubernetes cluster consists of one or more nodes. A node is a host system, whether physical or virtual, with a container runtime and its dependencies (i.e. docker mostly) and several kubernetes system components, that is connected to a network that allows it to reach other nodes in the cluster. A simple cluster of two nodes might look like this:

enter image description here

enter image description here

You can find more answers here

When the cluster use one CIDR for all nodes, the pod will be assigned ip address from one subnet.

-- Le Khiem
Source: StackOverflow

7/3/2019

Kubernetes has its own service discovery and you can use define service for communicate. If you want to communicate or send request to worker2 then you have to define a service for worker2. Suppose you have a worker add-service and you want to communicate with it, then you have to define a service for add-service worker like below

apiVersion: v1
kind: Service
metadata:
  name: add-service
spec:
  selector:
    app: add
  ports:
    - port: 3000
      targetPort: add-service

Then from worker1 you can user add-service to communicate and kuberntes will use service discovery to find the exact worker. Here is a hackernoon detail article about how to create pod, deployment, service and communicate with between them.

-- Shalauddin Ahamad Shuza
Source: StackOverflow