Zookeeper Deployment Task
This tutorial provides a hands-on problem to solve. It is designed for students and junior DevOps engineers who are learning to translate service requirements into functional Kubernetes manifests. By completing this task, you will create a valid Kubernetes Deployment and an associated Service for Apache Zookeeper.
Following this guide will give you practical experience in configuring key aspects of a Kubernetes deployment and exposing it for network access, a critical skill for managing containerized applications.
In this tutorial, you will be tasked to:
Analyze a set of deployment and service requirements for Zookeeper.
Complete a skeleton YAML file for the Deployment.
Create a YAML file for the Service.
Prepare the manifests needed to deploy Zookeeper to the cluster.
Before you start
Make sure that:
You are SSHed into the
k3smainnode.You have switched to the shared user account.
Part 1: Create the Zookeeper Deployment Manifest
Your first goal is to create a Kubernetes deployment file named zookeeper-deployment.yaml. This deployment will run the Zookeeper pods and must meet a specific set of operational requirements.
Deployment Requirements
The Zookeeper instance must be configured with the following specifications:
Node Affinity: The pod must only be scheduled to run on the node named
k3smain.Container Image: Use the latest
bitnami/zookeeperimage.Networking: The container must expose port
2181.Configuration: To simplify the setup, Zookeeper must be configured to allow anonymous logins.
Storage: Zookeeper needs a path to store its data. For this simulation, it should use a non-persistent, ephemeral volume mounted at
/bitnami/zookeeper.Resource Management: The container must be configured with specific resource requests and limits.
Requests: 256Mi of memory and 0.2 CPU.
Limits: 512Mi of memory and 0.5 CPU.
Skeleton File
To get you started, here is a skeleton zookeeper-deployment.yaml file. It is your job to fill in the missing values based on the requirements listed above.
Part 2: Expose Zookeeper with a Service
Now that you have a Deployment, you need to create a stable network endpoint for it so other applications can find and communicate with the Zookeeper pods. Your second goal is to create a zookeeper-service.yaml file.
Service Requirements
The Service must:
Have the name
zookeeper-service.Forward traffic from its port
2181to thetargetPort2181on the pods.Use a
selectorto correctly identify the Zookeeper pods managed by your Deployment. This selector must match the labels on the pods.
Skeleton File for Service
Create a second file named zookeeper-service.yaml. Fill in the missing values in the skeleton below to provide the stable network endpoint that other applications (like Kafka) will use to communicate with Zookeeper.
PArt 3: Deployment verification
Once you have created and completed both zookeeper-deployment.yaml and zookeeper-service.yaml, you need to apply them to the cluster.
Verify the deployment: Check that the Zookeeper pod is running successfully.
Check zookeeper logs for error
Hint: The pod name is obtained from the previous command.