Deploy Replica Set in Kubernetes Cluster
How to Set Up a Replica Set in a Kubernetes Cluster
Tasks
Create a ReplicaSet using the
nginx
image with thelatest
tag (specify asnginx:latest
) and name itnginx-replicaset
.Apply labels:
app
asnginx_app
,type
asfront-end
.Name the container
nginx-container
. Ensure the replica count is4
.
Steps
Create a manifest file name it as
replicaset.yaml
.apiVersion: apps/v1 kind: ReplicaSet metadata: name: nginx-replicaset spec: replicas: 4 selector: matchLabels: app: nginx_app type: front-end template: metadata: labels: app: nginx_app type: front-end spec: containers: - name: nginx-container image: nginx:latest
Now apply the configuration in k8s cluster.
kubectl apply -f replicaset.yaml
Get replicaset
kubectl get replicaset
Check the description of this replicaset.
kubectl describe replicaset nginx-replicaset
#k8s #kubernetes #replicaset