apiVersion: apps/v1
kind: Deployment
metadata:
  name: happy-up-api
  labels:
    app: happy-up-api
spec:
  replicas: 2
  selector:
    matchLabels:
      app: happy-up-api
  template:
    metadata:
      labels:
        app: happy-up-api
    spec:
      containers:
        - name: api
          image: registry.example.com/happy-up/api:latest
          ports:
            - containerPort: 8000
          envFrom:
            - configMapRef:
                name: happy-up-api-config
            - secretRef:
                name: happy-up-api-secret
          readinessProbe:
            httpGet:
              path: /health
              port: 8000
            initialDelaySeconds: 5
            periodSeconds: 10
          livenessProbe:
            httpGet:
              path: /health
              port: 8000
            initialDelaySeconds: 15
            periodSeconds: 20
          resources:
            requests:
              cpu: 200m
              memory: 256Mi
            limits:
              cpu: "1"
              memory: 512Mi
---
apiVersion: v1
kind: Service
metadata:
  name: happy-up-api
spec:
  selector:
    app: happy-up-api
  ports:
    - port: 80
      targetPort: 8000
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: happy-up-api-config
data:
  APP_ENV: production
  APP_DEBUG: "false"
  ANALYSIS_INLINE_PROCESS: "false"
  OSS_ENABLED: "true"
  OSS_PROVIDER: aliyun
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: happy-up-api
spec:
  rules:
    - host: api.happy-up.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: happy-up-api
                port:
                  number: 80
