Azure Kubernetes Service
Azure Kubernetes Service
Azure Kubernetes
Service
The BIG Picture
Notes based on
Pluralsight course
'm
Traditional software Development
Mondi Build Package Deploy Migrate
Cif hardware
Present dhiomsenices fails ]
Independent ,
Distributed ,
etc .
Horizontal vs .
Vertical scaling !
Scale
specific features of the service !
Explore the
pros
and cons of mionoserrices ?
"
we need automation which includes automatic
,
scheduling ,
automatic
configuration .
Supervision
and failure handling "
.
Srihari Sridharan
@asksrihari needs
Microsomes > Containers
need
<
Orchestration
⑥ Containers 101
Containers
lightweight design of
a
j process
isolation of an operating
system .
Containers us . Virtualization
Filesystems
process
User Ids
Ids
} Single
Namespace
Network Interfaces
one
namespace of each hind .
Namespace kinds
Mount lmnt ) Network Cnet)
process ED fpid)
( " P" User ID cases)
Srihari Sridharan
Inter process UTS
communication
@asksrihari determines
⑨ Uts namespace what
Answer :
Cgnonps > Control Groups
Linux kernel feature that limits the resource
usage of a
process Cora
group of processed
than the
A process cannot use more
bandwidth and so on .
from hogging
Cgnonps prevent processes
resources reserved for other processes .
Srihari Sridharan
@asksrihari Platform for packaging distributing
,
and
>
Host isolation
v
packaging Experience
application and
its dependencies BENEFITS
Offers
<
, Images are
Images ✓
much smaller
compared
Namespaces to
and cgnoupsto um
offer isolation
and resource controls
Images
the the
the
image
contains filesystem and
Registries
D-
Docker registry is a repository that stores
container
is
Aomning container process running a on
② What is kubernetes ?
Allows you to
easily deploy and manage containerized
applications on
top of it .
Exposes the
underlying infrastructure as a
API server
Kubeeet
Scheduler
Kuba Proxy
Controller
Container Runtime
etcd
Srihari Sridharan
@asksrihari
Running Applications in k8S
1.
Package your appln .
into one or more containers
available workers
s '
deployment
Better hardware utilization
Health monitoring and self healing
Automatic scaling .
⑥ kubemetes Objects
Knbectl < <object > tressure name >
operation >
< optional
flags >
Pod_ Smallest hint that KSS
manages
Made up of one or more containers
Any container
running within a
pod will
share the Node 's network with other
any
containers in the same pod
containers within a pod can share files
to containers
through volumes ,
attached .
A pod has an
explicit lifecycle and will
remain in a node it was started .
Namespaces
Pods are collected into namespaces , which
are used to group
Pods .
If no
namespace
is mentioned KSS assumes
Nodes
Node is a machine that is added to
Srihari Sridharan
@asksrihari the brain of less
The master node is
network .
Controllers
Desired state
deployment
controllers are the brain behind this
by a
deployment
Srihari Sridharan
.
@asksrihari
Deployment Recommended way to om
code on Kss
✓
Wraps around and extends the
replica set
Services Kgs to
resource used
provide an
Can contain a
policy .
Emulates a
software load balances within
kubernetes .
② What is AKS ?
Self hosting Kss cluster
Need to consider
Manually install the
master and worker high availability
nodes .
of the master ,
adding additional
LOT OF WORK ! worker nodes ,
patching upgrades. ,
etc
Handled by .
L
Aks
Srihari Sridharan
@asksrihari
Aks .
Deployment ,
management and operations of
kubernetes
Provisioning ,
upgrading
and
scaling on
demand .
Master node is
managed by Azure
Offload responsibility to Azure
Pay for agents only
Benefits
and
• Version upgrades patching
cluster
•
Easy scaling
o self healing hosted control plane ( master)
cost
☐
savings
kss
⑧ Beyond managed
Think about the of cloud
ecosystem the
vendor .
Azure container
Registry ( ACR)
infrastructure
underlying
Easily start
deploying containers for
"
targeted usecases .
and execute
your application
Dockeoize
'
it in one click .
ACR
Repository for container
images .
cloud scale .
Srihari Sridharan
@asksrihari
2. Ahs in Action
https://githnb.csmlmanojnair/myapp
Docker images
https :/I hwb.dscher.am/r1monojnair1myappltags
Run
p 8081 : 80
manojnairlmyapp : v1
visit http://lscalhost : 8081
✓ and V4 in 8082,8083
V2 V3
Similarly run ,
and 8084
NOTE : You can use the ones above or
postal /
RG aks rgl
-
various blades in
create KSS cluster
< postal
Basic Node Pools Authentication / Networking
,
I Better to Integration
me
RBAC : enable
> Look at
Network > Azure CNI course
In Azure CLI
az account show
az configure - -
Set RG
forsubsequent AKS credentials name <cluster
AZ
get
- - -
ciscommanas
name>
<
Fetch the c
Whatever you used
it into current
merge
context .
Srihari Sridharan
@asksrihari
② Deploy the application to Ahs cluster
imperatively .
Kss
management techniques .
Imperative -
for development how learning
commands
projects more
Imperative Moderate
object configuration
-
for production
projects learning
curve
Declarative
object -
for production high learning
came
configuration projects
This sample uses imperative approach
commands
Kubectl create deployment myapp
image Manoj nair / myapp v1
-
-
=
:
replicas =\
- -
Service
Srihari Sridharan
@asksrihari
knbectl expose deployment my app
-
-
port
= 80
target port = 80
- -
-
- -
^
Before running the above command
enabled .
To scale
deployments
Kubectl scale deployment myapp - -
replicas =3
Pods
" "
name
agentpool query
Max
-
- -
-
these
many pods for your application as
Srihari Sridharan
@asksrihari
Knbectl babe system
get pods namespace
-
- -
to scale nodes
az aks scale
- -
resource
-
group aks -
rgl
-
-
name ahsdemol
- -
nodecsont 2
- -
no - wait
,
returns immediately we
query [ count ,
provisioning
kubeete nodes
use
get
Srihari Sridharan
@asksrihari
⑤ Updating the application
Rollout
Manage the rollout of a resource
usage
Kubectl rollout SUBCSMMAND
the
Describe deployment
Method I
kurbectl set image
deployment /my app
myapp
=
manojnairlmyapp : v2
- -
record = true
repeatedly ,
then you will basically keep
toggling between the last 2 deployments .
Srihari Sridharan
@asksrihari
IMPORTANT NOTE
new item in
history and removes the
old entry .
Chis explains why it keeps
between last two notbnts when
swapping
we undo twice or more ]
⑥
Using declarative approach to
deploy
lcubeonetes objects
myapp2.y.nl
api version :
apps / v1
kind :
Deployment
metadata ;
name :
my app 2
labels :
app :
my app 2
spec :
replicas :3
selector :
matchlabels :
app :
my app 2
template :
metadata :
labels :
app : my app 2
spec :
containers :
Srihari Sridharan
@asksrihari -
name :
myapp2
image :
mansjnairlmyapp : v2
pools : n
-
container Post : so
- -
>
-
Pod
Api version : v1 image
separator kind : service
for
multiple metadata :
resources in
a file
name :
myappz
spec :
posts :
-
protocol : Tep
80
post :
targetPost : 80
Ihubectl apply -
f. lmyappziyml
To clean -
up
kubectl delete deployment myapp
Kubectt delete service my app
Srihari Sridharan
@asksrihari
① Pushing the images to ACB
Azure
L
Container
Registry
ACRT Aks -
Best of both worlds !
ACR
Create in
postal or
using IAC .
Registry .name ,
location .
SKU ,
>
Basic
s Premium
Stock
/ keeping
azurecr.io unit
registry - name .
.
eg .
to pull
AKS agent pool nodes need permission
images from ACR .
myappaorol.azureor.io/myapp:viazaor
login -
-
name =
myappaoro
'
image
=
myappacrol.azurecr.io/myapp:v1
n
- -
target post 80 - =
--
post = So
Image is
securely stored in ACR !
Srihari Sridharan
@asksrihari
Next steps
Srihari Sridharan