Initial commit: add .gitignore and README

This commit is contained in:
defiQUG
2026-02-09 21:51:46 -08:00
commit b970b4fc51
52 changed files with 3362 additions and 0 deletions

30
event-bus/nats/install.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
# Install NATS Event Bus
set -e
NAMESPACE="event-bus"
echo "📡 Installing NATS Event Bus..."
# Check prerequisites
command -v kubectl >/dev/null 2>&1 || { echo "❌ kubectl not found"; exit 1; }
# Create namespace
echo "📦 Creating namespace: $NAMESPACE"
kubectl create namespace "$NAMESPACE" --dry-run=client -o yaml | kubectl apply -f -
# Apply deployment
echo "🚀 Deploying NATS..."
kubectl apply -f k8s-deployment.yaml
# Wait for StatefulSet
echo "⏳ Waiting for NATS to be ready..."
kubectl wait --for=condition=ready --timeout=300s pod -l app=nats -n "$NAMESPACE"
echo "✅ NATS Event Bus installed successfully!"
echo ""
echo "📝 Access NATS monitoring:"
echo " kubectl port-forward -n $NAMESPACE svc/nats 8222:8222"
echo " Then visit: http://localhost:8222"

View File

@@ -0,0 +1,96 @@
# NATS Server Kubernetes Deployment
apiVersion: v1
kind: Namespace
metadata:
name: event-bus
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nats-config
namespace: event-bus
data:
nats.conf: |
port: 4222
http_port: 8222
jetstream:
store_dir: /data/jetstream
max_mem: 2GB
max_file: 10GB
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: nats
namespace: event-bus
spec:
serviceName: nats
replicas: 3
selector:
matchLabels:
app: nats
template:
metadata:
labels:
app: nats
spec:
containers:
- name: nats
image: nats:2.10-alpine
args:
- -c
- /etc/nats/nats.conf
ports:
- name: client
containerPort: 4222
- name: cluster
containerPort: 6222
- name: monitor
containerPort: 8222
volumeMounts:
- name: config
mountPath: /etc/nats
- name: data
mountPath: /data/jetstream
resources:
requests:
memory: "512Mi"
cpu: "200m"
limits:
memory: "1Gi"
cpu: "500m"
volumes:
- name: config
configMap:
name: nats-config
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: standard
resources:
requests:
storage: 10Gi
---
apiVersion: v1
kind: Service
metadata:
name: nats
namespace: event-bus
spec:
clusterIP: None
ports:
- port: 4222
targetPort: 4222
name: client
- port: 6222
targetPort: 6222
name: cluster
- port: 8222
targetPort: 8222
name: monitor
selector:
app: nats

41
event-bus/nats/nats.yaml Normal file
View File

@@ -0,0 +1,41 @@
# NATS Server Configuration
port: 4222
http_port: 8222
cluster:
port: 6222
routes:
- nats://nats-1:6222
- nats://nats-2:6222
- nats://nats-3:6222
jetstream:
store_dir: /data/jetstream
max_mem: 2GB
max_file: 10GB
logging:
time: true
debug: false
trace: false
logtime: true
log_file: "/var/log/nats/nats.log"
log_size_limit: 100MB
authorization:
users:
- user: api-user
password: ${NATS_API_PASSWORD}
permissions:
publish:
- ">"
subscribe:
- ">"
- user: service-user
password: ${NATS_SERVICE_PASSWORD}
permissions:
publish:
- "events.>"
subscribe:
- "events.>"