This commit is contained in:
PB
2025-11-23 21:49:18 +01:00
parent d5596b59cb
commit 68d0f3d48d
18 changed files with 268 additions and 54 deletions

View File

@@ -2,7 +2,7 @@ apiVersion: v1
kind: PersistentVolume
metadata:
name: api-cache-pv
namespace: egommerce
# namespace: egommerce
spec:
capacity:
storage: 5Gi

View File

@@ -2,7 +2,7 @@ apiVersion: v1
kind: PersistentVolume
metadata:
name: api-eventbus-pv
namespace: egommerce
# namespace: egommerce
spec:
capacity:
storage: 10Gi
@@ -41,7 +41,7 @@ spec:
protocol: TCP
port: 9092
nodePort: 31200
- name: api-eventbus-controller
- name: api-eventbus-ctrl
protocol: TCP
port: 9093
nodePort: 31299
@@ -68,7 +68,7 @@ spec:
imagePullPolicy: Always # For future image
ports:
- containerPort: 9092
name: eventbus
name: eventbus-brkr
- containerPort: 9093
name: eventbus-ctrl
volumeMounts:
@@ -79,14 +79,16 @@ spec:
value: "broker,controller"
- name: KAFKA_CONTROLLER_LISTENER_NAMES
value: "CONTROLLER"
- name: KAFKA_NODE_ID
value: "1"
- name: KAFKA_LISTENERS
value: "PLAINTEXT://:9092,CONTROLLER://:9093"
- name: KAFKA_CONTROLLER_QUORUM_VOTERS
value: "1@localhost:9093"
- name: KAFKA_NODE_ID
value: "1"
value: "1@api-eventbus:9093"
- name: KAFKA_ADVERTISED_LISTENERS
value: "PLAINTEXT://localhost:9092"
value: "PLAINTEXT://api-eventbus:9092"
- name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
value: "1"
- name: KAFKA_LOG_DIRS
value: "/var/lib/kafka/data"
imagePullSecrets:

View File

@@ -1,4 +1,20 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: api-gateway-config
namespace: egommerce
data:
global-config-snippet: |
# lua-prepend-path /usr/local/lib/lua/5.4/?.lua
# set-dumpable
log 127.0.0.1 local0 debug
lua-load /etc/haproxy/lua/jwt_auth.lua
frontend-config-snippet: |
http-request lua.jwt_auth
http-response lua.jwt_auth
# http-request deny if !{ var(txn.authenticated) -m bool }
---
apiVersion: v1
kind: Service
metadata:
name: api-gateway
@@ -18,11 +34,10 @@ spec:
kind: IngressClass
apiVersion: networking.k8s.io/v1
metadata:
name: haproxy
name: api-gateway
namespace: egommerce
spec:
controller: haproxy.org/ingress-controller/haproxy
# PROBABLY NOT NEEDED :D
---
apiVersion: networking.k8s.io/v1
kind: Ingress
@@ -32,18 +47,23 @@ metadata:
annotations:
haproxy.org/server-ssl: "true"
haproxy.org/server-ca: "egommerce/ca-root"
haproxy.org/server-alpn: "h2,http/1.1"
haproxy.org/enable-lua: "true"
haproxy.org/backend-config-snippet: |
http-response set-header X-Custom-Backend-Header "value"
haproxy.org/path-rewrite: |
/api/identity/(.*) /\1
/api/catalog/(.*) /\1
/api/basket/(.*) /\1
/api/config/(.*) /\1
spec:
ingressClassName: haproxy
ingressClassName: api-gateway
tls:
- secretName: api-gateway-cert
hosts:
- egommerce.io # CHANGE TO PROD DOMAIN
- egommerce.io # CHANGE TO THE PROD DOMAIN
rules:
- host: egommerce.io # CHANGE TO PROD DOMAIN
- host: egommerce.io # CHANGE TO THE PROD DOMAIN
http:
paths:
- path: /api/identity
@@ -67,6 +87,13 @@ spec:
name: basket-svc
port:
number: 443
- path: /api/config
pathType: Prefix
backend:
service:
name: config-svc
port:
number: 443
---
apiVersion: apps/v1
kind: Deployment
@@ -88,19 +115,13 @@ spec:
- name: api-gateway
image: git.ego.freeddns.org/egommerce/api-gateway:dev
imagePullPolicy: Always
resources:
limits:
cpu: 100m
memory: 512M
requests:
cpu: 50m
memory: 256M
ports:
- containerPort: 8443
args:
- --publish-service=egommerce/api-gateway
- --configmap=egommerce/api-gateway-config
- --ingress.class=haproxy
- --https-bind-port=8443
ports:
- containerPort: 8443
env:
- name: POD_NAME
valueFrom:
@@ -112,22 +133,34 @@ spec:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
securityContext:
capabilities:
add:
- NET_BIND_SERVICE
drop:
- ALL
# - name: POD_IP
# valueFrom:
# fieldRef:
# apiVersion: v1
# fieldPath: status.podIP
resources:
limits:
cpu: 100m
memory: 512M
requests:
cpu: 50m
memory: 256M
# securityContext:
# capabilities:
# add:
# - NET_BIND_SERVICE
# drop:
# - ALL
# readOnlyRootFilesystem: false
# runAsUser: 1000
# runAsGroup: 1000
# runAsNonRoot: true
# allowPrivilegeEscalation: false
# seccompProfile:
# type: RuntimeDefault
volumes:
- name: api-gateway-config
configMap:
name: api-gateway-config
imagePullSecrets:
- name: regcred

