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
71
trading-platform/deploy/k8s/base/api-gateway-deployment.yaml
Normal file
71
trading-platform/deploy/k8s/base/api-gateway-deployment.yaml
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: api-gateway
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: api-gateway
|
||||
app.kubernetes.io/name: api-gateway
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: api-gateway
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: api-gateway
|
||||
app.kubernetes.io/name: api-gateway
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
fsGroup: 1000
|
||||
containers:
|
||||
- name: api-gateway
|
||||
image: "trading-platform/api-gateway:v${VERSION}"
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
protocol: TCP
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: trading-platform-config
|
||||
resources:
|
||||
limits:
|
||||
cpu: "500m"
|
||||
memory: 256Mi
|
||||
requests:
|
||||
cpu: "250m"
|
||||
memory: 128Mi
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 8080
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 8080
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
readOnlyRootFilesystem: true
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
27
trading-platform/deploy/k8s/base/api-gateway-hpa.yaml
Normal file
27
trading-platform/deploy/k8s/base/api-gateway-hpa.yaml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: api-gateway-hpa
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: api-gateway
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: api-gateway
|
||||
minReplicas: 2
|
||||
maxReplicas: 10
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
||||
18
trading-platform/deploy/k8s/base/api-gateway-service.yaml
Normal file
18
trading-platform/deploy/k8s/base/api-gateway-service.yaml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: api-gateway
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: api-gateway
|
||||
app.kubernetes.io/name: api-gateway
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 8080
|
||||
targetPort: 8080
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
app: api-gateway
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: api-gateway-mtls-cert
|
||||
namespace: customer1
|
||||
spec:
|
||||
secretName: api-gateway-mtls-secret
|
||||
duration: 2160h # 90 days
|
||||
renewBefore: 360h # 15 days
|
||||
commonName: api-gateway.customer1.svc.cluster.local
|
||||
dnsNames:
|
||||
- api-gateway
|
||||
- api-gateway.customer1
|
||||
- api-gateway.customer1.svc
|
||||
- api-gateway.customer1.svc.cluster.local
|
||||
usages:
|
||||
- digital signature
|
||||
- key encipherment
|
||||
- client auth
|
||||
- server auth
|
||||
issuerRef:
|
||||
name: trading-platform-ca-issuer
|
||||
kind: Issuer
|
||||
group: cert-manager.io
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
apiVersion: cert-manager.io/v1
|
||||
kind: Issuer
|
||||
metadata:
|
||||
name: trading-platform-ca-issuer
|
||||
namespace: customer1
|
||||
spec:
|
||||
ca:
|
||||
secretName: trading-platform-ca-secret
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
apiVersion: cert-manager.io/v1
|
||||
kind: ClusterIssuer
|
||||
metadata:
|
||||
name: letsencrypt-prod
|
||||
spec:
|
||||
acme:
|
||||
server: https://acme-v02.api.letsencrypt.org/directory
|
||||
email: [email protected]
|
||||
privateKeySecretRef:
|
||||
name: letsencrypt-prod-key
|
||||
solvers:
|
||||
- http01:
|
||||
ingress:
|
||||
class: nginx
|
||||
---
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: ClusterIssuer
|
||||
metadata:
|
||||
name: letsencrypt-staging
|
||||
spec:
|
||||
acme:
|
||||
server: https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
email: [email protected]
|
||||
privateKeySecretRef:
|
||||
name: letsencrypt-staging-key
|
||||
solvers:
|
||||
- http01:
|
||||
ingress:
|
||||
class: nginx
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: dashboard-mtls-cert
|
||||
namespace: customer1
|
||||
spec:
|
||||
secretName: dashboard-mtls-secret
|
||||
duration: 2160h # 90 days
|
||||
renewBefore: 360h # 15 days
|
||||
commonName: dashboard.customer1.svc.cluster.local
|
||||
dnsNames:
|
||||
- dashboard
|
||||
- dashboard.customer1
|
||||
- dashboard.customer1.svc
|
||||
- dashboard.customer1.svc.cluster.local
|
||||
usages:
|
||||
- digital signature
|
||||
- key encipherment
|
||||
- client auth
|
||||
- server auth
|
||||
issuerRef:
|
||||
name: trading-platform-ca-issuer
|
||||
kind: Issuer
|
||||
group: cert-manager.io
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: data-service-mtls-cert
|
||||
namespace: customer1
|
||||
spec:
|
||||
secretName: data-service-mtls-secret
|
||||
duration: 2160h # 90 days
|
||||
renewBefore: 360h # 15 days
|
||||
commonName: data-service.customer1.svc.cluster.local
|
||||
dnsNames:
|
||||
- data-service
|
||||
- data-service.customer1
|
||||
- data-service.customer1.svc
|
||||
- data-service.customer1.svc.cluster.local
|
||||
usages:
|
||||
- digital signature
|
||||
- key encipherment
|
||||
- client auth
|
||||
- server auth
|
||||
issuerRef:
|
||||
name: trading-platform-ca-issuer
|
||||
kind: Issuer
|
||||
group: cert-manager.io
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: execute-service-mtls-cert
|
||||
namespace: customer1
|
||||
spec:
|
||||
secretName: execute-service-mtls-secret
|
||||
duration: 2160h # 90 days
|
||||
renewBefore: 360h # 15 days
|
||||
commonName: execute-service.customer1.svc.cluster.local
|
||||
dnsNames:
|
||||
- execute-service
|
||||
- execute-service.customer1
|
||||
- execute-service.customer1.svc
|
||||
- execute-service.customer1.svc.cluster.local
|
||||
usages:
|
||||
- digital signature
|
||||
- key encipherment
|
||||
- client auth
|
||||
- server auth
|
||||
issuerRef:
|
||||
name: trading-platform-ca-issuer
|
||||
kind: Issuer
|
||||
group: cert-manager.io
|
||||
24
trading-platform/deploy/k8s/base/cert-manager/issuer.yaml
Normal file
24
trading-platform/deploy/k8s/base/cert-manager/issuer.yaml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
apiVersion: cert-manager.io/v1
|
||||
kind: Issuer
|
||||
metadata:
|
||||
name: selfsigned-issuer
|
||||
namespace: cert-manager
|
||||
spec:
|
||||
selfSigned: {}
|
||||
---
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: trading-platform-ca
|
||||
namespace: cert-manager
|
||||
spec:
|
||||
isCA: true
|
||||
commonName: trading-platform-ca
|
||||
secretName: trading-platform-ca-secret
|
||||
privateKey:
|
||||
algorithm: ECDSA
|
||||
size: 256
|
||||
issuerRef:
|
||||
name: selfsigned-issuer
|
||||
kind: Issuer
|
||||
group: cert-manager.io
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: news-service-mtls-cert
|
||||
namespace: customer1
|
||||
spec:
|
||||
secretName: news-service-mtls-secret
|
||||
duration: 2160h # 90 days
|
||||
renewBefore: 360h # 15 days
|
||||
commonName: news-service.customer1.svc.cluster.local
|
||||
dnsNames:
|
||||
- news-service
|
||||
- news-service.customer1
|
||||
- news-service.customer1.svc
|
||||
- news-service.customer1.svc.cluster.local
|
||||
usages:
|
||||
- digital signature
|
||||
- key encipherment
|
||||
- client auth
|
||||
- server auth
|
||||
issuerRef:
|
||||
name: trading-platform-ca-issuer
|
||||
kind: Issuer
|
||||
group: cert-manager.io
|
||||
71
trading-platform/deploy/k8s/base/dashboard-deployment.yaml
Normal file
71
trading-platform/deploy/k8s/base/dashboard-deployment.yaml
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: dashboard
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: dashboard
|
||||
app.kubernetes.io/name: dashboard
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: dashboard
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: dashboard
|
||||
app.kubernetes.io/name: dashboard
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
fsGroup: 1000
|
||||
containers:
|
||||
- name: dashboard
|
||||
image: "trading-platform/dashboard:v${VERSION}"
|
||||
ports:
|
||||
- containerPort: 3000
|
||||
protocol: TCP
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: trading-platform-config
|
||||
resources:
|
||||
limits:
|
||||
cpu: "500m"
|
||||
memory: 512Mi
|
||||
requests:
|
||||
cpu: "250m"
|
||||
memory: 256Mi
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 3000
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 3000
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
readOnlyRootFilesystem: true
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
27
trading-platform/deploy/k8s/base/dashboard-hpa.yaml
Normal file
27
trading-platform/deploy/k8s/base/dashboard-hpa.yaml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: dashboard-hpa
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: dashboard
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: dashboard
|
||||
minReplicas: 2
|
||||
maxReplicas: 10
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
||||
18
trading-platform/deploy/k8s/base/dashboard-service.yaml
Normal file
18
trading-platform/deploy/k8s/base/dashboard-service.yaml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: dashboard
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: dashboard
|
||||
app.kubernetes.io/name: dashboard
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 3000
|
||||
targetPort: 3000
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
app: dashboard
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: data-service
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: data-service
|
||||
app.kubernetes.io/name: data-service
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: data-service
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: data-service
|
||||
app.kubernetes.io/name: data-service
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
fsGroup: 1000
|
||||
containers:
|
||||
- name: data-service
|
||||
image: "trading-platform/data-service:v${VERSION}"
|
||||
ports:
|
||||
- containerPort: 8001
|
||||
protocol: TCP
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: trading-platform-config
|
||||
resources:
|
||||
limits:
|
||||
cpu: "1000m"
|
||||
memory: 1Gi
|
||||
requests:
|
||||
cpu: "500m"
|
||||
memory: 512Mi
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 8001
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 8001
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
readOnlyRootFilesystem: true
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
27
trading-platform/deploy/k8s/base/data-service-hpa.yaml
Normal file
27
trading-platform/deploy/k8s/base/data-service-hpa.yaml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: data-service-hpa
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: data-service
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: data-service
|
||||
minReplicas: 2
|
||||
maxReplicas: 10
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
||||
18
trading-platform/deploy/k8s/base/data-service-service.yaml
Normal file
18
trading-platform/deploy/k8s/base/data-service-service.yaml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: data-service
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: data-service
|
||||
app.kubernetes.io/name: data-service
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 8001
|
||||
targetPort: 8001
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
app: data-service
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: execute-service
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: execute-service
|
||||
app.kubernetes.io/name: execute-service
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: execute-service
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: execute-service
|
||||
app.kubernetes.io/name: execute-service
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
fsGroup: 1000
|
||||
containers:
|
||||
- name: execute-service
|
||||
image: "trading-platform/execute-service:v${VERSION}"
|
||||
ports:
|
||||
- containerPort: 8000
|
||||
protocol: TCP
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: trading-platform-config
|
||||
resources:
|
||||
limits:
|
||||
cpu: "500m"
|
||||
memory: 512Mi
|
||||
requests:
|
||||
cpu: "250m"
|
||||
memory: 256Mi
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 8000
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 8000
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
readOnlyRootFilesystem: true
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
27
trading-platform/deploy/k8s/base/execute-service-hpa.yaml
Normal file
27
trading-platform/deploy/k8s/base/execute-service-hpa.yaml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: execute-service-hpa
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: execute-service
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: execute-service
|
||||
minReplicas: 2
|
||||
maxReplicas: 10
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: execute-service
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: execute-service
|
||||
app.kubernetes.io/name: execute-service
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 8000
|
||||
targetPort: 8000
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
app: execute-service
|
||||
40
trading-platform/deploy/k8s/base/ingress.yaml
Normal file
40
trading-platform/deploy/k8s/base/ingress.yaml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: api-gateway-ingress
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: api-gateway
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
||||
nginx.ingress.kubernetes.io/proxy-body-size: "10m"
|
||||
nginx.ingress.kubernetes.io/rate-limit: "100"
|
||||
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
tls:
|
||||
- hosts:
|
||||
- api.trading.example.com
|
||||
- dashboard.trading.example.com
|
||||
secretName: trading-tls-secret
|
||||
rules:
|
||||
- host: api.trading.example.com
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: api-gateway
|
||||
port:
|
||||
number: 8080
|
||||
- host: dashboard.trading.example.com
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: dashboard
|
||||
port:
|
||||
number: 3000
|
||||
18
trading-platform/deploy/k8s/base/namespace.yaml
Normal file
18
trading-platform/deploy/k8s/base/namespace.yaml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: customer1
|
||||
labels:
|
||||
name: customer1
|
||||
istio-injection: disabled # Disable Istio if using native K8s policies
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: trading-platform-config
|
||||
namespace: customer1
|
||||
data:
|
||||
KAFKA_BOOTSTRAP_SERVERS: "kafka-headless:9092"
|
||||
REDIS_URL: "redis://redis-master:6379/0"
|
||||
LOG_LEVEL: "info"
|
||||
TRADING_ENV: "production"
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: news-service
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: news-service
|
||||
app.kubernetes.io/name: news-service
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: news-service
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: news-service
|
||||
app.kubernetes.io/name: news-service
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
fsGroup: 1000
|
||||
containers:
|
||||
- name: news-service
|
||||
image: "trading-platform/news-service:v${VERSION}"
|
||||
ports:
|
||||
- containerPort: 8002
|
||||
protocol: TCP
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: trading-platform-config
|
||||
resources:
|
||||
limits:
|
||||
cpu: "1000m"
|
||||
memory: 1Gi
|
||||
requests:
|
||||
cpu: "500m"
|
||||
memory: 512Mi
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 8002
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 8002
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
readOnlyRootFilesystem: true
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
27
trading-platform/deploy/k8s/base/news-service-hpa.yaml
Normal file
27
trading-platform/deploy/k8s/base/news-service-hpa.yaml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: news-service-hpa
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: news-service
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: news-service
|
||||
minReplicas: 2
|
||||
maxReplicas: 10
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
||||
18
trading-platform/deploy/k8s/base/news-service-service.yaml
Normal file
18
trading-platform/deploy/k8s/base/news-service-service.yaml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: news-service
|
||||
namespace: customer1
|
||||
labels:
|
||||
app: news-service
|
||||
app.kubernetes.io/name: news-service
|
||||
app.kubernetes.io/component: microservice
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- port: 8002
|
||||
targetPort: 8002
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
app: news-service
|
||||
Loading…
Reference in a new issue