今日已更新 312 条资讯 | 累计 30356 条内容
关于我们

Deploy ReplicaSet in Kubernetes Cluster

janak0ff 2026年08月11日 14:42 2 次阅读 来源:Dev.to

The Nautilus DevOps team is gearing up to deploy applications on a Kubernetes cluster for migration purposes. A team member has been tasked with creating a ReplicaSet outlined below: Create a ReplicaSet using nginx image with latest tag (ensure to specify as nginx:latest ) and name it nginx-replicaset . Apply labels: app as nginx_app , type as front-end . Name the container nginx-container . Ensure the replica count is 4 . Solution Step 1: Generate the ReplicaSet YAML First, let's generate a base ReplicaSet manifest: kubectl create replicaset nginx-replicaset \ --image = nginx:latest \ --dry-run = client -o yaml > nginx-replicaset.yaml Step 2: Edit the YAML to Add Requirements Open the file and modify it according to the requirements: nano nginx-replicaset.yaml Update the file with: Replica count: 4 Labels: app: nginx_app , type: front-end Container name: nginx-container Here's the complete YAML: apiVersion : apps/v1 kind : ReplicaSet metadata : name : nginx-replicaset labels : app : nginx_app type : front-end 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 ports : - containerPort : 80 Step 3: Apply the ReplicaSet Create the ReplicaSet in your cluster: kubectl apply -f nginx-replicaset.yaml Expected output: replicaset.apps/nginx-replicaset created Step 4: Verify the ReplicaSet Check that the ReplicaSet was created successfully: kubectl get replicasets Expected output: NAME DESIRED CURRENT READY AGE nginx-replicaset 4 4 4 10s Step 5: Verify Pods Check that 4 pods were created: kubectl get pods Expected output: NAME READY STATUS RESTARTS AGE nginx-replicaset-xxxxx 1/1 Running 0 15s nginx-replicaset-yyyyy 1/1 Running 0 15s nginx-replicaset-zzzzz 1/1 Running 0 15s nginx-replicaset-wwwww 1/1 Running 0 15s Step 6: Verify Labels Check that the labels are correctly applied: kubectl get replicaset nginx-replicaset --s

本文内容来源于互联网,版权归原作者所有
查看原文