View File

@@ -159,7 +159,7 @@ apiVersion: v1
kind: PersistentVolume
metadata:
name: api-logger-prometheus-pv
namespace: egommerce
# namespace: egommerce
spec:
capacity:
storage: 5Gi
@@ -325,7 +325,7 @@ apiVersion: v1
kind: PersistentVolume
metadata:
name: api-logger-grafana-pv
namespace: egommerce
# namespace: egommerce
spec:
capacity:
storage: 5Gi

133
deploy/k8s/config-svc.yml Normal file
View File

@@ -0,0 +1,133 @@
apiVersion: v1
kind: Service
metadata:
name: config-svc
namespace: egommerce
annotations:
haproxy.org/check: "true"
labels:
app: config-svc
spec:
type: NodePort
selector:
app: config-svc
ports:
- name: config-svc
port: 443
nodePort: 31811
# - name: config-svc-metrics
# port: 9090
# nodePort: 31811
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: config-svc
namespace: egommerce
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1 # Number of extra pods that can be created during update
maxUnavailable: 1 # Max number of pods that can be unavailable during update
selector:
matchLabels:
app: config-svc
template:
metadata:
labels:
app: config-svc
spec:
# initContainers:
# - name: config-svc-init
# image: busybox:1.28
# command: [
# 'sh',
# '-c',
# '/bin/migrate'
# ]
containers:
- name: config-svc
image: git.ego.freeddns.org/egommerce/config-svc:dev
imagePullPolicy: Always
env:
- name: APP_NAME
value: config-svc
- name: APP_DOMAIN
value: config-svc.egommerce.io
- name: APP_PATH_PREFIX
value: /config
- name: API_DATABASE_URL
value: postgres://egommerce:12345678@db-postgres:5432/egommerce?sslmode=disable
readinessProbe:
httpGet:
scheme: HTTPS
port: config-svc
path: /health
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 1
livenessProbe:
httpGet:
scheme: HTTPS
port: config-svc
path: /health
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 1
volumeMounts:
- name: config-cert
mountPath: /certs/config-svc.crt
readOnly: true
- name: config-key
mountPath: /certs/config-svc.key
readOnly: true
- name: config-migrations
mountPath: /migrations
readOnly: true
resources:
limits:
cpu: 100m
memory: 512M
requests:
cpu: 50m
memory: 256M
ports:
- name: config-svc
containerPort: 443
# - name: config-svc-metrics
# image: prom/prometheus-exporter:latest
# ports:
# - containerPort: 9090
# args:
# - --web.listen-address=:9090
# - --web.telemetry-path=/metrics
# - name: config-scheduler # Scheduler Container
# image: git.ego.freeddns.org/egommerce/config-svc:dev
# imagePullPolicy: Always
# command: [
# "/usr/local/bin/scheduler"
# ]
# resources:
# limits:
# cpu: 100m
# memory: 512Mi
# requests:
# cpu: 50m
# memory: 256Mi
imagePullSecrets:
- name: regcred
volumes:
- name: config-cert
hostPath:
path: /egommerce/stack/deploy/certs/config-svc/config-svc.crt
type: File
- name: config-key
hostPath:
path: /egommerce/stack/deploy/certs/config-svc/config-svc.key
type: File
- name: config-migrations
hostPath:
path: /egommerce/stack/deploy/db_migrations/config-svc
type: Directory

View File

@@ -2,7 +2,7 @@ apiVersion: v1
kind: PersistentVolume
metadata:
name: db-postgres-pv
namespace: egommerce
# namespace: egommerce
spec:
capacity:
storage: 5Gi

View File

@@ -5,6 +5,8 @@ metadata:
namespace: egommerce
annotations:
haproxy.org/check: "true"
# haproxy.org/backend-config-snippet: |
# http-response set-header X-Custom-Header-Service "rojter"
labels:
app: identity-svc
spec: