{{- if .Values.ingress.enabled }}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: stonks-query-api-https
  namespace: {{ .Release.Namespace }}
  annotations:
    cert-manager.io/cluster-issuer: {{ .Values.ingress.clusterIssuer }}
spec:
  ingressClassName: {{ .Values.ingress.className }}
  tls:
    - hosts:
        - {{ .Values.ingress.hosts.queryApi }}
      secretName: stonks-api-tls
  rules:
    - host: {{ .Values.ingress.hosts.queryApi }}
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: query-api
                port:
                  number: 8000
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: stonks-registry-https
  namespace: {{ .Release.Namespace }}
  annotations:
    cert-manager.io/cluster-issuer: {{ .Values.ingress.clusterIssuer }}
spec:
  ingressClassName: {{ .Values.ingress.className }}
  tls:
    - hosts:
        - {{ .Values.ingress.hosts.symbolRegistry }}
      secretName: stonks-registry-tls
  rules:
    - host: {{ .Values.ingress.hosts.symbolRegistry }}
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: symbol-registry
                port:
                  number: 8000
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: stonks-superset-https
  namespace: {{ .Release.Namespace }}
  annotations:
    cert-manager.io/cluster-issuer: {{ .Values.ingress.clusterIssuer }}
spec:
  ingressClassName: {{ .Values.ingress.className }}
  tls:
    - hosts:
        - {{ .Values.ingress.hosts.superset }}
      secretName: stonks-dash-tls
  rules:
    - host: {{ .Values.ingress.hosts.superset }}
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: superset
                port:
                  number: 8088
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: stonks-trino-https
  namespace: {{ .Release.Namespace }}
  annotations:
    cert-manager.io/cluster-issuer: {{ .Values.ingress.clusterIssuer }}
spec:
  ingressClassName: {{ .Values.ingress.className }}
  tls:
    - hosts:
        - {{ .Values.ingress.hosts.trino }}
      secretName: stonks-trino-tls
  rules:
    - host: {{ .Values.ingress.hosts.trino }}
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: trino
                port:
                  number: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: stonks-trading-engine-https
  namespace: {{ .Release.Namespace }}
  annotations:
    cert-manager.io/cluster-issuer: {{ .Values.ingress.clusterIssuer }}
spec:
  ingressClassName: {{ .Values.ingress.className }}
  tls:
    - hosts:
        - {{ .Values.ingress.hosts.tradingEngine }}
      secretName: stonks-trading-tls
  rules:
    - host: {{ .Values.ingress.hosts.tradingEngine }}
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: trading-engine
                port:
                  number: 8000
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: stonks-dashboard-https
  namespace: {{ .Release.Namespace }}
  annotations:
    cert-manager.io/cluster-issuer: {{ .Values.ingress.clusterIssuer }}
spec:
  ingressClassName: {{ .Values.ingress.className }}
  tls:
    - hosts:
        - {{ .Values.ingress.hosts.dashboard }}
      secretName: stonks-dashboard-tls
  rules:
    - host: {{ .Values.ingress.hosts.dashboard }}
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: dashboard
                port:
                  number: 8080
{{- end }}
