Kubernetes Introduction
Monolithic Architecture
Micro Services Architecture
Monolithic Vs. Micro Services Architecture
Containers Overview
Container Orchestration Engines
Managed Kubernetes Services
Kubernetes Architecture
Kubernetes Cluster Setup
POD Management
Replication Controller
ReplicaSet Controller
Deployment Controller
Kubernetes Services
Configure aws-provider on kubernetes cluster
Load Balancer service on Kubernetes
116 Followers
Create manifest file for Replica Set
Create "CreateReplicaSet.yaml" file with below manifest definitions
#Replica Set with Set-Based Selectors
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: nginx-rs
spec:
replicas: 5
selector:
matchLabels:
app: nginx-app
matchExpressions:
- {key: tier, operator: IN, values: [frontend]}
template:
name: nginx-pod
labels:
app: nginx-app
tier: frontend
spec:
containers:
- name: nginx-container
image: nginx
ports:
- containerPort: 80Deploy Replica Set
[root@ ~]$kubectl apply -f CreateReplicaSet.yaml
replicaset.apps/nginx-rs created
[root@ ~]$Verify running PODs in the cluster
[root@ ~]$kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-rs-6p274 1/1 Running 0 33s
nginx-rs-pfbfd 1/1 Running 0 33s
nginx-rs-w6xv6 1/1 Running 0 33s
[root@ ~]$kubectl get po
NAME READY STATUS RESTARTS AGE
nginx-rs-6p274 1/1 Running 0 39s
nginx-rs-pfbfd 1/1 Running 0 39s
nginx-rs-w6xv6 1/1 Running 0 39s
[iwayQ@ ~]$
Verify running Replica Set in the cluster
[root@ ~]$kubectl get rs
NAME DESIRED CURRENT READY AGE
nginx-rs 3 3 3 60s
[root@ ~]$kubectl get rs -o wide
NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR
nginx-rs 3 3 3 64s nginx-container nginx app=nginx-app,tier in (frontend)
[root@ ~]$kubectl get rs nginx-rs
NAME DESIRED CURRENT READY AGE
nginx-rs 3 3 3 73s
[root@ ~]$Describe running Replica Set properties and events
[root@ ~]$kubectl describe rs nginx-rs
Name: nginx-rs
Namespace: default
Selector: app=nginx-app,tier in (frontend)
Labels: <none>
Annotations: Replicas: 3 current / 3 desired
Pods Status: 3 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
Labels: app=nginx-app
tier=frontend
Containers:
nginx-container:
Image: nginx
Port: 80/TCP
Host Port: 0/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 104s replicaset-controller Created pod: nginx-rs-w6xv6
Normal SuccessfulCreate 104s replicaset-controller Created pod: nginx-rs-pfbfd
Normal SuccessfulCreate 104s replicaset-controller Created pod: nginx-rs-6p274
[root@ ~]$
Scale Out POD replicas manged by Replica Set
[root@ ~]$kubectl scale rs nginx-rs --replicas=5
replicaset.apps/nginx-rs scaled
[root@ ~]$kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-rs-6p274 1/1 Running 0 2m38s
nginx-rs-lqdcg 1/1 Running 0 6s
nginx-rs-pfbfd 1/1 Running 0 2m38s
nginx-rs-vbmqg 1/1 Running 0 6s
nginx-rs-w6xv6 1/1 Running 0 2m38s
[root@ ~]$
Scale In POD replicas managed by Replica Set
[root@ ~]$kubectl scale rs nginx-rs --replicas=3
replicaset.apps/nginx-rs scaled
[root@ ~]$kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-rs-6p274 1/1 Running 0 2m59s
nginx-rs-lqdcg 0/1 Terminating 0 27s
nginx-rs-pfbfd 1/1 Running 0 2m59s
nginx-rs-vbmqg 0/1 Terminating 0 27s
nginx-rs-w6xv6 1/1 Running 0 2m59s
[root@ ~]$kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-rs-6p274 1/1 Running 0 3m9s
nginx-rs-pfbfd 1/1 Running 0 3m9s
nginx-rs-w6xv6 1/1 Running 0 3m9s
[iwayQ@ ~]$
Delete Replica Set
[root@ ~]$kubectl delete rs nginx-rs
replicaset.apps "nginx-rs" deleted
[root@ ~]$kubectl get rs
No resources found in default namespace.
[root@ ~]$kubectl get pods
No resources found in default namespace.
[root~]$