Why Kubernetes ?
Why Kubernetes ?
Kubernetes lets you deploy containers on a cluster(set of nodes(instances
)). It is able to load balance traffic to containers and distribute the network traffic so that the deployment is stable.
-
How Does Kubernetes do it ?
For a stable deployment, kubernetes first creates a service with a fixed IP Address for your pods.A service is the fundamental way Kubernetes represents load balancer(Network LB with public IP). It groups set of pods together and provides a stable endpoint for them.
By default pods in your deployment are only accessible in your cluster so to allow access over the internet, connect a load balancer and then kubernetes will create the service:
$ kubectl expose deployments nginx --port=port --type=loadbalancer
- To get service:
$ kubectl get services
- Any client that hits the service
ExternalIP
will be routed to the pods behind the service.
- Any client that hits the service
- To get service:
-
Why do you need a service for a stable IP (Internet Protocol)?
Since deployment create and destroy pods, the internal pods may not be stable, so a service to a stable IP is a better way to manage connections. -
Extra Notes:
- Use declarative commands like
config files
to scale your deployments so you can update anytime and apply the new changes. - To avoid downtime while your app redeploys, use an update strategy (eg.
RollingUpdate
). - To view replicas:
$ kubectl get replicasets
- To see active pods:
$ kubectl get pods
- To check deployments:
$ kubectl get deployments
- Use declarative commands like