Kubernetes PDF
Document Details
Uploaded by AccessibleOxygen8704
BCIT
Tags
Summary
This document provides an overview of Kubernetes, a platform for automating deployment, scaling, and management of containerized applications. It explains concepts like containers, container orchestration, Kubernetes components, and commands. This document is a comprehensive introduction to Kubernetes, designed for understanding and learning.
Full Transcript
Containers A container is a lightweight, stand-alone, executable package of software that includes everything needed to run it: code, runtime environment, system tools, system libraries and settings. Containers isolate software from it’s surroundings It reduces conflict betwe...
Containers A container is a lightweight, stand-alone, executable package of software that includes everything needed to run it: code, runtime environment, system tools, system libraries and settings. Containers isolate software from it’s surroundings It reduces conflict between teams running different software on the same infrastructure Why Container Orchestration Container orchestration manages the availability, scaling and networking of containers. It helps in monitoring the cluster i.e., group of hosts It helps in managing the timing of container creations It helps in container configuration in order to allow containers to communicate with one another Container Orchestration The top 3 Container Orchestrators What is Kubernetes? It’s an open source orchestration system which is used for: Deployment of containerized applications Scaling of containerized applications Management of containerized applications Features of Kubernetes Advantages of Kubernetes Kubernetes Cluster Architecture Kubernetes Cluster Components Master Node: Cluster master manages the Kubernetes API Server, resource controller and scheduler. It’s life cycle is managed by Kubernetes engine when starting Worker Node: Worker node previously known as minions maybe a physical machine or a virtual machine based on the cluster Pods: Pods are group of containers which are tightly coupled together. This is done, when the containers are dependent on each other. Kubernetes Master Kube-apiserver: It validates and configures all the data for the API objects which includes pods, services, replica controllers, and others Kube-controller-manager: It’s a daemon that includes the non terminating loops (that regulates the state of the system) shipped with Kubernetes Etcd: It’s a distributed key-value store designed to reliably and quickly preserve and provide access to critical data Kube-scheduler: The Kubernetes scheduler is a work-load specific function that significantly impacts availability, performance, and capacity. Workload-specific requirements will be exposed through the API as required. Kubernetes Worker Nodes Kubelet: It’s a foremost node agent running on each node works under the terms of PodSec. A PodSec is a YAML or JSON object that describes a pod Kube-Proxy: Kubernetes network proxy runs on each node Container Runtime: The container runtime is the software that is responsible for running containers. Kubernetes supports several runtimes: Docker, rkt, runc and any OCI runtime-spec implementation Master vs Worker Nodes Kubernetes Pods Containers are deployed and scheduled through Kubernetes in a group called Pods. These are tightly coupled containers i.e. the applications running on them are dependent on each other 1 to 5 tightly coupled containers can be stored in a pod that collaborate to provide a service Kubectl Introduction It’s a Kubernetes command line tool which is used to deploy and manage applications on Kubernetes It helps in inspecting the Kubernetes cluster resources By using Kubectl, we can create, delete, and update components on Kubernetes cluster Kubectl Minikube How Kubectl works Monolith vs Microservices Deployment in Kubernetes Deployment can be defined to create new replicasets It can also be defined to remove the existing deployment and use all their resources with new Deployments Selector field defines how the pods management sequence is determined by deployment ReplicaSet A replicaSet makes sure that stated number of pod replicas are running at any instant of time It can be scaled up or down ReplicaSet controller ensures that a desired number of pods with a matching label selector are available and operational Services in Kubernetes Services act like load balancers in Kubernetes, they also have an IP address. This IP address automatically route to healthy pods. In case the pods becomes unhealthy the service automatically routes to next healthy pod. Hence, with this the user will interact with only one IP address. Services in Kubernetes Services define the logical set of pods and the policy through which they will be accessed They are the abstractions, and sometimes called as micro-services Label selectors determines the set of pods to be targeted by services Namespaces Namespaces are intended for use in environments with many users spread across multiple teams, or projects. Namespaces provide a scope for names. Names of resources need to be unique within a namespace, but not across namespaces. Namespaces cannot be nested inside one another and each Kubernetes resource can only be in one namespace. Namespaces are a way to divide cluster resources between multiple users. It is not necessary to use multiple namespaces just to separate slightly different resources, such as different versions of the same software: use labels to distinguish resources within the same namespace. Labels Labels are key/value pairs that are attached to objects, such as pods. Labels can be used to organize and to select subsets of objects. Labels can be attached to objects at creation time and subsequently added and modified at any time. Each object can have a set of key/value labels defined. Each Key must be unique for a given object. Labels enable users to map their own organizational structures onto system objects in a loosely coupled fashion. Commands kubectl cluster-info kubectl get nodes kubectl get pods kubectl get pods -o wide kubectl get pods --watch kubectl get svc kubectl get deployments kubectl get replicaset kubectl describe pods kubectl run tomcat --image tomcat:8.0 --port=8080 Commands kubectl delete pod tomcat kubectl expose pod tomcat --name=tomcat-svc --target-port=8080 -- type=NodePort kubectl delete service tomcat-svc kubectl create deployment app1 --image aldiab/webapp kubectl scale deployment app1 --replicas 3 kubectl expose deployment app1 --type LoadBalancer --port 80 --target-port 8080 kubectl delete deployment app1 Commands kubectl get namespace kubectl get pods --namespace=ns1 kubectl create namespace ns1 kubectl get pods --show-labels kubectl run nginx --image=nginx --namespace=ns1 kubectl create -f https://k8s.io/examples/admin/namespace-dev.json kubectl get pods -l 'env in (production, development)' kubectl get pods -l env=development kubectl run nginx --image=nginx --namespace=ns1 kubectl label pods tomcat label3=healty kubectl label --overwrite pods tomcat status=unhealthy