Show Menu
Cheatography

Kubernetes (k8s) Cheat Sheet by

Kubernetes (k8s)

Basics

Define :it is a container management technology developed by GOOGLE (later made open source in 2015) to manage contai­nerized applic­ati­on(­orc­hes­tra­tion).

Why

1.Service discovery and load balancing 1.Service discovery and load balancing
2.Auto­mated rollbacks
3.Self­-he­aling
4.Auto Scaling
5.Canary updates and Rolling updates
6.Open source & Community driven
7.High Availa­bility

Kubernetes Concepts

Node
machine in the cluster
Docker
helps in creation of containers that includes apps and its binaries.
Pods
A Pod is the basic building block of Kubern­­et­e­s–the smallest and simplest unit in the Kubernetes object model that you create or deploy,is also a group of containers (1 or more).Only containers of same pod can share shared storage.
Service
is an abstra­­ction which defines a logical set of Pods and a policy by which to access them.
Jobs
Creates pod(s) and ensures that a specified number succes­­sfully comple­ted.When a specified number of successful run of pods is completed, then the job is considered complete.
Cronjob
job scheduler in K8s
Repli­­casets
ensures how many replica of pod should be running.
Names­­paces
Logical seperation between teams and thier enviro­nme­nts.It allows various teams(­Dev­,Prod) to share k8s cluster by providing isolated workspace.
Deployment
Desired state of pods for declar­­ative updates
daemonset
ensures a particular pod to be run on some or all nodes
persis­­te­n­t­volume
Persistent storage in the cluster with an indepe­­ndent lifecycle.
persis­­te­n­t­vo­­lum­­eclaim
Request for storage (for a Persi­­ste­­nt­V­o­lume) by a user
ingress
An Ingress is a collection of rules that allow inbound connec­­tions to reach the cluster services.

Namespaces

kubectl get all --all-­nam­espaces
shows all objects of all namespaces
kubectl get pods --all-­nam­espaces
shows pods of all namespaces
kubectl get pods -n <name space>
shows pods of a namespace eg.kubectl get all -n kube-s­ystem :shows objects of system name space
kubectl get namespaces (show all namspaces)
default:default name spaces of user
kube-p­ublic:Namespace for resources that are publicly availa­ble­/re­adable by all
kube-s­ystem:Namespace for object­s/r­eso­urces created by Kubernetes systems
 

Components Archit­ecture Diagram

Components Basic

Components in Manager Nodes:
Controller manager: Runs various contro­llers to help move running state to desired state.
Node Controller: Respon­sible for noticing and responding when nodes go down.
Replic­ation Controller: Respon­sible for mainta­ining the correct number of pods for every replic­ation controller object in the system.
Endpoints Controller: Populates the Endpoints object (i.e, joins Services & Pods).
Service Account & Token Contro­llers: Create default accounts and API access tokens for new namesp­aces.
Scheduler: Watches newly created pods that have no node assigned, and selects a node for them to run on.
Api Server:The front-end for the Kubernetes control plane. It is designed to scale horizo­nta­lly.Every other component contact with this to commun­icate.
Etcd Cluster: key/value backing store for cluster data,it stores state of the cluster (what nodes exist in the cluster, what pods should be running, which nodes they are running on, and a whole lot more) at any given point of time.
Components in Worker Nodes:
Kubelet:Agent that contin­uously watches API server. It makes sure that containers are running in a pod.
Kube-proxy: a proxy service that runs on each worker node to deal with individual host subnetting and expose services to the external world. It performs request forwarding to the correct pods/c­ont­ainers across the various isolated networks in a cluster.

Various Ways of installing K8s

minikube
single node cluster
kubeadm
multinode cluste­r(d­oesn't support kubenet, hence require CNI[co­ntainer network interface] plugin eg. flannel.
GKE
multi node
Important: The network must be deployed before any applic­ations. Also, CoreDNS will not start up before a network is installed. kubeadm only supports Container Network Interface (CNI) based networks (and does not support kubenet).

Output format in get

-o wide
width wise details output
-o yaml
details output in yaml format
-o json
details output in json format
                   
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          kenv使用方法 Cheat Sheet
          Docker & Swarm 2022 Cheat Sheet
          Docker basics Cheat Sheet

          More Cheat Sheets by gauravpandey44