#env:
#  - name: DEPLOY_MODE
#    value: "kubernetes"
#  - name: BACKEND_PORT
#    value: "8090"
 
#---

# --- DEPLOYMENT --------------------------------------------

apiVersion: apps/v1
kind: Deployment
metadata:
  name: iching-broker-0-0-1
  namespace: argocd
spec:
  selector:
    matchLabels:
      app: iching-broker
  template:
    metadata:
      labels:
        app: iching-broker
    spec:
      containers:
      - image: gitea-192-168-197-2.c-one-infra.de/giteaadmin/iching-broker:development
        name: iching-broker
        imagePullPolicy: Always
 
---

# --- SERVICE -----------------------------------------------

apiVersion: v1
kind: Service
metadata:
  name: iching-service
  namespace: argocd
spec:
  selector:
    app: iching-broker
  ports:
    - name: frontend
      port: 80
      targetPort: 8080
    - name: backend
      port: 81
      targetPort: 8090

---

# --- INGRESS: Frontend -------------------------------------

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: iching-frontend-ingress
  namespace: argocd
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  ingressClassName: nginx
  rules:
    - host: 192-168-197-2.c-one-infra.de
      http:
        paths:
          - path: /iching(/|$)(.*)
            pathType: ImplementationSpecific
            backend:
              service:
                name: iching-service
                port:
                  number: 80
  tls:
    - hosts:
        - 192-168-197-2.c-one-infra.de
      secretName: argocd-net-tls

---

# --- INGRESS: Backend ---------------------------------------

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: iching-backend-ingress
  namespace: argocd
spec:
  ingressClassName: nginx
  rules:
    - host: 192-168-197-2.c-one-infra.de
      http:
        paths:
          - path: /iching/api(/|$)(.*)
            pathType: ImplementationSpecific
            backend:
              service:
                name: iching-service
                port:
                  number: 81
  tls:
    - hosts:
        - 192-168-197-2.c-one-infra.de
      secretName: argocd-net-tls
