Kubernetes
Kubernetes
§ Portable, extensible, open-source platform for managing containerized workloads and services
§ Facilitates both declarative configuration and automation
§ It has a large, rapidly growing ecosystem
§ Kubernetes services, support, and tools are widely available
-
-
dedaoahuecong.g.gg#+
§ Google open-sourced the Kubernetes project in 2014
→ ✗ MI -
✗
✓
→ yami →
json
→ - ✓
=É
server and allows better scalability because
Operating System Operating System
§ an application can be added or updated easily
§ reduces hardware costs
§ With virtualization you can present a set of physical resources Hypervisor
as a cluster of disposable virtual machines
Operating System
§ Each VM is a full machine running all the components,
including its own operating system, on top of the virtualized Hardware
hardware
§ Containers are similar to VMs, but they have relaxed isolation imac
properties to share the Operating System (OS) among the
applications
Container 1 Container a
§ Therefore, containers are considered lightweight =
§ Similar to a VM, a container has its own filesystem, CPU, App App App App App App
÷
memory, process space, and more
Bin/Library Bin/Library
§ As they are decoupled from the underlying infrastructure, they
are portable across clouds and OS distributions
.
Container Runtime
Operating System
Hardware
§ Increased ease and efficiency of container image creation compared to VM image use
=
§ Continuous development, integration, and deployment
§ Dev and Ops separation of concerns
§ Observability not only surfaces OS-level information and metrics, but also application health and other
signals
§ Cloud and OS distribution portability
§ Application-centric management:
§ Loosely coupled, distributed, elastic, liberated micro-services
§ Resource isolation: predictable application performance
E-
§ Kubernetes can expose a container using the DNS name or using their own IP address
§ If traffic to a container is high, Kubernetes is able to load balance and distribute the network traffic so that the
deployment is stable
§ Storage orchestration
§ Kubernetes allows you to automatically mount a storage system of your choice, such as local storages,
public cloud providers, and more
-
§ Self-healing
=
§ Kubernetes restarts containers that fail, replaces containers, kills containers that don’t respond to your user-
- - -
defined health check, and doesn’t advertise them to clients until they are ready to serve
=
-
§ Does not limit the types of applications supported ° " "" "" "
""
t÷#
§ Does not deploy source code and does not build your application
§ Does not provide application-level services as built-in services
§ Does not dictate logging, monitoring, or alerting solutions
§ Does not provide nor mandate a configuration language/system
E-
§ Does not provide nor adopt any comprehensive machine configuration, maintenance, management,
or self-healing systems
..÷ ÷:
§ When you deploy Kubernetes, you get a
cluster.
§ A cluster is a set of machines (nodes), that Master
run containerized applications managed by
Kubernetes
§ A cluster has at least one worker node and
at least one master node
§ The worker node(s) host the pods that are service
the components of the application
§ The master node(s) manages the worker worker I
worker -2
# - __
I Eid -
-1 →
Fo
⑧⑤
⑦
cluster
⑥
⑨
N
RE
/
/ →
↳ client
ˢe↳%% services master
kabeiet
master
women l☒☒
p?•f
¥¥÷±
÷÷÷t
sÉ ÑI
l☒l☒
V
"" "
Kubernetes Components
-
=kube-apiserver
etcd kubelet
E-
kube-scheduler
kube-controller-manager
= kube-proxy
Container Runtime
cloud-controller-manager
==-
§ Master components make global decisions about the and they detect and respond to cluster events
§ Master components can be run on any machine in the cluster
①§ kube-apiserver
§ The API server is a component that exposes the Kubernetes API
§ The API server is the front end for the Kubernetes
②§ etcd
=
- %n
§ Consistent and highly-available key value store used as Kubernetes’ backing store for all cluster data
③§ kube-scheduler
§ Component on the master that watches newly created pods that have no node assigned, -
and selects a node
for them to run on
☐ €
÷÷ ÷÷
Sunbeam Infotech www.sunbeaminfo.com
Master Components
④§ kube-controller-manager
§ Component on the master that runs controllers
§ Logically, each controller is a separate process, but to reduce complexity, they are all compiled into a single
-
§ Types
§ Node Controller: Responsible for noticing and responding when nodes go down.
§ Replication Controller: Responsible for maintaining the correct number of pods for every replication
controller object in the system
§ Endpoints Controller: Populates the Endpoints object (that is, joins Services & Pods)
§ Service Account & Token Controllers: Create default accounts and API access tokens for new
namespaces
§ cloud-controller-manager
§ Runs controllers that interact with the underlying cloud providers
§ The cloud-controller-manager binary is an alpha feature introduced in Kubernetes release 1.6
§ Node components run on every node, maintaining running pods and providing the Kubernetes runtime
=
dingmastFN-I-a.FI
environment
§ kubelet
§ An agent that runs on each node in the cluster
§ It makes sure that containers are running in a pod
§ kube-proxy
§ Network proxy that runs on each node in your cluster, implementing part of the Kubernetes service concept
§ kube-proxy maintains network rules on nodes
§ These network rules allow network communication to your Pods from network sessions inside or outside of
your cluster
§ Container Runtime [ ]
docker
§ The container runtime is the software that is responsible for running containers
a-
§ Kubernetes supports several container runtimes: Docker, containerd, rktlet, cri-o etc.
> sudo apt-get update && sudo apt-get install -y apt-transport-https curl
> curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
> cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list deb https://apt.kubernetes.io/kubernetes-
xenial main EOF
> sudo apt-get update
> sudo apt-get install -y kubelet kubeadm kubectl
> sudo apt-mark hold kubelet kubeadm kubectl
5 join join
4 POD Network
3 initialize
ÉÉ
§ The basic Kubernetes objects include
§ Pod
§ Service
§ Volume
§ Namespace
§ Kubernetes also contains higher-level abstractions build upon the basic objects
§ Deployment
§ DaemonSet
§ StatefulSet
§ ReplicaSet
§ Job
§ The smallest and simplest unit in the Kubernetes object model that you create or deploy
-
E-
§ A Pod encapsulates
§ application’s container (or, in some cases, multiple containers)
§ storage resources
/ app code
Libra
,
§ F-
options that govern how the container(s) should run
our one OR
a pod may
more containers within it .
eg pod / service
→ Specification of object
YAML to create Pod
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
E-
labels:
app: myapp
spec:
containers:
E-=
- name: myapp-container
image: httpd
↓ ↑
cluster
Service
=
=
a network service
§ Service is an abstraction which defines a logical set of Pods and a
policy by which to access them (sometimes this pattern is called a apiVersion: v1
micro-service) kind: Service
metadata:
§ Service Types name: my-service
§ ClusterIP spec:
⇐"÷÷
§ Exposes the Service on a cluster-internal IP selector:
§ Choosing this value makes the Service only reachable from within app: MyApp
the cluster ports:
§ LoadBalancer - protocol: TCP
§ Used for load balancing the containers port: 80
§ NodePort targetPort: 9376
consumes
p
which Pod
port on
gop
used by consumer
"
,
¥±o¥÷:¥!÷:
÷i÷÷÷¥÷±E
http://192.168#T:G446
r
tunnel seoi
°
/
v01
client services
-
-
192.168-1-20
Service Type: NodePort
:#
10.100.2.45
A- E-
Port TargetPort
Service
if
80
32000
80
10.30.4.6
http://#85-3L
NodePort
client =
POD
-
§ On-disk files in a Container are ephemeral, which presents some problems for non-trivial applications
when running in Containers
§ Problems
§ When a Container crashes, kubelet will restart it, but the files will be lost
§ When running Containers together in a Pod it is often necessary to share files between those Containers
§ The Kubernetes Volume abstraction solves both of these problems
§ A volume outlives any Containers that run within the Pod, and data is preserved across Container
restarts
§ 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 can not 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