Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
10 views

Module 6 - Kubernetes

Uploaded by

Jeff Deep
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Module 6 - Kubernetes

Uploaded by

Jeff Deep
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Container Orchestration [ Kubernetes ]

AGENDA
Introduction to Kubernetes

Kubernetes Architecture

Kubernetes Installation

Creating a Deployment in Kubernetes Using YAML

Services in Kubernetes

Ingress in Kubernetes
INTRODUCTION TO
KUBERNETES

© Copyright. All Rights Reserved.


INTRODUCTION TO KUBERNETES

Kubernetes is an open-source container orchestration software.

It was originally developed by Google.

It was first released on July 21, 2015.


It is the ninth most active repository on GitHub in terms of number
of commits.

© Copyright. All Rights Reserved.


FEATURES OF KUBERNETES

Pods Service Discovery

Replication Controller Networking

Storage Management Secret Management

Resource Monitoring Rolling Updates

Health Checks

© Copyright. All Rights Reserved.


KUBERNETES
ARCHITECTURE

© Copyright. All Rights Reserved.


KUBERNETES ARCHITECTURE

Master Node

Slave Node Slave Node Slave Node

© Copyright. All Rights Reserved.


KUBERNETES ARCHITECTURE

Master Node Docker

etcd API Server Scheduler

Controller Manager

Slave Node Slave Node Slave Node


Docker Docker Docker

Kubelet Kube-proxy Kubelet Kube-proxy Kubelet Kube-proxy

© Copyright. All Rights Reserved.


KUBERNETES ARCHITECTURE:
MASTER COMPONENTS

© Copyright. All Rights Reserved.


KUBERNETES ARCHITECTURE: MASTER COMPONENTS

It is a highly available distributed key–value store, which is used to


store cluster wide secrets. It is only accessible by the Kubernetes
etcd
API server, as it has sensitive information.

API Server

Scheduler
Master Node Docker

etcd API Server Scheduler


Controller Manager
Controller Manager

© Copyright. All Rights Reserved.


KUBERNETES ARCHITECTURE: MASTER COMPONENTS

It exposes Kubernetes API. Kubernetes API is the front-end for the


etcd Kubernetes Control Plane and is used to deploy and execute all
operations in Kubernetes.

API Server

Scheduler
Master Node Docker

etcd API Server Scheduler


Controller Manager
Controller Manager

© Copyright. All Rights Reserved.


KUBERNETES ARCHITECTURE: MASTER COMPONENTS

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

etcd API Server Scheduler


Controller Manager
Controller Manager

© Copyright. All Rights Reserved.


KUBERNETES ARCHITECTURE: MASTER COMPONENTS

The controller manager runs all controllers on the Kubernetes cluster.


Although each controller is a separate process, to reduce complexity, all
controllers are compiled into a single process. They are as follows:
etcd Node Controller, Replication Controller, Endpoints Controller, Service
Accounts and TokenControllers.

API Server

Scheduler
Master Node Docker

etcd API Server Scheduler


Controller Manager
Controller Manager

© Copyright. All Rights Reserved.


KUBERNETES ARCHITECTURE:
SLAVE COMPONENTS

© Copyright. All Rights Reserved.


KUBERNETES ARCHITECTURE: SLAVE COMPONENTS

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

Kube-proxy Slave Node


Docker

Kubelet Kube-proxy

© Copyright. All Rights Reserved.


KUBERNETES ARCHITECTURE: SLAVE COMPONENTS

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

Kube-proxy Slave Node


Docker

Kubelet Kube-proxy

© Copyright. All Rights Reserved.


KUBERNETES
INSTALLATION

© Copyright. All Rights Reserved.


KUBERNETES INSTALLATION

There are numerous ways to install Kubernetes. Following are some of the popular ways:

▪ Kubeadm: Bare Metal Installation

▪ Minikube: Virtualized Environment for Kubernetes

▪ Kops: Kubernetes on AWS

▪ Kubernetes on GCP: Kubernetes running on Google Cloud Platform

