apiVersion: v1
kind: ConfigMap
metadata:
  name: frontend-config
  namespace: dg0400-lifesub-ns
data:
  runtime-env.js: |
    window.__runtime_config__ = {
        MEMBER_URL: 'http://dg0400.20.214.196.128.nip.io/api/auth',
        MYSUB_URL: 'http://dg0400.20.214.196.128.nip.io/api/mysub',
        RECOMMEND_URL: 'http://dg0400.20.214.196.128.nip.io/api/recommend'
    };

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: lifesub-web
  namespace: dg0400-lifesub-ns
  labels:
    app: lifesub-web
spec:
  replicas: 2
  selector:
    matchLabels:
      app: lifesub-web
  template:
    metadata:
      labels:
        app: lifesub-web
    spec:
      imagePullSecrets:
      - name: acr-secret
      containers:
      - name: lifesub-web
        image: dg0400cr.azurecr.io/dg0400/lifesub-web:1.0.0
        imagePullPolicy: Always
        ports:
        - containerPort: 18080
        resources:
          requests:
            cpu: 256m
            memory: 256Mi
          limits:
            cpu: 1024m
            memory: 1024Mi
        volumeMounts:
        - name: runtime-config
          mountPath: /usr/share/nginx/html/runtime-env.js
          subPath: runtime-env.js
      volumes:
      - name: runtime-config
        configMap:
          name: frontend-config
          
---

apiVersion: v1
kind: Service
metadata:
  name: lifesub-web-service
  namespace: dg0400-lifesub-ns
  labels:
    app: lifesub-web
spec:
  type: ClusterIP
  ports:
  - port: 80
    targetPort: 18080
    protocol: TCP
  selector:
    app: lifesub-web

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: frontend-ingress
  namespace: dg0400-lifesub-ns
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: dg0400.20.249.113.122.nip.io
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: lifesub-web-service
            port:
              number: 80

