refactor(frontend): migrar a base+overlay de platform-templates
Reemplaza frontend.yaml + patches/frontend-resources.yaml por un overlay de Kustomize sobre el base remoto de platform-templates (workloads/ecommerce/frontend/). Agrega readinessProbe/livenessProbe (no tenia ninguna, apuntando a /api/health que ya expone el propio Dockerfile) y securityContext (capabilities NET_BIND_SERVICE agregada de vuelta por el puerto 80 privilegiado -- frontend ya corre no-root de antes, sin el problema de chown que tuvo docs-portal). El Ingress generico del base se excluye via $patch:delete -- frontend comparte ecommerce-ingress con catalog-api-svc, no le corresponde un Ingress propio. Validado con kubectl kustomize contra el arbol completo de workloads/ecommerce antes de aplicar. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FqYP3Wf1W63Qmh7qgXAAT
This commit is contained in:
1 parent
827086049c
commit
d0ecb5ef16
6 files changed
+135
-75
No files matched your search
@@ -1,43 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: frontend-deploy
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: frontend
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: frontend
|
|
||||||
spec:
|
|
||||||
imagePullSecrets:
|
|
||||||
- name: gitea-registry-secret
|
|
||||||
containers:
|
|
||||||
- name: web
|
|
||||||
image: gitea.cruzcloud.net/devops/ecommerce-frontend:v1.0.104
|
|
||||||
ports:
|
|
||||||
- containerPort: 80
|
|
||||||
env:
|
|
||||||
- name: HEADLESS_PROVIDER
|
|
||||||
value: medusa
|
|
||||||
- name: MEDUSA_BACKEND_URL
|
|
||||||
value: http://medusa-svc:9000
|
|
||||||
- name: MEDUSA_REGION_ID
|
|
||||||
value: reg_01KZT86WPAH7A7ZZRDSX3350V2
|
|
||||||
envFrom:
|
|
||||||
- secretRef:
|
|
||||||
name: commerce-storefront
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: frontend-svc
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: frontend
|
|
||||||
ports:
|
|
||||||
- protocol: TCP
|
|
||||||
port: 80
|
|
||||||
targetPort: 80
|
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
namespace: ecommerce
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- https://gitea.cruzcloud.net/devops/platform-templates.git//k8s-manifests/base?ref=main
|
||||||
|
|
||||||
|
patches:
|
||||||
|
# frontend comparte "ecommerce-ingress" con catalog-api-svc (path-based,
|
||||||
|
# un solo Ingress con 2 backends) -- no le corresponde el Ingress
|
||||||
|
# genérico de 1-backend del base. Se borra del output de este overlay;
|
||||||
|
# ecommerce-ingress se queda tal cual está, definido fuera de acá.
|
||||||
|
# (Kustomize no soporta referenciar solo algunos archivos de un
|
||||||
|
# directorio remoto vía git -- probado en vivo, "expecting directory".
|
||||||
|
# Traer el base completo y borrar lo que no aplica es el patrón real.)
|
||||||
|
- target:
|
||||||
|
kind: Ingress
|
||||||
|
name: app-ingress
|
||||||
|
patch: |-
|
||||||
|
$patch: delete
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: app-ingress
|
||||||
|
- target:
|
||||||
|
kind: Deployment
|
||||||
|
name: app-deployment
|
||||||
|
path: patches/deployment.yaml
|
||||||
|
- target:
|
||||||
|
kind: Service
|
||||||
|
name: app-svc
|
||||||
|
path: patches/service.yaml
|
||||||
|
|
||||||
|
- target:
|
||||||
|
kind: Deployment
|
||||||
|
name: app-deployment
|
||||||
|
patch: |-
|
||||||
|
- op: replace
|
||||||
|
path: /metadata/name
|
||||||
|
value: frontend-deploy
|
||||||
|
- op: replace
|
||||||
|
path: /spec/template/spec/containers/0/ports
|
||||||
|
value:
|
||||||
|
- name: http
|
||||||
|
containerPort: 80
|
||||||
|
- target:
|
||||||
|
kind: Service
|
||||||
|
name: app-svc
|
||||||
|
patch: |-
|
||||||
|
- op: replace
|
||||||
|
path: /metadata/name
|
||||||
|
value: frontend-svc
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: app-deployment
|
||||||
|
labels:
|
||||||
|
app: frontend
|
||||||
|
spec:
|
||||||
|
replicas: 2
|
||||||
|
strategy:
|
||||||
|
type: RollingUpdate
|
||||||
|
rollingUpdate:
|
||||||
|
maxUnavailable: 0
|
||||||
|
maxSurge: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: frontend
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: frontend
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: app
|
||||||
|
image: gitea.cruzcloud.net/devops/ecommerce-frontend:v1.0.104
|
||||||
|
env:
|
||||||
|
- name: HEADLESS_PROVIDER
|
||||||
|
value: medusa
|
||||||
|
- name: MEDUSA_BACKEND_URL
|
||||||
|
value: http://medusa-svc:9000
|
||||||
|
- name: MEDUSA_REGION_ID
|
||||||
|
value: reg_01KZT86WPAH7A7ZZRDSX3350V2
|
||||||
|
envFrom:
|
||||||
|
- secretRef:
|
||||||
|
name: commerce-storefront
|
||||||
|
# El base usa "/" por default. El Dockerfile de frontend ya
|
||||||
|
# define su propio HEALTHCHECK contra /api/health -- usamos
|
||||||
|
# el mismo endpoint acá en vez del genérico del base, ya
|
||||||
|
# sabemos que existe y responde.
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /api/health
|
||||||
|
port: http
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /api/health
|
||||||
|
port: http
|
||||||
|
# El Dockerfile de frontend ya corre como usuario "nextjs" no-root
|
||||||
|
# (a diferencia de docs-portal) -- runAsNonRoot: true del base
|
||||||
|
# se queda tal cual, sin override.
|
||||||
|
#
|
||||||
|
# Sí hace falta NET_BIND_SERVICE: el puerto real es 80
|
||||||
|
# (privilegiado, <1024). El Dockerfile ya hace setcap sobre el
|
||||||
|
# binario de node para esto, pero eso solo funciona si el
|
||||||
|
# bounding set del contenedor lo permite -- drop: ALL del base
|
||||||
|
# lo bloquea igual, root o no root. Mismo motivo que docs-portal.
|
||||||
|
securityContext:
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
readOnlyRootFilesystem: false
|
||||||
|
capabilities:
|
||||||
|
drop:
|
||||||
|
- ALL
|
||||||
|
add:
|
||||||
|
- NET_BIND_SERVICE
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 256Mi
|
||||||
|
limits:
|
||||||
|
cpu: "1"
|
||||||
|
memory: 768Mi
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: app-svc
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: frontend
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 80
|
||||||
|
targetPort: 80
|
||||||
@@ -2,19 +2,12 @@ apiVersion: kustomize.config.k8s.io/v1beta1
|
|||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
- frontend.yaml
|
- frontend/
|
||||||
- catalog-api.yaml
|
- catalog-api.yaml
|
||||||
- ingress.yaml
|
- ingress.yaml
|
||||||
|
|
||||||
- commerce/
|
- commerce/
|
||||||
patches:
|
patches:
|
||||||
- path: patches/frontend-resources.yaml
|
|
||||||
target:
|
|
||||||
group: apps
|
|
||||||
version: v1
|
|
||||||
kind: Deployment
|
|
||||||
name: frontend-deploy
|
|
||||||
|
|
||||||
- path: patches/catalog-resources.yaml
|
- path: patches/catalog-resources.yaml
|
||||||
target:
|
target:
|
||||||
group: apps
|
group: apps
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: frontend-deploy
|
|
||||||
spec:
|
|
||||||
replicas: 2
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
type: RollingUpdate
|
|
||||||
rollingUpdate:
|
|
||||||
maxUnavailable: 0
|
|
||||||
maxSurge: 1
|
|
||||||
|
|
||||||
template:
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: web
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 100m
|
|
||||||
memory: 256Mi
|
|
||||||
limits:
|
|
||||||
cpu: "1"
|
|
||||||
memory: 768Mi
|
|
||||||
Reference in new issue
Block a user