- A pod can have multiple containers
- All containers inside a Pod share the same network stack, which includes the following
- IP Address
- Network interfaces
- Routing tables
- Ports
- Every pod has a unique IP address and all containers inside a pod have the same IP address as that of the pod and that is why the containers inside the same pod are able to talk to each other using localhost
- If two containers within the same Pod attempt to bind to the same port, it will result in a conflict
- Here is an example from a yaml file where the "containerPort"s are the ports which tell kubernetes that the respective applicaton is running inside the container on this port, so when someone wants to access this application, they will have to make a call to the same port number on the Pod and then the Pod will forward the request to the same port number on the container, by default the ports on the pod are mapped to the same port numbers in contianers
spec: containers: - name: eggplantsui image: realneeleshsharma/eggplantsui:latest ports: - containerPort: 3000 - name: eggplantsapi image: realneeleshsharma/eggplantsapp:latest ports: - containerPort: 5000- Because of the above mentioned way of port mapping from containers to pods, we must take care of any port conflicts that may occur while deploying applications inside containers to pods
Pods that are running inside Kubernetes are running on a private, isolated network. By default they are visible from other pods and services within the same Kubernetes cluster, but not outside that network Every Pod has a unique IP address And it is reachable from all other Pods in the K8s cluster A pod is a host, just like your laptop, having an ip-address and a range of ports that can be alloted to containers A container runs on a specific port inside a pod In a Kubernetes environment, when services are deployed within the same namespace , they can communicate with each other using the service name as the hostname e.g. in the following snippet from appsetting.json form a .net core project, ' document-api' is the name of the service "DocumentApiConfiguration" : { "BaseUrl" : "http://document-api/" } What if I want to access a service from another namespace? When you want to access a service from another namespace in Kubernetes, you typica...

Comments
Post a Comment