Module 6 - Kubernetes
Module 6 - Kubernetes
AGENDA
Introduction to Kubernetes
Kubernetes Architecture
Kubernetes Installation
Services in Kubernetes
Ingress in Kubernetes
INTRODUCTION TO
KUBERNETES
Health Checks
Master Node
Controller Manager
API Server
Scheduler
Master Node Docker
API Server
Scheduler
Master Node Docker
The scheduler takes care of scheduling of all processes and the dynamic
resource management and manages present and future events on the cluster.
etcd
API Server
Scheduler
Master Node Docker
API Server
Scheduler
Master Node Docker
Kubelet takes the specification from the API server and ensures that the
application is running according to the specifications which were
mentioned. Each node has its own kubelet service.
Kubelet
Kubelet Kube-proxy
This proxy service runs on each node and helps in making services available
to the external host. It helps in connection forwarding to the correct
resources. It is also capable of doing primitive load balancing.
Kubelet
Kubelet Kube-proxy
There are numerous ways to install Kubernetes. Following are some of the popular ways:
Pod – Replica 1
Pod – Replica 2
Pod – Replica 1
Service
Pod – Replica 2
Pod – Replica 3
Pod – Replica 1
Image Processing
Service
Pod – Replica 2
Demo.com/image
Pod – Replica 3
Ingress
demo.com/video
Pod – Replica 1
Deployment
Pods
Once the file is created, to deploy this deployment use the following syntax:
Syntax
kubectl create –f nginx.yaml
Syntax
kubectl get po
As you can see, the number of pods are matching with the number of replicas specified in the deployment file.
A Service is basically a round-robin load balancer for all pods, which matches with its name or selector. It constantly
monitors the pods; in case a pod gets unhealthy, the service will start deploying the traffic to other healthy pods.
Pod – Replica 1
Service
Pod – Replica 2
Pod – Replica 3
LoadBalancer: Exposes the service externally using a cloud provider’s load balancer
ExternalName: Maps the service to the DNS Name mentioned with the ExternalName service
Pod – Replica 1
Service
Pod – Replica 2
Pod – Replica 3
Syntax
kubectl create service nodeport <name-of-service> --tcp=<port-of-service>:<port-of-container>
Syntax
kubectl get svc nginx
Kubernetes ingress is a collection of routing rules that govern how external users
access services running in a Kubernetes cluster.
Service
demo.com/image
Ingress
demo.com/video
Service
IngressRules
Pod – Replica 1
Service
Pod – Replica 2
ClusterIP
demo.com/video
Pod – Replica 3
Ingress Ingress
Service Controller
demo.com/image
Pod – Replica 1
NodePort
Service
ClusterIP Pod – Replica 2
Pod – Replica 3
We will be using the nginx ingress controller for our demo. We can download it from the following link:
Link
https://github.com/kubernetes/ingress-nginx/blob/master/docs/deploy/index.md
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name:simple-fanout-example
annotations:
The following rule, will redirect traffic which asks for nginx.ingress.kubernetes.io/rewrite-target: /
spec:
/foo to nginx service. All other requests willbe rules:
redirected to ingress controller’s default page. -http:
paths:
- path:/foo
backend:
serviceName: nginx
servicePort: 80
Syntax
kubectl create –f ingress.yaml
Syntax
kubectl get ing