- each Pod has only 1 IP, irrespective of the number of containers.
- all containers in a Pod shares IP, cgroups, namespaces, localhost adapter, volumes
- every pod can interact directly with another pod via Pod N/W (Inter-Pod communication)
there are two types of communication in pods
- Inter-pod
- Intra-pod - every container in a pod can interact with each other via a shared localhost interface
---
apiVersion: v1 kind: Pod metadata: name: myapp labels: zones: prod version: v1 spec: containers: - name: app-container image: punitporwal07/myapp:0.1 ports: - containerPort: 8000 ...
$ kubectl create -f pod.yaml
$ kubectl describe pods (checks status)
NOTE: we don't work directly on pods
so we use a replication controller to manage the container inside a pod, which implements the desired state
get your sample replcationController.yml
get your sample replcationController.yml
Now big question is, how do we access our pods ? Service is the answer.
1. accessing outside the cluster (Browser, client)
2. accessing inside the cluster (How Pods interact with each other)
services nail both the above
2. accessing inside the cluster (How Pods interact with each other)
services nail both the above
every service gets a name and IP which are STABLE! which means name and this IP will never change throughout its life.
services are REST objects in K8s, service stands infront of Pod so that outside world can interact to Pods via service. service never changes means its IP, DNS, Ports are reliable, unlike Pods which are unreliable in nature.
services are REST objects in K8s, service stands infront of Pod so that outside world can interact to Pods via service. service never changes means its IP, DNS, Ports are reliable, unlike Pods which are unreliable in nature.
Service use Labels to identify the Pods and do the things on them.
now since pods are mortal and they come and go, so how do service identify which pods are alive. so Its Endpoint which maintains the list of available pods dynamically and let service know about the active pods.$ kubectl create -f svc.yml
$ kubectl get svc
$ kubectl describe svc -myapp-svc
$ kubectl expose rc myapp-rc --name=myapp-svc --taget-port=8000 --type=NodePort (this way it will expose the service hello-svc)
$ kubectl describe svc myapp-svc (describes the service with all its meaningful attributes like port, Namespace, labels etc.)
Deployment is about updates and rollbacks this is the superset of replication controller and can access deployment via node pod service
for example, deployment.yml may look like
--- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: myapp-deployspec:
replicas: 5template:
metadata:
labels: app: prod spec: containers: - name: myapp-container image: punitporwal07/myapp:0.1 ports: - containerPort: 8000 ...
at last be declarative!
$ kubectl create -f <manifest.yaml>
check in to source control > make changes to same file > apply change with
$ kubectl apply --record
No comments:
Post a Comment