100 lines
2.9 KiB
YAML
100 lines
2.9 KiB
YAML
# Phase 6.6: Kubernetes Job to Create kmsvc Topics
|
|||
|
|
# This Job runs once to create required Kafka topics
|
||
|
|
# Can be re-run if topics need to be recreated
|
||
|
|
|
||
|
|
apiVersion: batch/v1
|
||
|
|
kind: Job
|
||
|
|
metadata:
|
||
|
|
name: create-poimen-memory-kmsvc-topics
|
||
|
|
namespace: poimen
|
||
|
|
labels:
|
||
|
|
app: poimen-memory
|
||
|
|
phase: "6.6"
|
||
|
|
spec:
|
||
|
|
backoffLimit: 3
|
||
|
|
activeDeadlineSeconds: 600
|
||
|
|
template:
|
||
|
|
metadata:
|
||
|
|
labels:
|
||
|
|
app: poimen-memory
|
||
|
|
job: create-kmsvc-topics
|
||
|
|
spec:
|
||
|
|
serviceAccountName: memory-app
|
||
|
|
restartPolicy: Never
|
||
|
|
containers:
|
||
|
|
- name: create-topics
|
||
|
|
image: curlimages/curl:latest
|
||
|
|
imagePullPolicy: IfNotPresent
|
||
|
|
|
||
|
|
command:
|
||
|
|
- /bin/sh
|
||
|
|
- -c
|
||
|
|
- |
|
||
|
|
set -e
|
||
|
|
|
||
|
|
echo "Creating kmsvc topics for Poimen Memory..."
|
||
|
|
|
||
|
|
# Wait for management-service to be ready
|
||
|
|
echo "Waiting for management-service to be ready..."
|
||
|
|
for i in {1..30}; do
|
||
|
|
if curl -s http://management-service.sqs.svc.cluster.local:8080/v1/queues > /dev/null 2>&1; then
|
||
|
|
echo "management-service is ready"
|
||
|
|
break
|
||
|
|
fi
|
||
|
|
echo "Attempt $i/30: Waiting for management-service..."
|
||
|
|
sleep 2
|
||
|
|
done
|
||
|
|
|
||
|
|
# Create poimen-memory-dlq
|
||
|
|
echo "Creating topic: poimen-memory-dlq"
|
||
|
|
curl -X POST http://management-service.sqs.svc.cluster.local:8080/v1/queues \
|
||
|
|
-H "Content-Type: application/json" \
|
||
|
|
-d '{
|
||
|
|
"name": "poimen-memory-dlq",
|
||
|
|
"fifoQueue": false,
|
||
|
|
"visibilityTimeoutSeconds": 300,
|
||
|
|
"messageRetentionPeriodSeconds": 1209600
|
||
|
|
}' || echo "Topic may already exist"
|
||
|
|
|
||
|
|
# Create poimen-memory-metric-dlq
|
||
|
|
echo "Creating topic: poimen-memory-metric-dlq"
|
||
|
|
curl -X POST http://management-service.sqs.svc.cluster.local:8080/v1/queues \
|
||
|
|
-H "Content-Type: application/json" \
|
||
|
|
-d '{
|
||
|
|
"name": "poimen-memory-metric-dlq",
|
||
|
|
"fifoQueue": false,
|
||
|
|
"visibilityTimeoutSeconds": 300,
|
||
|
|
"messageRetentionPeriodSeconds": 1209600
|
||
|
|
}' || echo "Topic may already exist"
|
||
|
|
|
||
|
|
# List queues
|
||
|
|
echo "Listing all queues:"
|
||
|
|
curl http://management-service.sqs.svc.cluster.local:8080/v1/queues
|
||
|
|
|
||
|
|
echo "Done!"
|
||
|
|
|
||
|
|
resources:
|
||
|
|
requests:
|
||
|
|
cpu: "50m"
|
||
|
|
memory: "64Mi"
|
||
|
|
limits:
|
||
|
|
cpu: "100m"
|
||
|
|
memory: "128Mi"
|
||
|
|
|
||
|
|
securityContext:
|
||
|
|
allowPrivilegeEscalation: false
|
||
|
|
readOnlyRootFilesystem: true
|
||
|
|
runAsNonRoot: true
|
||
|
|
runAsUser: 1000
|
||
|
|
|
||
|
|
---
|
||
|
|
# ServiceAccount for the job (reuse memory-app SA)
|
||
|
|
# If not exists, create it:
|
||
|
|
apiVersion: v1
|
||
|
|
kind: ServiceAccount
|
||
|
|
metadata:
|
||
|
|
name: memory-app
|
||
|
|
namespace: poimen
|
||
|
|
labels:
|
||
|
|
app: poimen-memory
|