This document provides step-by-step instructions for testing the Task API after deploying it to Kubernetes.
- Kubernetes cluster running (Docker Desktop, Minikube, etc.)
- kubectl configured to connect to your cluster
- Task API and MongoDB deployed using the provided manifests
# Get the NodePort for the Task API service
kubectl get svc task-apiNote the NodePort (e.g., 31234) and use it in the following commands.
curl -X PUT http://localhost:<NODE_PORT>/tasks \
-H "Content-Type: application/json" \
-d '{
"id": "123",
"name": "Print Hello",
"owner": "John Smith",
"command": "echo Hello World!"
}'Expected response: A JSON object with the task details.
curl -X PUT http://localhost:<NODE_PORT>/tasks/123/executeExpected response: A JSON object with the task details including the execution results.
# Check if a pod was created for the task execution
kubectl get pods | grep task-execExpected result: You should see a pod with a name starting with "task-exec" (it might be in "Completed" state).
curl http://localhost:<NODE_PORT>/tasks?id=123Expected response: A JSON object with the task details including the execution results.
# Delete the MongoDB pod to test persistence
kubectl delete pod -l app=mongodb
# Wait for the pod to be recreated
kubectl get pods -l app=mongodb
# Get the task to verify data persistence
curl http://localhost:<NODE_PORT>/tasks?id=123Expected result: The task data should still be available after the MongoDB pod is recreated.
# For the Task API pod
kubectl logs -l app=task-api
# For the MongoDB pod
kubectl logs -l app=mongodb
# For a specific task execution pod
kubectl logs <task-exec-pod-name>kubectl describe pod -l app=task-api
kubectl describe pod -l app=mongodbkubectl get pv
kubectl get pvcMake sure to capture screenshots of:
- The kubectl commands showing the running pods
- The curl command output showing a successful API response
- The pod list showing a task execution pod created by the API
These screenshots will serve as proof that your application is correctly deployed to Kubernetes and functioning as required.