Documentation
Logging Pod in default ns (ecommerce-app)
apiVersion: v1 kind: Pod metadata: name: ecommerce-logger spec: containers:
- name: ecommerce-log-generator
image: busybox
resources:
limits:
cpu: 500m
memory: 500Mi
requests:
cpu: 500m
memory: 500Mi
args:
-
/bin/sh
-
-c
-
| while true; do timestamp=$(date '+%Y-%m-%d %H:%M:%S') user="user$((RANDOM % 4 + 1))" action_num=$((RANDOM % 6)) product=""
case $action_num in 0) action="Login";;
- action="Logout";;
- action="Cart Added"; product=$(echo "Product: Laptop");;
- action="Buy Item"; product=$(echo "Product: Phone");;
- action="Search Item";;
- action="Checkout";; esac
if [ -n "$product" ]; then echo "$timestamp | $user | $action | $product" else echo "$timestamp | $user | $action" fi
sleep $((RANDOM % 5 + 1)) done
-
Logging Pod in default ns (payment-app)
apiVersion: v1 kind: Pod metadata: name: payment-logger spec: containers:
- name: payment-log-generator
image: busybox
resources:
limits:
cpu: 500m
memory: 500Mi
requests:
cpu: 500m
memory: 500Mi
args:
-
/bin/sh
-
-c
-
| while true; do timestamp=$(date '+%Y-%m-%d %H:%M:%S') user="user$((RANDOM % 10 + 1))" order_id="order$((RANDOM % 100 + 1))" transaction_id="txn$((RANDOM % 1000 + 1))" action_num=$((RANDOM % 8))
case $action_num in 0) echo "$timestamp | INFO | User: $user | Action: User logged in";;
- echo "$timestamp | INFO | User: $user | Action: Payment initiated | Order ID: $order_id | Transaction ID: $transaction_id";;
- echo "$timestamp | SUCCESS | User: $user | Action: Payment completed | Order ID: $order_id | Transaction ID: $transaction_id";;
- echo "$timestamp | WARNING | User: $user | Action: Payment pending | Order ID: $order_id";;
- echo "$timestamp | ERROR | User: $user | Action: Payment failed | Order ID: $order_id | Reason: Insufficient funds";;
- echo "$timestamp | INFO | User: $user | Action: Logout";;
- echo "$timestamp | INFO | User: $user | Action: Order confirmed | Order ID: $order_id";;
- echo "$timestamp | INFO | User: $user | Action: Cart cleared";; esac
sleep $((RANDOM % 5 + 1)) done
-