apiVersion: apps/v1
kind: Deployment
metadata:
  name: kubethor-backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kubethor-backend
  template:
    metadata:
      labels:
        app: kubethor-backend
    spec:
      containers:
        - name: kubethor-backend
          image: CHANGE_DOCKER_IMAGE_LINK
          ports:
            - containerPort: 8080
          resources:
            requests:
              memory: "64Mi"
              cpu: "250m"
            limits:
              memory: "128Mi"
              cpu: "500m"
          livenessProbe:
            httpGet:
              path: /healthz
              port: 8080
            initialDelaySeconds: 5
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /ready
              port: 8080
            initialDelaySeconds: 10
            periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
  name: kubethor-backend
spec:
  selector:
    app: kubethor-backend
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 8080
  type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: kubethor-backend
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/force-ssl-redirect: "false"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
    nginx.ingress.kubernetes.io/session-cookie-expires: "172800"
    nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"
  labels:
    app.kubernetes.io/name: kubethor-backend
spec:
  defaultBackend:
    service:
      name: kubethor-backend
      port:
        number: 8080
  rules:
    - host: CHANGE_HOST_URL
      http:
        paths:
          - path: "/"
            pathType: Prefix
            backend:
              service:
                name: kubethor-backend
                port:
                  number: 8080
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: kubethor-backend-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: kubethor-backend
  minReplicas: 1
  maxReplicas: 5
  targetCPUUtilizationPercentage: 50
