feat: add OSINT Dashboard Kubernetes infrastructure
- Helm chart scaffold (Chart.yaml, values.yaml, _helpers.tpl) - Namespace + RBAC manifests - PostgreSQL (CNPG, 3 replicas, PostGIS + TimescaleDB) - NATS JetStream (3 replicas, persistent, custom subjects) - Redis Sentinel (1 primary + 2 replicas, HA) - MinIO distributed (4 replicas, bucket init job) - Gateway API HTTPRoute + cert-manager TLS certificates - Monitoring stack (Prometheus, Grafana, Alertmanager, exporters) - NetworkPolicies (default deny + per-component policies) - GitHub Actions CI/CD pipeline (lint, template, security scan) - Flux CD staging overlay
This commit is contained in:
parent
36b1d637f1
commit
8255467313
31 changed files with 2818 additions and 0 deletions
|
|
@ -0,0 +1,88 @@
|
|||
{{- if .Values.nats.enabled }}
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: nats-jetstream-init
|
||||
namespace: {{ .Values.namespace }}
|
||||
labels:
|
||||
{{- include "osint-dashboard.labels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: message-broker
|
||||
annotations:
|
||||
"helm.sh/hook": post-install,post-upgrade
|
||||
"helm.sh/hook-delete-policy": hook-succeeded
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "osint-dashboard.selectorLabels" . | nindent 8 }}
|
||||
app.kubernetes.io/component: message-broker
|
||||
spec:
|
||||
restartPolicy: OnFailure
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
containers:
|
||||
- name: nats-box
|
||||
image: "{{ .Values.nats.image.repository }}:{{ .Values.nats.image.tag }}"
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
args:
|
||||
- |
|
||||
# Wait for NATS to be ready
|
||||
until nats-server -version > /dev/null 2>&1 || curl -sf http://nats:{{ .Values.nats.ports.monitor }}/healthz; do
|
||||
echo "Waiting for NATS..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Download nats CLI
|
||||
curl -fsSL https://github.com/nats-io/natscli/releases/latest/download/nats-linux-amd64 -o /tmp/nats
|
||||
chmod +x /tmp/nats
|
||||
|
||||
# Create JetStream stream for events
|
||||
/tmp/nats stream add events \
|
||||
--subjects=events.gdelt,events.rss,events.social,events.earthquake,events.disaster,events.weather,events.fire,events.satellite,events.new,events.alert \
|
||||
--retention=interests \
|
||||
--max-consumers=-1 \
|
||||
--max-msgs=1000000 \
|
||||
--max-bytes=1GB \
|
||||
--discard=old \
|
||||
--storage=file \
|
||||
--replicas=3 \
|
||||
--server=nats://nats:{{ .Values.nats.ports.client }} || echo "events stream already exists"
|
||||
|
||||
# Create JetStream stream for alerts
|
||||
/tmp/nats stream add alerts \
|
||||
--subjects=alerts.camera_offline,alerts.new \
|
||||
--retention=interests \
|
||||
--max-consumers=-1 \
|
||||
--max-msgs=100000 \
|
||||
--discard=old \
|
||||
--storage=file \
|
||||
--replicas=3 \
|
||||
--server=nats://nats:{{ .Values.nats.ports.client }} || echo "alerts stream already exists"
|
||||
|
||||
# Create JetStream stream for video
|
||||
/tmp/nats stream add video \
|
||||
--subjects="video.status.>","video.record.>" \
|
||||
--retention=limits \
|
||||
--max-consumers=-1 \
|
||||
--max-msgs=50000 \
|
||||
--discard=old \
|
||||
--storage=file \
|
||||
--replicas=3 \
|
||||
--server=nats://nats:{{ .Values.nats.ports.client }} || echo "video stream already exists"
|
||||
|
||||
echo "JetStream subjects initialized successfully"
|
||||
resources:
|
||||
requests:
|
||||
cpu: "100m"
|
||||
memory: "64Mi"
|
||||
limits:
|
||||
cpu: "500m"
|
||||
memory: "256Mi"
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
{{- end }}
|
||||
60
apps/base/osint-dashboard/templates/nats/service.yaml
Normal file
60
apps/base/osint-dashboard/templates/nats/service.yaml
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
{{- if .Values.nats.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: nats
|
||||
namespace: {{ .Values.namespace }}
|
||||
labels:
|
||||
{{- include "osint-dashboard.labels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: message-broker
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: {{ .Values.nats.ports.client }}
|
||||
targetPort: {{ .Values.nats.ports.client }}
|
||||
protocol: TCP
|
||||
name: client
|
||||
selector:
|
||||
app.kubernetes.io/name: osint-dashboard
|
||||
app.kubernetes.io/component: message-broker
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: nats-ws
|
||||
namespace: {{ .Values.namespace }}
|
||||
labels:
|
||||
{{- include "osint-dashboard.labels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: message-broker
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: {{ .Values.nats.ports.websocket }}
|
||||
targetPort: {{ .Values.nats.ports.websocket }}
|
||||
protocol: TCP
|
||||
name: websocket
|
||||
selector:
|
||||
app.kubernetes.io/name: osint-dashboard
|
||||
app.kubernetes.io/component: message-broker
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: nats-cluster
|
||||
namespace: {{ .Values.namespace }}
|
||||
labels:
|
||||
{{- include "osint-dashboard.labels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: message-broker
|
||||
annotations:
|
||||
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
|
||||
spec:
|
||||
clusterIP: None
|
||||
ports:
|
||||
- port: {{ .Values.nats.ports.cluster }}
|
||||
targetPort: {{ .Values.nats.ports.cluster }}
|
||||
protocol: TCP
|
||||
name: cluster
|
||||
selector:
|
||||
app.kubernetes.io/name: osint-dashboard
|
||||
app.kubernetes.io/component: message-broker
|
||||
{{- end }}
|
||||
130
apps/base/osint-dashboard/templates/nats/statefulset.yaml
Normal file
130
apps/base/osint-dashboard/templates/nats/statefulset.yaml
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
{{- if .Values.nats.enabled }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: nats-config
|
||||
namespace: {{ .Values.namespace }}
|
||||
labels:
|
||||
{{- include "osint-dashboard.labels" . | nindent 4 }}
|
||||
data:
|
||||
nats-server.conf: |
|
||||
port: {{ .Values.nats.ports.client }}
|
||||
server_name: "osint-nats-${HOSTNAME}"
|
||||
|
||||
# Cluster
|
||||
cluster {
|
||||
port: {{ .Values.nats.ports.cluster }}
|
||||
routes: [
|
||||
nats-route://nats-0.nats-cluster.{{ .Values.namespace }}.svc:{{ .Values.nats.ports.cluster }},
|
||||
nats-route://nats-1.nats-cluster.{{ .Values.namespace }}.svc:{{ .Values.nats.ports.cluster }},
|
||||
nats-route://nats-2.nats-cluster.{{ .Values.namespace }}.svc:{{ .Values.nats.ports.cluster }}
|
||||
]
|
||||
cluster_advertise: "nats-${HOSTNAME}.nats-cluster.{{ .Values.namespace }}.svc:{{ .Values.nats.ports.cluster }}"
|
||||
}
|
||||
|
||||
# JetStream
|
||||
jetstream {
|
||||
store_dir: "{{ .Values.nats.jetstream.fileStore }}"
|
||||
max_mem_store: {{ .Values.nats.jetstream.maxMemory }}
|
||||
max_file_store: {{ .Values.nats.storage.size }}
|
||||
}
|
||||
|
||||
# Monitoring
|
||||
monitor: {{ .Values.nats.ports.monitor }}
|
||||
|
||||
# WebSocket
|
||||
websocket {
|
||||
port: {{ .Values.nats.ports.websocket }}
|
||||
no_tls: true
|
||||
}
|
||||
|
||||
# Logging
|
||||
logtime: true
|
||||
log_file: /var/log/nats/nats.log
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: nats
|
||||
namespace: {{ .Values.namespace }}
|
||||
labels:
|
||||
{{- include "osint-dashboard.labels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: message-broker
|
||||
spec:
|
||||
serviceName: nats-cluster
|
||||
replicas: {{ .Values.nats.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "osint-dashboard.selectorLabels" . | nindent 6 }}
|
||||
app.kubernetes.io/component: message-broker
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "osint-dashboard.selectorLabels" . | nindent 8 }}
|
||||
app.kubernetes.io/component: message-broker
|
||||
annotations:
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/port: "{{ .Values.nats.ports.monitor }}"
|
||||
spec:
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
fsGroup: 1000
|
||||
terminationGracePeriodSeconds: 30
|
||||
containers:
|
||||
- name: nats
|
||||
image: "{{ .Values.nats.image.repository }}:{{ .Values.nats.image.tag }}"
|
||||
ports:
|
||||
- name: client
|
||||
containerPort: {{ .Values.nats.ports.client }}
|
||||
- name: cluster
|
||||
containerPort: {{ .Values.nats.ports.cluster }}
|
||||
- name: monitor
|
||||
containerPort: {{ .Values.nats.ports.monitor }}
|
||||
- name: websocket
|
||||
containerPort: {{ .Values.nats.ports.websocket }}
|
||||
resources:
|
||||
{{- toYaml .Values.nats.resources | nindent 12 }}
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/nats-config
|
||||
- name: data
|
||||
mountPath: {{ .Values.nats.jetstream.fileStore }}
|
||||
- name: logs
|
||||
mountPath: /var/log/nats
|
||||
args:
|
||||
- "-c"
|
||||
- "/etc/nats-config/nats-server.conf"
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: monitor
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: monitor
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: nats-config
|
||||
- name: logs
|
||||
emptyDir: {}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.nats.storage.size }}
|
||||
storageClassName: {{ .Values.nats.storage.storageClass }}
|
||||
{{- end }}
|
||||
Loading…
Reference in a new issue