Thai Nguyen
Thai Nguyen

Reputation: 3

Kubernetes network config

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?

Upvotes: 0

Views: 287

Answers (2)

Le Khiem
Le Khiem

Reputation: 886

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.

Upvotes: 0

Shalauddin Ahamad Shuza
Shalauddin Ahamad Shuza

Reputation: 3657

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.

Upvotes: 2

Related Questions