17
kubernete s

Kubernetes Basics

Embed Size (px)

Citation preview

Page 1: Kubernetes Basics

kubernetes

Page 2: Kubernetes Basics

THE NEED FOR CONTAINER ORCHESTRATION Docker packaging, deploying and running containerized application applications are independent of the underlying OS architecture.

Docker itself can be used to manage a few containers running on a fewer machines. Production applications deploy containers on a large scale on hundreds of machines.

Page 3: Kubernetes Basics

THE NEED FOR CONTAINER ORCHESTRATION

PHYSICAL INFRASTRUCURE

VM VM VM VMVM VM VMVM

CLUSTER CLUSTER

CLUSTERCLUSTERCLUSTER

CLUSTER MANAGER

Page 4: Kubernetes Basics

WHAT IS KUBERNETES A subset of an internal Google project called Borg. Decouples application from machines through containers. Maintains and tracks the global view of the cluster. Distributed architecture with master and multiple worker nodes. Developed in Go language. Automate the scaling and distribution of applications.

Page 5: Kubernetes Basics

K8S FEATURES Horizontal scaling – with command or based on CPU usage. Self-healing – restart containers that fail or don`t respond to health check. Replaces and reschedules containers when nodes die. Automating binpacking – placing the containers based on their resource requirements thus saving system resource. Automated rollouts and rollbacks - If something goes wrong, Kubernetes will rollback the changes. Storage orchestration – mount the storage system of your choice from local storage or AWS or from a network storage system.

Page 6: Kubernetes Basics

KUBERNETES ARCHITECTURE

XML file

JSON file

YAML file

Page 7: Kubernetes Basics

KUBERNETES COMPONENTS Master - coordinates the cluster Cluster - set of physical or virtual machines and other infrastructure resources used by Kubernetes to run your applications. Nodes – hosts that run kubernetes applications. Pod - a co-located group of containers and volumes. Unit of deployment. Label -  a key/value pair for identification. Replication Controller – ensures/maintains availability and scalability. etcd – maintains state.

Page 8: Kubernetes Basics

CREATING A CLUSTER A k8s cluster consists of two types of resources The Master coordinates the clusterNodes are the workers that runs application.The nodes communicate with the master using the KubernetesAPI, which the master exposes.

Page 9: Kubernetes Basics

CREATE A DEPLOYMENT A Deployment is responsible for creating and updating instances of application. The Deployment controller replaces an instance if the Node hosting it goes down or it is deleted.

Page 10: Kubernetes Basics

PODS AND NODES A Pod is a group of one or more application containers and includes shared storage (volumes), IP address and information about how to run them.

Page 11: Kubernetes Basics

PODS AND NODES Every Kubernetes Node runs at least:Kubelet, a process responsible for communication between the Kubernetes Master and the Nodes

A container runtime (like Docker, rkt).

Page 12: Kubernetes Basics

SERVICES Provides external access to a single or group of pods.

Page 13: Kubernetes Basics

SCALING

Page 14: Kubernetes Basics

BASIC COMMANDS Clusterminikube startkubectl cluster-infokubectl get nodes

Deploymentkubectl run kubernetes-bootcamp --image=docker.io/jocatalin/kubernetes-bootcamp:v1 --port=8080

kubectl get deployments Pods kubectl get podskubectl describe podskubectl proxy

Page 15: Kubernetes Basics

BASIC COMMANDS Pods export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')

echo Name of the Pod: $POD_NAMEkubectl logs $POD_NAMEkubectl exec -ti $POD_NAME bash

Serviceskubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080kubectl get serviceskubectl describe services/kubernetes-bootcampexport NODE_PORT=$(kubectl get services/kubernetes-bootcamp -o go-template='{{(index .spec.ports 0).nodePort}}') echo NODE_PORT=$NODE_PORT

minikube service kubernetes-bootcamp

Page 16: Kubernetes Basics

BASIC COMMANDS Scalingkubectl scale deployments/kubernetes-bootcamp --replicas=4kubectl get deploymentskubectl get pods -o wide

Updating image kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=jocatalin/kubernetes-bootcamp:v2

minikube service kubernetes-bootcampkubectl get pods