© Copyright. All Rights Reserved.


HANDS-ON: INSTALLING
KUBERNETESUSING
KUBEADM

© Copyright. All Rights Reserved.


WORKING OF
KUBERNETES

© Copyright. All Rights Reserved.


WORKING OF KUBERNETES

Pod – Replica 1

Pod – Replica 2

Pods can have one or more containers coupled


together. They are the basic unit of Kubernetes.
To increase high availability, we alwaysprefer
pods to be in replicas. Pod – Replica 3

© Copyright. All Rights Reserved.


WORKING OF KUBERNETES

Services are used to load balance the traffic


among the pods. It follows round-robin
distribution among the healthy pods.

Pod – Replica 1

Service

Pod – Replica 2

Pod – Replica 3

© Copyright. All Rights Reserved.


WORKING OF KUBERNETES

Pod – Replica 1
Image Processing

Service
Pod – Replica 2

Demo.com/image

Pod – Replica 3
Ingress

demo.com/video
Pod – Replica 1

An Ingress is an object that allows access to


your Kubernetes services from outside the Service
Kubernetes cluster. You can configure access by Video Processing Pod – Replica 2

creating a collection of rules that define which


inbound connections reach which services.
Pod – Replica 3

© Copyright. All Rights Reserved.


DEPLOYMENTS IN
KUBERNETES

© Copyright. All Rights Reserved.


DEPLOYMENTS IN KUBERNETES

Deployment in Kubernetes is a controller which helps your applications reach the


desired state; the desired state is defined inside the deployment file.

Deployment

Pods

© Copyright. All Rights Reserved.


YAML SYNTAX FOR DEPLOYMENTS
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
This YAML file will deploy 3 pods for nginx and matchLabels:
app: nginx
will maintain the desired state, which is 3 pods, template:
until this deployment is deleted. metadata:
labels:
app:nginx
spec:
containers:
- name: nginx
image:nginx:1.7.9
ports:
- containerPort:80

© Copyright. All Rights Reserved.


CREATING A DEPLOYMENT

Once the file is created, to deploy this deployment use the following syntax:

Syntax
kubectl create –f nginx.yaml

© Copyright. All Rights Reserved.


LISTING THE PODS

To view the pods, type the following command:

Syntax
kubectl get po

As you can see, the number of pods are matching with the number of replicas specified in the deployment file.

© Copyright. All Rights Reserved.


CREATING A
SERVICE

© Copyright. All Rights Reserved.


CREATING A SERVICE

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

© Copyright. All Rights Reserved.


SERVICE TYPES

ClusterIP: Exposes the service on cluster-internal IP

NodePort: Exposes the service on each Node’s IP at a static port

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

© Copyright. All Rights Reserved.


CREATING A NODEPORT SERVICE
We can create a NodePort service using the following syntax:

Syntax
kubectl create service nodeport <name-of-service> --tcp=<port-of-service>:<port-of-container>

© Copyright. All Rights Reserved.


CREATING A NODEPORT SERVICE
To know the port, on which the service is being exposed, type the following command:

Syntax
kubectl get svc nginx

© Copyright. All Rights Reserved.


CREATING AN
INGRESS

© Copyright. All Rights Reserved.


WHAT IS AN INGRESS?

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

© Copyright. All Rights Reserved.


WHAT IS AN INGRESS?

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

© Copyright. All Rights Reserved.


INSTALLING INGRESS CONTROLLER

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

© Copyright. All Rights Reserved.


DEFINING INGRESS RULES

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

© Copyright. All Rights Reserved.


DEPLOYING INGRESS RULES

To deploy ingress rules, we use the following syntax:

Syntax
kubectl create –f ingress.yaml

© Copyright. All Rights Reserved.


VIEWING INGRESS RULES

To list the ingress rules we use the followingsyntax:

Syntax
kubectl get ing

© Copyright. All Rights Reserved.


© Copyright. All Rights Reserved.

You might also like