7.Deploy ReplicaSet in Kubernetes Cluster

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MyrinNew
    Senior Member
    • Feb 2024
    • 5168

    #1

    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.





    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







    Step 2: Apply the ReplicaSet

    Apply the ReplicaSet configuration





    kubectl apply -f httpd-replicaset.yaml







    Step 3: Verification

    Check if ReplicaSet was created:






    kubectl get replicaset httpd-replicaset







    Check the pods created by the ReplicaSet:






    kubectl get pods







    Get detailed information about the ReplicaSet:






    kubectl describe replicaset httpd-replicaset













    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.






    More...
Working...