apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend
  namespace: bakery-ia
  labels:
    app.kubernetes.io/name: frontend
    app.kubernetes.io/component: frontend
    app.kubernetes.io/part-of: bakery-ia
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: frontend
      app.kubernetes.io/component: frontend
  template:
    metadata:
      labels:
        app.kubernetes.io/name: frontend
        app.kubernetes.io/component: frontend
    spec:
      containers:
      - name: frontend
        image: bakery/dashboard:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 3000
          name: http
        env:
        - name: NODE_ENV
          value: "production"
        envFrom:
        - configMapRef:
            name: bakery-config
        resources:
          requests:
            memory: "512Mi"
            cpu: "250m"
          limits:
            memory: "1Gi"
            cpu: "500m"
        livenessProbe:
          httpGet:
            path: /
            port: 3000
          initialDelaySeconds: 60
          timeoutSeconds: 10
          periodSeconds: 30
          failureThreshold: 3
        readinessProbe:
          httpGet:
            path: /
            port: 3000
          initialDelaySeconds: 20
          timeoutSeconds: 5
          periodSeconds: 10
          failureThreshold: 3

---
apiVersion: v1
kind: Service
metadata:
  name: frontend-service
  namespace: bakery-ia
  labels:
    app.kubernetes.io/name: frontend
    app.kubernetes.io/component: frontend
spec:
  type: ClusterIP
  ports:
  - port: 3000
    targetPort: 3000
    protocol: TCP
    name: http
  selector:
    app.kubernetes.io/name: frontend
    app.kubernetes.io/component: frontend
