Kubernetes Pizza Observability is a main-character energy project serving up pizza orders when your Kubernetes cluster's CPU usage exceeds a threshold. It combines infrastructure monitoring with real-world actions, demonstrating a fun and practical application of observability principles.
- Monitoring: Prometheus continuously monitors CPU usage in your Kubernetes cluster
- Alerting: When CPU usage exceeds 80% for 5 minutes, AlertManager triggers an alert
- Processing: An Azure Function receives the alert and prepares a pizza order
- Confirmation: Slack allows users to confirm or cancel order
- Ordering: The system places an order with Domino's Pizza API
- Tracking: The pizza order status is tracked through Kubernetes custom resources
Kubernetes Cluster
βββ Workloads (Pods, Deployments, etc.)
βββ Prometheus (Monitoring)
βββ Grafana (Visualization & Alerting)
βββ AlertManager (Alert Routing)
βββ Azure Function (Alert Handler)
βββ PizzaOrder CRD (Custom Resource Definition)
βββ Slack App (Order Confirmation)
- Prometheus & Grafana: Monitors cluster metrics and visualizes CPU usage
- AlertManager: Routes alerts to the Azure Function
- Azure Function: Processes alerts and creates pizza orders
- Pizza Controller: Kubernetes controller that manages PizzaOrder custom resources
- Slack App: Provides a user interface for confirming pizza orders
- Kubernetes cluster (AKS, GKE, EKS, or local like Minikube/Kind)
- Helm 3.x
- kubectl configured to access your cluster
- Docker and Docker Compose (for local development)
-
Deploy Kubernetes Cluster
You can use the Terraform configuration in the
terraformdirectory to deploy an AKS cluster:cd terraform terraform init terraform apply -
Deploy with Helm
# Add Prometheus Helm repository helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update # Install the chart helm install k8s-pizza helm/k8s-pizza-observability-chart
-
Configure Pizza Delivery Information
Create a values override file with your delivery information:
cat > pizza-values.yaml << EOF dominosPayment: cardType: "Credit" cardNumber: "4100123456789010" cardExpiration: "01/25" cardSecurityCode: "123" cardPostalCode: "90210" azureFunction: env: CUSTOMER_FIRST_NAME: "Pizza" CUSTOMER_LAST_NAME: "Lover" CUSTOMER_EMAIL: "pizza@example.com" CUSTOMER_PHONE: "1234567890" DELIVERY_STREET: "123 Main St" DELIVERY_CITY: "Anytown" DELIVERY_STATE: "NY" DELIVERY_ZIP: "10001" PIZZA_SIZE: "large" PIZZA_TYPE: "pepperoni" EOF helm upgrade k8s-pizza helm/k8s-pizza-observability-chart -f pizza-values.yaml
-
Verify Installation
# Check that all pods are running kubectl get pods # Access Grafana dashboard kubectl port-forward svc/k8s-pizza-grafana 3000:80
Visit http://localhost:3000 and log in with username
adminand passwordpizza123.
To test the system without waiting for actual high CPU usage:
# Send a test alert
kubectl apply -f kubernetes/pizza-test-alert.jsonNote: The complete end-to-end workflow could not be tested in real-time because the Domino's Pizza API works primarily in the US and Canada. The system is designed to work with the API but may require adjustments based on your location.
Below is a visual representation of how the testing workflow operates outside the US and Canada:
- Generate Test Alert: Use the test alert JSON to simulate high CPU usage
- Alert Processing: The alert is processed by AlertManager and forwarded to the Azure Function
- Order Creation: A PizzaOrder custom resource is created in the Kubernetes cluster
- Slack Notification: A notification is sent to Slack for order confirmation
- Mock API Call: For testing outside US/Canada, the API call is mocked
- Status Updates: The Pizza Controller updates the order status in the cluster
In the US and Canada, the system would work with the actual Domino's Pizza API, resulting in real pizza deliveries:
- High CPU Detection: Prometheus detects high CPU usage in the cluster
- Alert Triggering: AlertManager triggers an alert when CPU exceeds threshold
- Order Processing: The Azure Function processes the alert and creates an order
- User Confirmation: Slack notification allows users to confirm the order
- Pizza Ordering: The Pizza Controller places a real order with Domino's API
- Status Tracking: Order status is tracked in the Kubernetes cluster
- Pizza Delivery: A real pizza is delivered to your specified address
For a complete test in supported regions, replace the mock API call with an actual Domino's API call.
For local development without a Kubernetes cluster:
# Build and start all components
docker-compose up -d
# View logs
docker-compose logs -fβββ azure-function/ # Azure Function for processing alerts
βββ docs/ # Documentation and diagrams
βββ helm/ # Helm chart for Kubernetes deployment
βββ kubernetes/ # Kubernetes manifests and samples
β βββ controller/ # Pizza Order controller implementation
β βββ crds/ # Custom Resource Definitions
β βββ samples/ # Sample resources
βββ scripts/ # Utility scripts
βββ slack/ # Slack app for order confirmation
βββ terraform/ # Infrastructure as Code for cloud deployment
Each directory contains its own README with detailed information.
The Azure Function receives alerts from Prometheus/AlertManager and creates PizzaOrder custom resources in the Kubernetes cluster. See the Azure Function README for more details.
The Pizza Order Controller is a Kubernetes controller that manages PizzaOrder custom resources. It processes orders by finding the nearest Dominos store, creating an order, and tracking its status. See the Controller README for more details.
The Helm charts provide a streamlined way to deploy all components of the system. See the Helm README for more details on configuration options.
The Terraform configuration creates the necessary cloud infrastructure for the project. See the Terraform README for more details on deployment options.
The Slack app provides a user interface for receiving notifications and confirming pizza orders. See the Slack README for more details on setup and configuration.
- Prometheus not receiving metrics: Check that the Prometheus service can reach your pods
- AlertManager not sending alerts: Verify the AlertManager configuration and webhook URL
- Azure Function not processing alerts: Check the function logs and environment variables
- Pizza Controller not creating orders: Ensure the controller has the necessary permissions
- Slack app not receiving notifications: Verify the webhook URL and app configuration
Check component logs for detailed error information:
# Azure Function logs
az functionapp log tail --name pizza-order-function --resource-group pizza-function-rg
# Pizza Controller logs
kubectl logs -f deployment/pizza-controller
# Slack app logs
kubectl logs -f deployment/slack-app- Store sensitive information (like payment details) in Kubernetes Secrets
- Use HTTPS for all external communications
- Implement proper authentication for the Azure Function
- Consider using a service mesh for additional security features
Contributions are welcome! Please feel free to submit a Pull Request.
This project is unlicensed.