feat: poblar scaffold inicial del shape rest-api/python
Reemplaza el placeholder mínimo previo por el scaffold canónico del golden path rest-api/python (entry point para tier free-trial): - code/app/main.py — FastAPI con /health (sin DB), /metrics, middleware correlation_id, settings Pydantic - code/tests/ — pytest + httpx TestClient (sin testcontainers, sin Docker) - helm/APP_NAME/ — chart minimal: Deployment, Service, IngressRoute, NetworkPolicy. SIN Job Alembic, SIN ServiceMonitor, SIN claim de BD - coralware-shape.yaml — shapeVersion 1.0.0, minTier free-trial, promotionPath -> web-backend-python cuando se requiera persistencia - .gitea/workflows/APP_NAME-build.yaml — invoca reusable workflow ADR-038 + job helm-deploy con KUBECONFIG_TENANT_B64 Diferencias con web-backend/python: sin alembic, sin BD, sin testcontainers, NetworkPolicy sin acceso a ns-addons. Placeholders __APP_NAME__, __TIER__, __TENANT_ID__, __TENANT_ID_NODASHES__ serán sustituidos server-side por repo-provisioner. El openspec/ del golden path NO se sincroniza al repo Gitea (gobernanza interna de Coralware). Refs: ADR-027 (Golden Paths), ADR-038 (CI), ADR-053 (referencia anatomía).
This commit is contained in:
9
helm/APP_NAME/.helmignore
Normal file
9
helm/APP_NAME/.helmignore
Normal file
@@ -0,0 +1,9 @@
|
||||
.DS_Store
|
||||
.git/
|
||||
.gitignore
|
||||
.bzr/
|
||||
.hg/
|
||||
.svn/
|
||||
*.tmproj
|
||||
.vscode/
|
||||
.idea/
|
||||
12
helm/APP_NAME/Chart.yaml
Normal file
12
helm/APP_NAME/Chart.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: v2
|
||||
name: __APP_NAME__
|
||||
description: Helm chart del Golden Path rest-api/python
|
||||
type: application
|
||||
version: 0.1.0
|
||||
appVersion: "0.1.0"
|
||||
keywords:
|
||||
- fastapi
|
||||
- rest-api
|
||||
- coralware-cove
|
||||
maintainers:
|
||||
- name: __OWNER__
|
||||
24
helm/APP_NAME/templates/_helpers.tpl
Normal file
24
helm/APP_NAME/templates/_helpers.tpl
Normal file
@@ -0,0 +1,24 @@
|
||||
{{/*
|
||||
Labels comunes a todos los recursos del chart.
|
||||
Sigue convenciones CLAUDE.md global + IDP (idp.coralware.cloud/*).
|
||||
*/}}
|
||||
{{- define "app.labels" -}}
|
||||
app.kubernetes.io/name: {{ .Chart.Name }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
app.kubernetes.io/part-of: {{ .Chart.Name }}
|
||||
idp.coralware.cloud/tier: {{ .Values.tier | quote }}
|
||||
idp.coralware.cloud/tenant-id: {{ .Values.tenantId | quote }}
|
||||
idp.coralware.cloud/golden-path: {{ .Values.goldenPath }}
|
||||
idp.coralware.cloud/golden-path-lang: {{ .Values.goldenPathLang }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels — subset estable usado en Deployment.spec.selector y Service.spec.selector.
|
||||
NO debe incluir labels que cambien (version, tier).
|
||||
*/}}
|
||||
{{- define "app.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ .Chart.Name }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
80
helm/APP_NAME/templates/deployment.yaml
Normal file
80
helm/APP_NAME/templates/deployment.yaml
Normal file
@@ -0,0 +1,80 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
labels:
|
||||
{{- include "app.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "app.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "app.labels" . | nindent 8 }}
|
||||
spec:
|
||||
serviceAccountName: {{ .Release.Name }}
|
||||
imagePullSecrets:
|
||||
- name: {{ .Values.image.pullSecret }}
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1001
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: app
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8000
|
||||
protocol: TCP
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: {{ .Release.Name }}-config
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.probes.liveness.periodSeconds }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: http
|
||||
initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.probes.readiness.periodSeconds }}
|
||||
failureThreshold: {{ .Values.probes.readiness.failureThreshold }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop: ["ALL"]
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
labels:
|
||||
{{- include "app.labels" . | nindent 4 }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-config
|
||||
labels:
|
||||
{{- include "app.labels" . | nindent 4 }}
|
||||
data:
|
||||
LOG_LEVEL: {{ .Values.config.logLevel | quote }}
|
||||
CORRELATION_ID_HEADER: {{ .Values.config.correlationIdHeader | quote }}
|
||||
OPENAPI_REQUIRE_AUTH: {{ .Values.config.openapiRequireAuth | quote }}
|
||||
KEYCLOAK_ISSUER: {{ .Values.config.keycloakIssuer | quote }}
|
||||
19
helm/APP_NAME/templates/ingressroute.yaml
Normal file
19
helm/APP_NAME/templates/ingressroute.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
{{- if .Values.ingress.enabled }}
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
labels:
|
||||
{{- include "app.labels" . | nindent 4 }}
|
||||
spec:
|
||||
entryPoints:
|
||||
- websecure
|
||||
routes:
|
||||
- match: Host(`{{ .Values.ingress.host }}`)
|
||||
kind: Rule
|
||||
services:
|
||||
- name: {{ .Release.Name }}
|
||||
port: {{ .Values.service.port }}
|
||||
tls:
|
||||
secretName: {{ .Values.ingress.tlsSecretName }}
|
||||
{{- end }}
|
||||
57
helm/APP_NAME/templates/networkpolicy.yaml
Normal file
57
helm/APP_NAME/templates/networkpolicy.yaml
Normal file
@@ -0,0 +1,57 @@
|
||||
{{- if .Values.networkPolicy.enabled }}
|
||||
# NetworkPolicy mínima del shape rest-api: bajo deny-all-default del namespace, permite:
|
||||
# - Ingress: Traefik (público) + Prometheus (scrape de /metrics).
|
||||
# - Egress: DNS, Harbor pull HTTPS.
|
||||
# Sin acceso a ns-addons (rest-api no tiene BD por diseño).
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
labels:
|
||||
{{- include "app.labels" . | nindent 4 }}
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
{{- include "app.selectorLabels" . | nindent 6 }}
|
||||
policyTypes: [Ingress, Egress]
|
||||
|
||||
ingress:
|
||||
# Tráfico HTTP desde Traefik (IngressRoute)
|
||||
- from:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: traefik-system
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 8000
|
||||
# Scrape de métricas Prometheus
|
||||
- from:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: cattle-monitoring-system
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: prometheus
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 8000
|
||||
|
||||
egress:
|
||||
# DNS
|
||||
- to:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: kube-system
|
||||
ports:
|
||||
- protocol: UDP
|
||||
port: 53
|
||||
- protocol: TCP
|
||||
port: 53
|
||||
# Harbor pull (registro de imágenes) — HTTPS abierto
|
||||
- to:
|
||||
- ipBlock:
|
||||
cidr: 0.0.0.0/0
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 443
|
||||
{{- end }}
|
||||
15
helm/APP_NAME/templates/service.yaml
Normal file
15
helm/APP_NAME/templates/service.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
labels:
|
||||
{{- include "app.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
selector:
|
||||
{{- include "app.selectorLabels" . | nindent 4 }}
|
||||
ports:
|
||||
- name: http
|
||||
port: {{ .Values.service.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
52
helm/APP_NAME/values.yaml
Normal file
52
helm/APP_NAME/values.yaml
Normal file
@@ -0,0 +1,52 @@
|
||||
# Defaults sensatos para tier free-trial. El CI inyecta tier/tenantId via --set
|
||||
# leyendo valores del TenantProfile correspondiente.
|
||||
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: registry.coralsafety.com/__TENANT_ID_NODASHES__/__APP_NAME__
|
||||
tag: latest
|
||||
pullPolicy: Always
|
||||
pullSecret: harbor-tenant-pull
|
||||
|
||||
# Identidad del tenant — populated por --set desde el CI
|
||||
tenantId: ""
|
||||
tenantIdNodashes: ""
|
||||
tier: free-trial
|
||||
goldenPath: rest-api
|
||||
goldenPathLang: python
|
||||
|
||||
config:
|
||||
logLevel: INFO
|
||||
correlationIdHeader: X-Correlation-ID
|
||||
openapiRequireAuth: false
|
||||
keycloakIssuer: ""
|
||||
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 64Mi
|
||||
limits:
|
||||
cpu: 250m
|
||||
memory: 256Mi
|
||||
|
||||
probes:
|
||||
liveness:
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 10
|
||||
readiness:
|
||||
initialDelaySeconds: 3
|
||||
periodSeconds: 5
|
||||
failureThreshold: 3
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 8000
|
||||
|
||||
ingress:
|
||||
enabled: true
|
||||
host: __APP_NAME__-__TENANT_ID_NODASHES__.apps.coralware.cloud
|
||||
tlsSecretName: __APP_NAME__-tls
|
||||
|
||||
networkPolicy:
|
||||
enabled: true
|
||||
Reference in New Issue
Block a user