# 02-web-app-ingress — Deployment + Service + Ingress + HPA + ServiceMonitor.

# Fixes the name prefix every resource carries. Without it the Service would be
# <release>-universal-helm-chart-web, and the Ingress backend below has to spell out
# whatever the chart renders.
fullnameOverride: webapp

integrations:
  monitoring:
    defaults:
      enabled: true                # opt-in monitoring; per-workload metrics.enabled remains the override
      provider: prometheus
      discovery: crd
      type: service

ingress:
  enabled: true
  ingressClassName: nginx
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
  hosts:
    web.example.com:
      paths:
        - path: /
          pathType: Prefix
          serviceName: webapp-web   # <fullnameOverride>-<workload>
          servicePort: 80
  tls:
    - hosts:
        - web.example.com
      secretName: web-example-tls

deployments:
  web:
    enabled: true
    image:
      repository: nginx
      tag: "1.27"
      pullPolicy: IfNotPresent

    service:
      enabled: true
      type: ClusterIP
      ports:
        http:
          port: 80
          targetPort: 8080
        metrics:
          port: 9090
          targetPort: 9090

    metrics:
      enabled: true
      port: metrics                # name from service.ports — required by ServiceMonitor CRD
      path: /metrics
      interval: 30s

    hpa:
      enabled: true
      minReplicas: 2
      maxReplicas: 10
      metrics:
        - type: Resource
          resource:
            name: cpu
            target:
              type: Utilization
              averageUtilization: 70

    resources:
      requests:
        cpu: 100m
        memory: 128Mi
      limits:
        memory: 256Mi
