feat: add trading platform K8s deployment infrastructure
- Add Helm chart with 19 templates (Deployments, Services, Ingress, ConfigMaps, Secrets, NetworkPolicy, cert-manager) - Add Dockerfiles for 4 microservices (dashboard, data-service, execute-service, news-service) - Add CI/CD workflows (build-test, build-push, deploy) - Add raw K8s manifests, per-service Helm charts, and deploy scripts - Add SOPS-encrypted secrets template and config - Configure deployment to customer1 namespace - Include infrastructure components: PostgreSQL, Redis, Kafka
This commit is contained in:
parent
af4cb3d321
commit
d079d1239f
115 changed files with 5917 additions and 0 deletions
19
trading-platform/helm/.sops.yaml
Normal file
19
trading-platform/helm/.sops.yaml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# SOPS configuration for trading platform secrets
|
||||
# Usage: sops -e -i trading-secrets.yaml && kubectl apply -f trading-secrets.yaml
|
||||
creation_rules:
|
||||
# Production secrets - encrypted with Age key
|
||||
- path_regex: trading-secrets.yaml$
|
||||
encrypted_regex: "^(stringData|data)$"
|
||||
age: >-
|
||||
age1ql3z7hjy54pw3hyww5ayyfg7zqgvcnw3eks6lekrq733qkq76jwqgq3g20
|
||||
|
||||
# Per-environment overrides
|
||||
- path_regex: .*/staging/trading-secrets.yaml$
|
||||
encrypted_regex: "^(stringData|data)$"
|
||||
age: >-
|
||||
age1ql3z7hjy54pw3hyww5ayyfg7zqgvcnq76jwqgq3g20
|
||||
|
||||
- path_regex: .*/production/trading-secrets.yaml$
|
||||
encrypted_regex: "^(stringData|data)$"
|
||||
age: >-
|
||||
age1ql3z7hjy54pw3hyww5ayyfg7zqgvcnq76jwqgq3g20
|
||||
19
trading-platform/helm/trading-platform/.sops.yaml
Normal file
19
trading-platform/helm/trading-platform/.sops.yaml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# SOPS configuration for trading platform secrets
|
||||
# Usage: sops -e -i trading-secrets.yaml && kubectl apply -f trading-secrets.yaml
|
||||
creation_rules:
|
||||
# Production secrets - encrypted with Age key
|
||||
- path_regex: trading-secrets.yaml$
|
||||
encrypted_regex: "^(stringData|data)$"
|
||||
age: >-
|
||||
age1ql3z7hjy54pw3hyww5ayyfg7zqgvcnw3eks6lekrq733qkq76jwqgq3g20
|
||||
|
||||
# Per-environment overrides
|
||||
- path_regex: .*/staging/trading-secrets.yaml$
|
||||
encrypted_regex: "^(stringData|data)$"
|
||||
age: >-
|
||||
age1ql3z7hjy54pw3hyww5ayyfg7zqgvcnq76jwqgq3g20
|
||||
|
||||
- path_regex: .*/production/trading-secrets.yaml$
|
||||
encrypted_regex: "^(stringData|data)$"
|
||||
age: >-
|
||||
age1ql3z7hjy54pw3hyww5ayyfg7zqgvcnq76jwqgq3g20
|
||||
12
trading-platform/helm/trading-platform/Chart.yaml
Normal file
12
trading-platform/helm/trading-platform/Chart.yaml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
apiVersion: v2
|
||||
name: trading-platform
|
||||
description: Helm chart for the DEFi trading platform microservices on GKE
|
||||
type: application
|
||||
version: 0.1.0
|
||||
appVersion: "0.1.0"
|
||||
keywords:
|
||||
- trading
|
||||
- defi
|
||||
- microservices
|
||||
maintainers:
|
||||
- name: Trading Platform Team
|
||||
29
trading-platform/helm/trading-platform/templates/NOTES.txt
Normal file
29
trading-platform/helm/trading-platform/templates/NOTES.txt
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
Trading Platform deployed successfully!
|
||||
|
||||
Namespace: {{ .Values.global.namespace }}
|
||||
Release: {{ .Release.Name }}
|
||||
Environment: {{ .Values.global.environment | default "not set" }}
|
||||
|
||||
Services deployed:
|
||||
- execute-service: {{ .Values.executeService.enabled }}
|
||||
- news-service: {{ .Values.newsService.enabled }}
|
||||
- data-service: {{ .Values.dataService.enabled }}
|
||||
- dashboard: {{ .Values.dashboard.enabled }}
|
||||
|
||||
Infrastructure:
|
||||
- PostgreSQL: {{ .Values.postgres.enabled }}
|
||||
- Redis: {{ .Values.redis.enabled }}
|
||||
- Kafka: {{ .Values.kafka.enabled }}
|
||||
|
||||
Ingress: {{ .Values.ingress.enabled }}
|
||||
{{- if .Values.ingress.enabled }}
|
||||
{{- range .Values.ingress.hosts }}
|
||||
Host: {{ .host }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
Next steps:
|
||||
1. Verify pods: kubectl get pods -n {{ .Values.global.namespace }}
|
||||
2. Check services: kubectl get svc -n {{ .Values.global.namespace }}
|
||||
3. Check ingress: kubectl get ingress -n {{ .Values.global.namespace }}
|
||||
4. If using SOPS, decrypt secrets: sops -d trading-secrets.yaml | kubectl apply -f -
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "trading-platform.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
*/}}
|
||||
{{- define "trading-platform.fullname" -}}
|
||||
{{- if .Values.fullnameOverride }}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride }}
|
||||
{{- if contains $name .Release.Name }}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "trading-platform.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "trading-platform.labels" -}}
|
||||
helm.sh/chart: {{ include "trading-platform.chart" . }}
|
||||
{{ include "trading-platform.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "trading-platform.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "trading-platform.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Service-specific labels
|
||||
*/}}
|
||||
{{- define "trading-platform.serviceLabels" -}}
|
||||
{{- $service := index . 0 }}
|
||||
{{- $parent := index . 1 }}
|
||||
{{ include "trading-platform.selectorLabels" $parent }}
|
||||
app: {{ $service.Values.name | default $service.Values.name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "trading-platform.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "trading-platform.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Generate env var map from values
|
||||
*/}}
|
||||
{{- define "trading-platform.envVars" -}}
|
||||
{{- range $key, $value := . }}
|
||||
- name: {{ $key }}
|
||||
value: {{ $value | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Generate secret env var refs
|
||||
*/}}
|
||||
{{- define "trading-platform.secretEnvVars" -}}
|
||||
{{- range $key, $secretRef := . }}
|
||||
- name: {{ $key }}
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
{{- $parts := split "/" $secretRef }}
|
||||
name: {{ $parts._0 }}
|
||||
key: {{ $parts._1 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
{{- if .Values.certManager.enabled }}
|
||||
# External issuer (Let's Encrypt) for public-facing TLS
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: ClusterIssuer
|
||||
metadata:
|
||||
name: {{ .Values.certManager.externalIssuer.name }}
|
||||
spec:
|
||||
acme:
|
||||
server: {{ .Values.certManager.externalIssuer.server }}
|
||||
email: {{ .Values.certManager.externalIssuer.email }}
|
||||
privateKeySecretRef:
|
||||
name: {{ .Values.certManager.externalIssuer.name }}-key
|
||||
solvers:
|
||||
- http01:
|
||||
ingress:
|
||||
class: {{ .Values.ingress.className }}
|
||||
---
|
||||
# Internal self-signed CA for service-to-service mTLS
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Issuer
|
||||
metadata:
|
||||
name: {{ .Values.certManager.internalIssuer.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
selfSigned: {}
|
||||
---
|
||||
# CA certificate issued by the self-signed issuer
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: trading-ca
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
isCA: true
|
||||
commonName: "trading-ca"
|
||||
secretName: trading-ca-secret
|
||||
privateKey:
|
||||
algorithm: ECDSA
|
||||
size: 256
|
||||
issuerRef:
|
||||
name: {{ .Values.certManager.internalIssuer.name }}
|
||||
kind: Issuer
|
||||
group: cert-manager.io
|
||||
---
|
||||
# CA issuer for signing service certificates
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Issuer
|
||||
metadata:
|
||||
name: trading-ca-issuer
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
ca:
|
||||
secretName: trading-ca-secret
|
||||
---
|
||||
# mTLS certificate for execute-service
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: execute-service-mtls
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
dnsNames:
|
||||
- execute-service
|
||||
- execute-service.{{ .Values.global.namespace }}.svc.cluster.local
|
||||
secretName: execute-service-mtls
|
||||
privateKey:
|
||||
algorithm: ECDSA
|
||||
size: 256
|
||||
issuerRef:
|
||||
name: trading-ca-issuer
|
||||
kind: Issuer
|
||||
group: cert-manager.io
|
||||
---
|
||||
# mTLS certificate for news-service
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: news-service-mtls
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
dnsNames:
|
||||
- news-service
|
||||
- news-service.{{ .Values.global.namespace }}.svc.cluster.local
|
||||
secretName: news-service-mtls
|
||||
privateKey:
|
||||
algorithm: ECDSA
|
||||
size: 256
|
||||
issuerRef:
|
||||
name: trading-ca-issuer
|
||||
kind: Issuer
|
||||
group: cert-manager.io
|
||||
---
|
||||
# mTLS certificate for data-service
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: data-service-mtls
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
dnsNames:
|
||||
- data-service
|
||||
- data-service.{{ .Values.global.namespace }}.svc.cluster.local
|
||||
secretName: data-service-mtls
|
||||
privateKey:
|
||||
algorithm: ECDSA
|
||||
size: 256
|
||||
issuerRef:
|
||||
name: trading-ca-issuer
|
||||
kind: Issuer
|
||||
group: cert-manager.io
|
||||
---
|
||||
# TLS certificate for the public domain (ingress)
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: trading-tls
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
secretName: trading-tls
|
||||
dnsNames:
|
||||
{{- range $host := .Values.ingress.hosts }}
|
||||
- {{ $host.host }}
|
||||
{{- end }}
|
||||
issuerRef:
|
||||
name: {{ .Values.certManager.externalIssuer.name }}
|
||||
kind: ClusterIssuer
|
||||
group: cert-manager.io
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
# Shared ConfigMap for trading platform configuration
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "trading-platform.fullname" . }}-config
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
{{- include "trading-platform.labels" . | nindent 4 }}
|
||||
data:
|
||||
# Shared environment configuration
|
||||
ENVIRONMENT: {{ .Values.global.environment | quote }}
|
||||
CLUSTER_NAME: {{ .Values.global.clusterName | quote }}
|
||||
NAMESPACE: {{ .Values.global.namespace | quote }}
|
||||
# Kafka bootstrap (internal DNS)
|
||||
KAFKA_BOOTSTRAP: kafka-headless.{{ .Values.global.namespace }}.svc.cluster.local:9092
|
||||
# Redis connection
|
||||
REDIS_HOST: redis-master.{{ .Values.global.namespace }}.svc.cluster.local
|
||||
REDIS_PORT: "6379"
|
||||
# PostgreSQL connection
|
||||
POSTGRES_HOST: postgres-primary.{{ .Values.global.namespace }}.svc.cluster.local
|
||||
POSTGRES_PORT: "5432"
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
{{- if .Values.dashboard.enabled }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .Values.dashboard.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
{{- include "trading-platform.labels" . | nindent 4 }}
|
||||
app: {{ .Values.dashboard.name }}
|
||||
spec:
|
||||
{{- if not .Values.dashboard.autoscaling.enabled }}
|
||||
replicas: {{ .Values.global.replicaCount }}
|
||||
{{- end }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "trading-platform.selectorLabels" . | nindent 6 }}
|
||||
app: {{ .Values.dashboard.name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "trading-platform.selectorLabels" . | nindent 8 }}
|
||||
app: {{ .Values.dashboard.name }}
|
||||
annotations:
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/port: "{{ .Values.dashboard.port }}"
|
||||
spec:
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
containers:
|
||||
- name: {{ .Values.dashboard.name }}
|
||||
image: "{{ .Values.dashboard.image.repository }}:{{ .Values.dashboard.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.dashboard.image.pullPolicy }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ .Values.dashboard.port }}
|
||||
protocol: TCP
|
||||
env:
|
||||
{{- range $key, $value := .Values.dashboard.env }}
|
||||
- name: {{ $key }}
|
||||
value: {{ $value | quote }}
|
||||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml .Values.dashboard.resources | nindent 12 }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: http
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: http
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
{{- with .Values.global.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
{{- if .Values.dashboard.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .Values.dashboard.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app: {{ .Values.dashboard.name }}
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: {{ .Values.dashboard.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
app: {{ .Values.dashboard.name }}
|
||||
---
|
||||
{{- if .Values.dashboard.autoscaling.enabled }}
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: {{ .Values.dashboard.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: {{ .Values.dashboard.name }}
|
||||
minReplicas: {{ .Values.dashboard.autoscaling.minReplicas }}
|
||||
maxReplicas: {{ .Values.dashboard.autoscaling.maxReplicas }}
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: {{ .Values.dashboard.autoscaling.targetCPUUtilizationPercentage }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
{{- if .Values.dataService.enabled }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .Values.dataService.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
{{- include "trading-platform.labels" . | nindent 4 }}
|
||||
app: {{ .Values.dataService.name }}
|
||||
spec:
|
||||
{{- if not .Values.dataService.autoscaling.enabled }}
|
||||
replicas: {{ .Values.global.replicaCount }}
|
||||
{{- end }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "trading-platform.selectorLabels" . | nindent 6 }}
|
||||
app: {{ .Values.dataService.name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "trading-platform.selectorLabels" . | nindent 8 }}
|
||||
app: {{ .Values.dataService.name }}
|
||||
annotations:
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/port: "{{ .Values.dataService.port }}"
|
||||
spec:
|
||||
serviceAccountName: {{ .Values.dataService.name }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
containers:
|
||||
- name: {{ .Values.dataService.name }}
|
||||
image: "{{ .Values.dataService.image.repository }}:{{ .Values.dataService.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.dataService.image.pullPolicy }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ .Values.dataService.port }}
|
||||
protocol: TCP
|
||||
env:
|
||||
{{- range $key, $value := .Values.dataService.env }}
|
||||
- name: {{ $key }}
|
||||
value: {{ $value | quote }}
|
||||
{{- end }}
|
||||
- name: DB_HOST
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "trading-platform.fullname" . }}-config
|
||||
key: POSTGRES_HOST
|
||||
- name: REDIS_HOST
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "trading-platform.fullname" . }}-config
|
||||
key: REDIS_HOST
|
||||
- name: KAFKA_BOOTSTRAP_SERVERS
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "trading-platform.fullname" . }}-config
|
||||
key: KAFKA_BOOTSTRAP
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: trading-secrets
|
||||
resources:
|
||||
{{- toYaml .Values.dataService.resources | nindent 12 }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
{{- with .Values.global.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
{{- if .Values.dataService.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .Values.dataService.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app: {{ .Values.dataService.name }}
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: {{ .Values.dataService.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
app: {{ .Values.dataService.name }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ .Values.dataService.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app: {{ .Values.dataService.name }}
|
||||
---
|
||||
{{- if .Values.dataService.autoscaling.enabled }}
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: {{ .Values.dataService.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: {{ .Values.dataService.name }}
|
||||
minReplicas: {{ .Values.dataService.autoscaling.minReplicas }}
|
||||
maxReplicas: {{ .Values.dataService.autoscaling.maxReplicas }}
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: {{ .Values.dataService.autoscaling.targetCPUUtilizationPercentage }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
{{- if .Values.executeService.enabled }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .Values.executeService.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
{{- include "trading-platform.labels" . | nindent 4 }}
|
||||
app: {{ .Values.executeService.name }}
|
||||
spec:
|
||||
{{- if not .Values.executeService.autoscaling.enabled }}
|
||||
replicas: {{ .Values.global.replicaCount }}
|
||||
{{- end }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "trading-platform.selectorLabels" . | nindent 6 }}
|
||||
app: {{ .Values.executeService.name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "trading-platform.selectorLabels" . | nindent 8 }}
|
||||
app: {{ .Values.executeService.name }}
|
||||
annotations:
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/port: "{{ .Values.executeService.port }}"
|
||||
spec:
|
||||
serviceAccountName: {{ .Values.executeService.name }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
containers:
|
||||
- name: {{ .Values.executeService.name }}
|
||||
image: "{{ .Values.executeService.image.repository }}:{{ .Values.executeService.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.executeService.image.pullPolicy }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ .Values.executeService.port }}
|
||||
protocol: TCP
|
||||
env:
|
||||
{{- range $key, $value := .Values.executeService.env }}
|
||||
- name: {{ $key }}
|
||||
value: {{ $value | quote }}
|
||||
{{- end }}
|
||||
# Shared config from ConfigMap
|
||||
- name: DB_HOST
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "trading-platform.fullname" . }}-config
|
||||
key: POSTGRES_HOST
|
||||
- name: REDIS_HOST
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "trading-platform.fullname" . }}-config
|
||||
key: REDIS_HOST
|
||||
- name: KAFKA_BOOTSTRAP_SERVERS
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "trading-platform.fullname" . }}-config
|
||||
key: KAFKA_BOOTSTRAP
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: trading-secrets
|
||||
resources:
|
||||
{{- toYaml .Values.executeService.resources | nindent 12 }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
- name: mtls-certs
|
||||
mountPath: /etc/mtls
|
||||
readOnly: true
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
failureThreshold: 3
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
- name: mtls-certs
|
||||
secret:
|
||||
secretName: execute-service-mtls
|
||||
{{- with .Values.global.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
nodeSelector:
|
||||
kubernetes.io/os: linux
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- weight: 100
|
||||
podAffinityTerm:
|
||||
labelSelector:
|
||||
matchExpressions:
|
||||
- key: app
|
||||
operator: In
|
||||
values:
|
||||
- {{ .Values.executeService.name }}
|
||||
topologyKey: kubernetes.io/hostname
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
{{- if .Values.executeService.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .Values.executeService.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app: {{ .Values.executeService.name }}
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: {{ .Values.executeService.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
app: {{ .Values.executeService.name }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ .Values.executeService.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app: {{ .Values.executeService.name }}
|
||||
annotations:
|
||||
iam.gke.io/gcp-service-account: execute-service@{{ .Values.global.clusterName }}.iam.gserviceaccount.com
|
||||
---
|
||||
{{- if .Values.executeService.autoscaling.enabled }}
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: {{ .Values.executeService.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: {{ .Values.executeService.name }}
|
||||
minReplicas: {{ .Values.executeService.autoscaling.minReplicas }}
|
||||
maxReplicas: {{ .Values.executeService.autoscaling.maxReplicas }}
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: {{ .Values.executeService.autoscaling.targetCPUUtilizationPercentage }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
{{- if .Values.kafka.enabled }}
|
||||
# Headless service for KRaft discovery
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: kafka-headless
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app: kafka
|
||||
spec:
|
||||
ports:
|
||||
- port: 9092
|
||||
targetPort: 9092
|
||||
name: kafka
|
||||
- port: 9093
|
||||
targetPort: 9093
|
||||
name: controller
|
||||
clusterIP: None
|
||||
selector:
|
||||
app: kafka
|
||||
---
|
||||
# Client-facing service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: kafka
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app: kafka
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 9092
|
||||
targetPort: 9092
|
||||
name: kafka
|
||||
selector:
|
||||
app: kafka
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: kafka
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app: kafka
|
||||
spec:
|
||||
serviceName: kafka-headless
|
||||
replicas: {{ .Values.kafka.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: kafka
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: kafka
|
||||
spec:
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
fsGroup: 1000
|
||||
containers:
|
||||
- name: kafka
|
||||
image: "{{ .Values.kafka.image.repository }}:{{ .Values.kafka.image.tag }}"
|
||||
ports:
|
||||
- containerPort: 9092
|
||||
name: kafka
|
||||
- containerPort: 9093
|
||||
name: controller
|
||||
env:
|
||||
- name: KAFKA_NODE_ID
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: KAFKA_PROCESS_ROLES
|
||||
value: "broker,controller"
|
||||
- name: KAFKA_CONTROLLER_QUORUM_VOTERS
|
||||
value: |
|
||||
{{- $ns := .Values.global.namespace }}
|
||||
{{- range $i := until (int .Values.kafka.replicaCount) }}
|
||||
{{- $i }}@kafka-{{ $i }}.kafka-headless.{{ $ns }}.svc.cluster.local:9093{{ if lt (add $i 1) (int $.Values.kafka.replicaCount) }},{{ end }}
|
||||
{{- end }}
|
||||
- name: KAFKA_CONTROLLER_LISTENER_NAMES
|
||||
value: "CONTROLLER"
|
||||
- name: KAFKA_LISTENERS
|
||||
value: "PLAINTEXT://0.0.0.0:9092,CONTROLLER://0.0.0.0:9093"
|
||||
- name: KAFKA_ADVERTISED_LISTENERS
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: status.podIP
|
||||
- name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
|
||||
value: "PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT"
|
||||
- name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
|
||||
value: "{{ .Values.kafka.replicaCount }}"
|
||||
- name: KAFKA_TRANSACTION_STATE_LOG_MIN_ISR
|
||||
value: "{{ add1 (div (int .Values.kafka.replicaCount) 2) }}"
|
||||
- name: KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR
|
||||
value: "{{ .Values.kafka.replicaCount }}"
|
||||
- name: KAFKA_AUTO_CREATE_TOPICS_ENABLE
|
||||
value: "true"
|
||||
- name: KAFKA_NUM_PARTITIONS
|
||||
value: "6"
|
||||
- name: KAFKA_DEFAULT_REPLICATION_FACTOR
|
||||
value: "{{ .Values.kafka.replicaCount }}"
|
||||
- name: KAFKA_LOG_DIRS
|
||||
value: "/var/lib/kafka/data"
|
||||
resources:
|
||||
{{- toYaml .Values.kafka.resources | nindent 12 }}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
volumeMounts:
|
||||
- name: kafka-data
|
||||
mountPath: /var/lib/kafka/data
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
livenessProbe:
|
||||
tcpSocket:
|
||||
port: kafka
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: kafka
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: kafka-data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
storageClassName: {{ .Values.kafka.storage.storageClass }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.kafka.storage.size }}
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
{{- if .Values.postgres.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: postgres-primary
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: postgres
|
||||
protocol: TCP
|
||||
name: postgres
|
||||
selector:
|
||||
app: postgres
|
||||
role: primary
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: postgres
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
serviceName: postgres-primary
|
||||
replicas: {{ .Values.postgres.primary.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: postgres
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: postgres
|
||||
role: primary
|
||||
spec:
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 999
|
||||
runAsGroup: 999
|
||||
fsGroup: 999
|
||||
containers:
|
||||
- name: postgres
|
||||
image: "{{ .Values.postgres.image.repository }}:{{ .Values.postgres.image.tag }}"
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
name: postgres
|
||||
env:
|
||||
- name: POSTGRES_USER
|
||||
value: "trading"
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: trading-secrets
|
||||
key: POSTGRES_PASSWORD
|
||||
- name: POSTGRES_DB
|
||||
value: {{ .Values.postgres.postgresqlDatabase | quote }}
|
||||
resources:
|
||||
{{- toYaml .Values.postgres.primary.resources | nindent 12 }}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
volumeMounts:
|
||||
- name: postgres-data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
- name: run
|
||||
mountPath: /var/run
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- pg_isready
|
||||
- -U
|
||||
- trading
|
||||
- -d
|
||||
- {{ .Values.postgres.postgresqlDatabase }}
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- pg_isready
|
||||
- -U
|
||||
- trading
|
||||
- -d
|
||||
- {{ .Values.postgres.postgresqlDatabase }}
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
- name: run
|
||||
emptyDir: {}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: postgres-data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
storageClassName: {{ .Values.postgres.storage.storageClass }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.postgres.storage.size }}
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
{{- if .Values.redis.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: redis-master
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app: redis
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 6379
|
||||
targetPort: redis
|
||||
protocol: TCP
|
||||
name: redis
|
||||
selector:
|
||||
app: redis
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: redis
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app: redis
|
||||
spec:
|
||||
serviceName: redis-master
|
||||
replicas: {{ .Values.redis.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: redis
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: redis
|
||||
spec:
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 999
|
||||
runAsGroup: 999
|
||||
fsGroup: 999
|
||||
containers:
|
||||
- name: redis
|
||||
image: "{{ .Values.redis.image.repository }}:{{ .Values.redis.image.tag }}"
|
||||
command:
|
||||
- redis-server
|
||||
- --appendonly
|
||||
- "yes"
|
||||
- --save
|
||||
- ""
|
||||
- --requirepass
|
||||
- $(REDIS_PASSWORD)
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
name: redis
|
||||
env:
|
||||
- name: REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: trading-secrets
|
||||
key: REDIS_PASSWORD
|
||||
resources:
|
||||
{{- toYaml .Values.redis.master.resources | nindent 12 }}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
volumeMounts:
|
||||
- name: redis-data
|
||||
mountPath: /data
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- redis-cli
|
||||
- -a
|
||||
- $(REDIS_PASSWORD)
|
||||
- ping
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- redis-cli
|
||||
- -a
|
||||
- $(REDIS_PASSWORD)
|
||||
- ping
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: redis-data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
storageClassName: {{ .Values.redis.master.storage.storageClass }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.redis.master.storage.size }}
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
{{- if .Values.ingress.enabled }}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ include "trading-platform.fullname" . }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
{{- include "trading-platform.labels" . | nindent 4 }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if .Values.ingress.className }}
|
||||
ingressClassName: {{ .Values.ingress.className }}
|
||||
{{- end }}
|
||||
tls:
|
||||
{{- range .Values.ingress.tls }}
|
||||
- hosts:
|
||||
{{- range .hosts }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
secretName: {{ .secretName }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range $host := .Values.ingress.hosts }}
|
||||
- host: {{ $host.host | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range $path := $host.paths }}
|
||||
- path: {{ $path.path }}
|
||||
pathType: {{ $path.pathType }}
|
||||
backend:
|
||||
service:
|
||||
name: {{ $path.service }}
|
||||
port:
|
||||
{{- if eq $path.service "dashboard" }}
|
||||
number: {{ $.Values.dashboard.port }}
|
||||
{{- else if eq $path.service "execute-service" }}
|
||||
number: {{ $.Values.executeService.port }}
|
||||
{{- else if eq $path.service "news-service" }}
|
||||
number: {{ $.Values.newsService.port }}
|
||||
{{- else if eq $path.service "data-service" }}
|
||||
number: {{ $.Values.dataService.port }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- if .Values.global.environment }}
|
||||
environment: {{ .Values.global.environment | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.global.clusterName }}
|
||||
cluster: {{ .Values.global.clusterName | quote }}
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,311 @@
|
|||
{{- if .Values.networkPolicies.enabled }}
|
||||
{{- if .Values.networkPolicies.defaultDenyIngress }}
|
||||
# Deny all ingress traffic by default
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: default-deny-all-ingress
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: security-audit
|
||||
spec:
|
||||
podSelector: {}
|
||||
policyTypes:
|
||||
- Ingress
|
||||
---
|
||||
{{- end }}
|
||||
{{- if .Values.networkPolicies.defaultDenyEgress }}
|
||||
# Deny all egress traffic by default
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: default-deny-all-egress
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: security-audit
|
||||
spec:
|
||||
podSelector: {}
|
||||
policyTypes:
|
||||
- Egress
|
||||
---
|
||||
{{- end }}
|
||||
{{- if .Values.networkPolicies.allowDNS }}
|
||||
# Allow all pods to resolve DNS
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: allow-dns-egress
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
podSelector: {}
|
||||
policyTypes:
|
||||
- Egress
|
||||
egress:
|
||||
- to: []
|
||||
ports:
|
||||
- port: 53
|
||||
protocol: UDP
|
||||
- port: 53
|
||||
protocol: TCP
|
||||
---
|
||||
{{- end }}
|
||||
# Execute Service networking
|
||||
{{- if .Values.executeService.enabled }}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: execute-service-networking
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app: execute-service
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
ingress:
|
||||
- from:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: ingress-nginx
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: ingress-nginx
|
||||
- namespaceSelector: {}
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: gce-proxy
|
||||
ports:
|
||||
- port: {{ .Values.executeService.port }}
|
||||
protocol: TCP
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: news-service
|
||||
ports:
|
||||
- port: {{ .Values.executeService.port }}
|
||||
protocol: TCP
|
||||
egress:
|
||||
- to:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: postgres
|
||||
ports:
|
||||
- port: 5432
|
||||
protocol: TCP
|
||||
- to:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: redis
|
||||
ports:
|
||||
- port: 6379
|
||||
protocol: TCP
|
||||
- to:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: kafka
|
||||
ports:
|
||||
- port: 9092
|
||||
protocol: TCP
|
||||
---
|
||||
{{- end }}
|
||||
# News Service networking
|
||||
{{- if .Values.newsService.enabled }}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: news-service-networking
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app: news-service
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
ingress:
|
||||
- from:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: ingress-nginx
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: ingress-nginx
|
||||
ports:
|
||||
- port: {{ .Values.newsService.port }}
|
||||
protocol: TCP
|
||||
egress:
|
||||
- to:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
cnpg.io/cluster: customer1-cnpg
|
||||
ports:
|
||||
- port: 5432
|
||||
protocol: TCP
|
||||
- to:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: kafka
|
||||
ports:
|
||||
- port: 9092
|
||||
protocol: TCP
|
||||
- to:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: execute-service
|
||||
ports:
|
||||
- port: {{ .Values.executeService.port }}
|
||||
protocol: TCP
|
||||
---
|
||||
{{- end }}
|
||||
# Database networking
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: postgres-networking
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app: postgres
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: execute-service
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: data-service
|
||||
ports:
|
||||
- port: 5432
|
||||
protocol: TCP
|
||||
egress: []
|
||||
---
|
||||
# Redis networking
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: redis-networking
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app: redis
|
||||
policyTypes:
|
||||
- Ingress
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: execute-service
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: data-service
|
||||
ports:
|
||||
- port: 6379
|
||||
protocol: TCP
|
||||
---
|
||||
# Kafka networking
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: kafka-networking
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app: kafka
|
||||
policyTypes:
|
||||
- Ingress
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: execute-service
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: news-service
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: data-service
|
||||
ports:
|
||||
- port: 9092
|
||||
protocol: TCP
|
||||
- port: 9093
|
||||
protocol: TCP
|
||||
---
|
||||
# Dashboard networking
|
||||
{{- if .Values.dashboard.enabled }}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: dashboard-networking
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app: dashboard
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
ingress:
|
||||
- from:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: ingress-nginx
|
||||
ports:
|
||||
- port: {{ .Values.dashboard.port }}
|
||||
protocol: TCP
|
||||
egress: []
|
||||
---
|
||||
{{- end }}
|
||||
# Data Service networking
|
||||
{{- if .Values.dataService.enabled }}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: data-service-networking
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app: data-service
|
||||
policyTypes:
|
||||
- Ingress
|
||||
- Egress
|
||||
ingress:
|
||||
- from:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: ingress-nginx
|
||||
ports:
|
||||
- port: {{ .Values.dataService.port }}
|
||||
protocol: TCP
|
||||
egress:
|
||||
- to:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: postgres
|
||||
ports:
|
||||
- port: 5432
|
||||
protocol: TCP
|
||||
- to:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: redis
|
||||
ports:
|
||||
- port: 6379
|
||||
protocol: TCP
|
||||
- to:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: kafka
|
||||
ports:
|
||||
- port: 9092
|
||||
protocol: TCP
|
||||
---
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
{{- if .Values.newsService.enabled }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .Values.newsService.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
{{- include "trading-platform.labels" . | nindent 4 }}
|
||||
app: {{ .Values.newsService.name }}
|
||||
spec:
|
||||
{{- if not .Values.newsService.autoscaling.enabled }}
|
||||
replicas: {{ .Values.global.replicaCount }}
|
||||
{{- end }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "trading-platform.selectorLabels" . | nindent 6 }}
|
||||
app: {{ .Values.newsService.name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "trading-platform.selectorLabels" . | nindent 8 }}
|
||||
app: {{ .Values.newsService.name }}
|
||||
annotations:
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/port: "{{ .Values.newsService.port }}"
|
||||
spec:
|
||||
serviceAccountName: {{ .Values.newsService.name }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
containers:
|
||||
- name: {{ .Values.newsService.name }}
|
||||
image: "{{ .Values.newsService.image.repository }}:{{ .Values.newsService.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.newsService.image.pullPolicy }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ .Values.newsService.port }}
|
||||
protocol: TCP
|
||||
env:
|
||||
{{- range $key, $value := .Values.newsService.env }}
|
||||
- name: {{ $key }}
|
||||
value: {{ $value | quote }}
|
||||
{{- end }}
|
||||
- name: KAFKA_BOOTSTRAP_SERVERS
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: {{ include "trading-platform.fullname" . }}-config
|
||||
key: KAFKA_BOOTSTRAP
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: trading-secrets
|
||||
resources:
|
||||
{{- toYaml .Values.newsService.resources | nindent 12 }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
- name: mtls-certs
|
||||
mountPath: /etc/mtls
|
||||
readOnly: true
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
- name: mtls-certs
|
||||
secret:
|
||||
secretName: news-service-mtls
|
||||
{{- with .Values.global.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
{{- if .Values.newsService.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .Values.newsService.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app: {{ .Values.newsService.name }}
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: {{ .Values.newsService.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
app: {{ .Values.newsService.name }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ .Values.newsService.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
app: {{ .Values.newsService.name }}
|
||||
---
|
||||
{{- if .Values.newsService.autoscaling.enabled }}
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: {{ .Values.newsService.name }}
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: {{ .Values.newsService.name }}
|
||||
minReplicas: {{ .Values.newsService.autoscaling.minReplicas }}
|
||||
maxReplicas: {{ .Values.newsService.autoscaling.maxReplicas }}
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: {{ .Values.newsService.autoscaling.targetCPUUtilizationPercentage }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
# Trading Secrets - Encrypt with SOPS before applying
|
||||
# Usage: sops -e -i trading-secrets.yaml && kubectl apply -f trading-secrets.yaml
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: trading-secrets
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
{{- include "trading-platform.labels" . | nindent 4 }}
|
||||
app.kubernetes.io/managed-by: security-audit
|
||||
annotations:
|
||||
# SOPS manages this file - edit with: sops trading-secrets.yaml
|
||||
secrets.yaml.sops.io/v2: encrypted
|
||||
type: Opaque
|
||||
stringData:
|
||||
# JWT authentication
|
||||
EXECUTE_JWT_SECRET_KEY: {{ .Values.executeService.env.JWT_SECRET_KEY | default "" | quote }}
|
||||
|
||||
# Exchange private keys
|
||||
EXECUTE_HYPERLIQUID_PRIVATE_KEY: {{ .Values.executeService.env.HYPERLIQUID_PRIVATE_KEY | default "" | quote }}
|
||||
EXECUTE_SOLANA_PRIVATE_KEY_BASE58: {{ .Values.executeService.env.SOLANA_PRIVATE_KEY_BASE58 | default "" | quote }}
|
||||
|
||||
# Database credentials
|
||||
POSTGRES_PASSWORD: {{ .Values.postgres.postgresqlPassword | default "" | quote }}
|
||||
NEWS_DB_PASSWORD: {{ .Values.newsService.env.NEWS_DB_PASSWORD | default "" | quote }}
|
||||
|
||||
# Redis
|
||||
REDIS_PASSWORD: {{ .Values.redis.redisPassword | default "" | quote }}
|
||||
|
||||
# Kafka SASL
|
||||
KAFKA_SASL_USERNAME: {{ .Values.kafka.saslUsername | default "" | quote }}
|
||||
KAFKA_SASL_PASSWORD: {{ .Values.kafka.saslPassword | default "" | quote }}
|
||||
|
||||
---
|
||||
# mTLS certificates (generated by cert-manager, mounted as volumes)
|
||||
# Service account tokens for SPIFFE/SPIRE identity
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: trading-mtls-certs
|
||||
namespace: {{ .Values.global.namespace }}
|
||||
labels:
|
||||
{{- include "trading-platform.labels" . | nindent 4 }}
|
||||
type: kubernetes.io/tls
|
||||
# tls.crt and tls.key populated by cert-manager
|
||||
33
trading-platform/helm/trading-platform/trading-secrets.yaml
Normal file
33
trading-platform/helm/trading-platform/trading-secrets.yaml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Trading Secrets - Encrypt with SOPS before applying
|
||||
# Usage: sops -e -i trading-secrets.yaml && kubectl apply -f trading-secrets.yaml
|
||||
#
|
||||
# DO NOT commit unencrypted secrets to git!
|
||||
# Generate secrets with: python -c "import secrets; print(secrets.token_urlsafe(24))"
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: trading-secrets
|
||||
namespace: trading
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: security-audit
|
||||
annotations:
|
||||
secrets.yaml.sops.io/v2: encrypted
|
||||
type: Opaque
|
||||
stringData:
|
||||
# JWT authentication - use 32+ byte hex token
|
||||
EXECUTE_JWT_SECRET_KEY: ""
|
||||
|
||||
# Exchange private keys - NEVER commit plaintext!
|
||||
EXECUTE_HYPERLIQUID_PRIVATE_KEY: ""
|
||||
EXECUTE_SOLANA_PRIVATE_KEY_BASE58: ""
|
||||
|
||||
# Database credentials - use 24+ byte URL-safe tokens
|
||||
POSTGRES_PASSWORD: ""
|
||||
NEWS_DB_PASSWORD: ""
|
||||
|
||||
# Redis password
|
||||
REDIS_PASSWORD: ""
|
||||
|
||||
# Kafka SASL authentication
|
||||
KAFKA_SASL_USERNAME: ""
|
||||
KAFKA_SASL_PASSWORD: ""
|
||||
306
trading-platform/helm/trading-platform/values.yaml
Normal file
306
trading-platform/helm/trading-platform/values.yaml
Normal file
|
|
@ -0,0 +1,306 @@
|
|||
# Trading Platform Helm Chart - Default Values
|
||||
# ============================================================
|
||||
|
||||
# Global settings
|
||||
global:
|
||||
namespace: customer1
|
||||
replicaCount: 2
|
||||
imagePullSecrets: []
|
||||
clusterName: customer1-gke
|
||||
environment: staging
|
||||
registry: us-central1-docker.pkg.dev/customer1-gke/trading
|
||||
|
||||
# Resource defaults for all microservices
|
||||
resources:
|
||||
requests:
|
||||
cpu: 250m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
cpu: "1"
|
||||
memory: 512Mi
|
||||
|
||||
# Pod security context defaults
|
||||
podSecurityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
fsGroup: 1000
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
|
||||
# Container security context defaults
|
||||
containerSecurityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
|
||||
# =================================================================
|
||||
# Execute Service (Hyperliquid + Solana trading engine)
|
||||
# =================================================================
|
||||
executeService:
|
||||
enabled: true
|
||||
name: execute-service
|
||||
image:
|
||||
repository: ""
|
||||
tag: "0.1.0"
|
||||
pullPolicy: IfNotPresent
|
||||
port: 8000
|
||||
resources:
|
||||
requests:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
limits:
|
||||
cpu: "2"
|
||||
memory: 1Gi
|
||||
autoscaling:
|
||||
enabled: true
|
||||
minReplicas: 2
|
||||
maxReplicas: 10
|
||||
targetCPUUtilizationPercentage: 70
|
||||
env:
|
||||
LOG_LEVEL: "INFO"
|
||||
KAFKA_BOOTSTRAP_SERVERS: "kafka-headless:9092"
|
||||
KAFKA_TOPIC_TRADES: "trades.executed"
|
||||
KAFKA_TOPIC_ORDERS: "orders.new"
|
||||
REDIS_HOST: "redis-master"
|
||||
REDIS_PORT: "6379"
|
||||
DB_HOST: "postgres-primary"
|
||||
DB_PORT: "5432"
|
||||
DB_NAME: "trading_db"
|
||||
|
||||
# =================================================================
|
||||
# News Service (CNPG connector + Kafka producer)
|
||||
# =================================================================
|
||||
newsService:
|
||||
enabled: true
|
||||
name: news-service
|
||||
image:
|
||||
repository: ""
|
||||
tag: "0.1.0"
|
||||
pullPolicy: IfNotPresent
|
||||
port: 8000
|
||||
resources:
|
||||
requests:
|
||||
cpu: 300m
|
||||
memory: 384Mi
|
||||
limits:
|
||||
cpu: "1"
|
||||
memory: 768Mi
|
||||
autoscaling:
|
||||
enabled: true
|
||||
minReplicas: 2
|
||||
maxReplicas: 6
|
||||
targetCPUUtilizationPercentage: 75
|
||||
env:
|
||||
LOG_LEVEL: "INFO"
|
||||
DB_POOL_SIZE: "5"
|
||||
DB_MAX_OVERFLOW: "10"
|
||||
KAFKA_BOOTSTRAP_SERVERS: "kafka-headless:9092"
|
||||
KAFKA_GROUP_ID: "news-analyzer"
|
||||
KAFKA_TOPIC_ARTICLES: "news.articles"
|
||||
KAFKA_TOPIC_ANALYSIS: "news.analysis"
|
||||
API_PREFIX: "/api/v1"
|
||||
CORS_ORIGINS: '["https://app.customer1.trading.com"]'
|
||||
DB_HOST: "customer1-cnpg-r"
|
||||
DB_PORT: "5432"
|
||||
DB_NAME: "news"
|
||||
|
||||
# =================================================================
|
||||
# Data Service (Postgres + Redis + Kafka consumers)
|
||||
# =================================================================
|
||||
dataService:
|
||||
enabled: true
|
||||
name: data-service
|
||||
image:
|
||||
repository: ""
|
||||
tag: "0.1.0"
|
||||
pullPolicy: IfNotPresent
|
||||
port: 8000
|
||||
resources:
|
||||
requests:
|
||||
cpu: 300m
|
||||
memory: 384Mi
|
||||
limits:
|
||||
cpu: "1"
|
||||
memory: 768Mi
|
||||
autoscaling:
|
||||
enabled: true
|
||||
minReplicas: 2
|
||||
maxReplicas: 6
|
||||
targetCPUUtilizationPercentage: 70
|
||||
env:
|
||||
LOG_LEVEL: "INFO"
|
||||
DB_HOST: "postgres-primary"
|
||||
DB_PORT: "5432"
|
||||
DB_NAME: "trading_db"
|
||||
REDIS_HOST: "redis-master"
|
||||
REDIS_PORT: "6379"
|
||||
KAFKA_BOOTSTRAP_SERVERS: "kafka-headless:9092"
|
||||
KAFKA_CONSUMER_GROUP: "data-service"
|
||||
|
||||
# =================================================================
|
||||
# Dashboard (Next.js frontend)
|
||||
# =================================================================
|
||||
dashboard:
|
||||
enabled: true
|
||||
name: dashboard
|
||||
image:
|
||||
repository: ""
|
||||
tag: "0.1.0"
|
||||
pullPolicy: IfNotPresent
|
||||
port: 3000
|
||||
resources:
|
||||
requests:
|
||||
cpu: 200m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
cpu: "500m"
|
||||
memory: 512Mi
|
||||
autoscaling:
|
||||
enabled: true
|
||||
minReplicas: 2
|
||||
maxReplicas: 8
|
||||
targetCPUUtilizationPercentage: 60
|
||||
env:
|
||||
NODE_ENV: "production"
|
||||
NEXT_PUBLIC_API_BASE_URL: "/api"
|
||||
|
||||
# =================================================================
|
||||
# Ingress
|
||||
# =================================================================
|
||||
ingress:
|
||||
enabled: true
|
||||
className: "gce"
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: gce
|
||||
kubernetes.io/ingress.allow-http: "true"
|
||||
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
||||
hosts:
|
||||
- host: app.customer1.trading.com
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
service: dashboard
|
||||
- path: /api/trades
|
||||
pathType: Prefix
|
||||
service: execute-service
|
||||
- path: /api/auth
|
||||
pathType: Prefix
|
||||
service: execute-service
|
||||
- path: /api/news
|
||||
pathType: Prefix
|
||||
service: news-service
|
||||
- path: /api/data
|
||||
pathType: Prefix
|
||||
service: data-service
|
||||
tls:
|
||||
- secretName: trading-tls
|
||||
hosts:
|
||||
- app.customer1.trading.com
|
||||
|
||||
# =================================================================
|
||||
# Cert-Manager / mTLS
|
||||
# =================================================================
|
||||
certManager:
|
||||
enabled: true
|
||||
externalIssuer:
|
||||
name: letsencrypt-prod
|
||||
server: https://acme-v02.api.letsencrypt.org/directory
|
||||
email: [email protected]
|
||||
internalIssuer:
|
||||
name: trading-ca
|
||||
|
||||
# =================================================================
|
||||
# PostgreSQL
|
||||
# =================================================================
|
||||
postgres:
|
||||
enabled: true
|
||||
image:
|
||||
repository: postgres
|
||||
tag: "17-alpine"
|
||||
primary:
|
||||
replicaCount: 1
|
||||
resources:
|
||||
requests:
|
||||
cpu: "1"
|
||||
memory: 2Gi
|
||||
limits:
|
||||
cpu: "2"
|
||||
memory: 4Gi
|
||||
storage:
|
||||
size: 50Gi
|
||||
storageClass: "standard-rwo"
|
||||
postgresqlDatabase: trading_db
|
||||
|
||||
# =================================================================
|
||||
# Redis
|
||||
# =================================================================
|
||||
redis:
|
||||
enabled: true
|
||||
image:
|
||||
repository: redis
|
||||
tag: "7-alpine"
|
||||
replicaCount: 3
|
||||
master:
|
||||
resources:
|
||||
requests:
|
||||
cpu: 250m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
cpu: "500m"
|
||||
memory: 512Mi
|
||||
storage:
|
||||
size: 10Gi
|
||||
storageClass: "standard-rwo"
|
||||
|
||||
# =================================================================
|
||||
# Kafka (KRaft mode)
|
||||
# =================================================================
|
||||
kafka:
|
||||
enabled: true
|
||||
image:
|
||||
repository: apache/kafka
|
||||
tag: "3.9.0"
|
||||
replicaCount: 3
|
||||
resources:
|
||||
requests:
|
||||
cpu: 500m
|
||||
memory: 1Gi
|
||||
limits:
|
||||
cpu: "1"
|
||||
memory: 2Gi
|
||||
storage:
|
||||
size: 20Gi
|
||||
storageClass: "standard-rwo"
|
||||
topics:
|
||||
- name: trades.executed
|
||||
partitions: 6
|
||||
replicationFactor: 3
|
||||
- name: orders.new
|
||||
partitions: 6
|
||||
replicationFactor: 3
|
||||
- name: news.articles
|
||||
partitions: 6
|
||||
replicationFactor: 3
|
||||
- name: news.analysis
|
||||
partitions: 6
|
||||
replicationFactor: 3
|
||||
|
||||
# =================================================================
|
||||
# Network Policies (from security audit)
|
||||
# =================================================================
|
||||
networkPolicies:
|
||||
enabled: true
|
||||
defaultDenyIngress: true
|
||||
defaultDenyEgress: true
|
||||
allowDNS: true
|
||||
|
||||
# =================================================================
|
||||
# SOPS Encryption
|
||||
# =================================================================
|
||||
sops:
|
||||
enabled: true
|
||||
ageKeyFile: /etc/sops/age.key
|
||||
secretsPath: trading-secrets.yaml
|
||||
33
trading-platform/helm/trading-secrets.yaml
Normal file
33
trading-platform/helm/trading-secrets.yaml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Trading Secrets - Encrypt with SOPS before applying
|
||||
# Usage: sops -e -i trading-secrets.yaml && kubectl apply -f trading-secrets.yaml
|
||||
#
|
||||
# DO NOT commit unencrypted secrets to git!
|
||||
# Generate secrets with: python -c "import secrets; print(secrets.token_urlsafe(24))"
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: trading-secrets
|
||||
namespace: customer1
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: security-audit
|
||||
annotations:
|
||||
secrets.yaml.sops.io/v2: encrypted
|
||||
type: Opaque
|
||||
stringData:
|
||||
# JWT authentication - use 32+ byte hex token
|
||||
EXECUTE_JWT_SECRET_KEY: ""
|
||||
|
||||
# Exchange private keys - NEVER commit plaintext!
|
||||
EXECUTE_HYPERLIQUID_PRIVATE_KEY: ""
|
||||
EXECUTE_SOLANA_PRIVATE_KEY_BASE58: ""
|
||||
|
||||
# Database credentials - use 24+ byte URL-safe tokens
|
||||
POSTGRES_PASSWORD: ""
|
||||
NEWS_DB_PASSWORD: ""
|
||||
|
||||
# Redis password
|
||||
REDIS_PASSWORD: ""
|
||||
|
||||
# Kafka SASL authentication
|
||||
KAFKA_SASL_USERNAME: ""
|
||||
KAFKA_SASL_PASSWORD: ""
|
||||
Loading…
Reference in a new issue