apiVersion: v1
kind: Service
metadata:
  name: skolplattformen-api
  namespace: skolplattformen
spec:
  ports:
  - port: 9000
  type: LoadBalancer
  selector:
    app: skolplattformen-api
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: skolplattformen-api
  namespace: skolplattformen
spec:
  selector:
    matchLabels:
      app: skolplattformen-api
  template:
    metadata:
      labels:
        app: skolplattformen-api
    spec:
      containers:
      - name: skolplattformen-api
        image: irony/skolplattformen-api
        ports:
        - containerPort: 9000
        env:
        - name: JWT_SECRET
          valueFrom:
            secretKeyRef:
              name: app-secrets
              key: JWT_SECRET
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: skolplattformen-api-ingress
  namespace: skolplattformen
  annotations:
    kubernetes.io/ingress.class: "nginx"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
  tls:
  - hosts:
    - api.skolplattformen.org
    secretName: skolplattformen-api-prod-tls
  rules:
  - host: api.skolplattformen.org
    http:
      paths:
      - backend:
          serviceName: skolplattformen-api
          servicePort: 9000