DEV Community

Cover image for 7.Deploy ReplicaSet in Kubernetes Cluster
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

7.Deploy ReplicaSet in Kubernetes Cluster

Lab Information

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 httpd image with latest tag (ensure to specify as httpd:latest) and name it httpd-replicaset.

Apply labels: app as httpd_app, type as front-end.

Name the container httpd-container. Ensure the replica count is 4.
Enter fullscreen mode Exit fullscreen mode

Note: The kubectl utility on jump_host is set up to interact with the Kubernetes cluster.

Lab Solutions

Step 1: Create the ReplicaSet YAML Configuration

Create a file named httpd-replicaset.yaml:

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: httpd-replicaset
  labels:
    app: httpd_app
    type: front-end
spec:
  replicas: 4
  selector:
    matchLabels:
      app: httpd_app
      type: front-end
  template:
    metadata:
      labels:
        app: httpd_app
        type: front-end
    spec:
      containers:
      - name: httpd-container
        image: httpd:latest
        ports:
        - containerPort: 80
Enter fullscreen mode Exit fullscreen mode

Step 2: Apply the ReplicaSet

Apply the ReplicaSet configuration

kubectl apply -f httpd-replicaset.yaml
Enter fullscreen mode Exit fullscreen mode

Step 3: Verification

Check if ReplicaSet was created:

kubectl get replicaset httpd-replicaset
Enter fullscreen mode Exit fullscreen mode

Check the pods created by the ReplicaSet:

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

Get detailed information about the ReplicaSet:

kubectl describe replicaset httpd-replicaset
Enter fullscreen mode Exit fullscreen mode


Resources & Next Steps
📦 Full Code Repository: KodeKloud Learning Labs
📖 More Deep Dives: Whispering Cloud Insights - Read other technical articles
💬 Join Discussion: DEV Community - Share your thoughts and questions
💼 Let's Connect: LinkedIn - I'd love to connect with you

Credits
• All labs are from: KodeKloud
• I sincerely appreciate your provision of these valuable resources.

Top comments (0)