PDF 13-Yaml Files
PDF 13-Yaml Files
Kubernetes
CloudIQ
Writing
YAML Files
Deploying Kubernetes Objects
CloudIQ
POD Deployment
Containers
Control Plane
POD
POD Name: metadata.name+<Random#>
Deployment Object POD IP: 178.89.55.34
Scheduler Name POD Label app: corpwebsite
metadata.name
Worker Node 2
API Server
etcd
Calico CNI plugin
Deployment
Object
Containers
Control
Manager
POD
POD Name: metadata.name+<Random#>
POD IP: 172.36.23.25
POD Label app: corpwebsite
Worker Node 2
API Server
etcd
Deployment
Object
Containers
Control
Manager
POD
POD Name: metadata.name+<Random#>
Replicas Set POD IP: 172.36.23.25
Desired = 2
Current =2 POD Label app: corpwebsite
POD Label:
app: corpwebsite Worker Node 1
CloudIQ
POD Network Access
Containers Containers
POD POD
POD IP: 172.36.23.25
POD IP: 178.89.55.34
Containers Containers
Node IP Node IP
Kubernetes
Traffic Route: Service Object
Internet > Node IP > POD IP NodePort
How to write?
● Write all in a SINGLE YAML File
● Write 2 separate YAML Files (Recommended)
CloudIQ
YAML Skeleton
kind: Deployment When writing YAML files for Kubernetes, there are four
apiVersion: required fields that must be present.
metadata: APIVersion
name:
labels: Deployment Identification
Kind
label:
Metadata
spec:
replicas: Specifications
strategy: Pod Behaviour
selector:
matchLabels:
label:
template:
metadata:
labels: Pod Identification
label:
spec:
containers:
- name: Container Identification
image:
CloudIQ
POD Deployment
apiVersion: apps/v1
kind: Deployment
spec:
selector: ● How many Replicas?
matchLabels:
app: pod-corpwebsite ● Group these Replicas using the
replicas: 2
particular POD LABEL
template:
metadata:
labels:
● POD LABELs
app: pod-corpwebsite
env: dev
spec:
containers:
- name: container-corpwebsite ● Container Specs
image: tanvisinghny/ssl-website
ports:
- containerPort: 80
- containerPort: 443
CloudIQ
Service Deployment
apiVersion: v1
kind: Service
spec:
type: NodePort ● Service Type: NodePort, Load
selector: Balancer
app: pod-corpwebsite
165.232.184.39 (443)
resources: resources:
limits: limits:
memory: 200Mi memory: 2G
cpu: 300m cpu: 3
requests: requests: CPU represents computing processing time, measured in
memory: 100Mi memory: 1G
cpu: 100m cores.
cpu: 1
● You can use millicores (m) to represent smaller
amounts than a core (e.g., 500m would be half a
Memory is measured in Kubernetes in bytes:
core)
You can use, E, P, T, G, M, k to represent Exabyte, Petabyte,
Terabyte, Gigabyte, Megabyte and kilobyte ● The minimum amount is 1m
You can define Mebibytes using Mi, as well as the rest as Ei, Pi, ● A Node might have more than one core available, so
Ti (e.g., 500Mi) requesting CPU > 1 is possible
CloudIQ
YAMl File with Resource Limits
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-corpwebsite
spec:
selector:
matchLabels:
app: pod-corpwebsite
replicas: 2
template:
metadata:
labels:
app: pod-corpwebsite
env: dev
spec:
containers:
- name: container-corpwebsite
image: tanvisinghny/ssl-website
ports:
- containerPort: 80
- containerPort: 443
resources:
limits:
memory: 200Mi
cpu: 300m
requests:
memory: 100Mi
cpu: 100m
CloudIQ
POD Resource Limits
Verifying Resource Limits set
Go inside POD:
cd /sys/fs/cgroup/
—--
deployment-corpwebsite-7675c48cc6-6zn5d 1m 7Mi
deployment-corpwebsite-7675c48cc6-rl4sh 1m 7Mi
CloudIQ
Test Metrics Server Installation
view pods resource utilization of your current namespace
deployment-corpwebsite-7675c48cc6-6zn5d 1m 7Mi
deployment-corpwebsite-7675c48cc6-rl4sh 1m 7Mi