apiVersion: v1
kind: Service
metadata:
  name: static-fe-sync
  namespace: frontend-static
  labels:
    app: static-fe-sync
    service: static-fe-sync
spec:
  clusterIP: None
  ports:
  - port: 9080
    name: http-static-fe-sync
  selector:
    app: static-fe-sync
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: static-fe-sync
  namespace: frontend-static
spec:
  selector:
    matchLabels:
      name: static-fe-sync
  template:
    metadata:
      labels:
        name: static-fe-sync
        app: static-fe-sync
    spec:
      initContainers:
      - image: rclone/rclone
        command:
        - /entrypoint.sh
        imagePullPolicy: IfNotPresent
        volumeMounts:
          - name: sync-path
            mountPath: "/data"
          - name: config
            mountPath: "/config/rclone"
            readOnly: true
          - name: rclone-configmap-volume
            mountPath: /entrypoint.sh
            readOnly: true
            subPath: entrypoint.sh
        name: static-fe-rclone-init
      containers:
      - image: docker.adaoncloud.com/frontend/static-sync:test
        imagePullPolicy: IfNotPresent
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 200Mi
        env:
        - name: ADA_KAFKA_BROKER
          value: "ada-cluster-kafka-bootstrap.ada-kafka.svc.cluster.local:9092"
        - name: ADA_KAFKA_TOPIC
          value: "static-fe-sync"
        - name: ADA_NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: ADA_POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: ADA_POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: ADA_POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        volumeMounts:
          - name: sync-path
            mountPath: "/data"
          - name: config
            mountPath: "root/.config/rclone"
            readOnly: true
        name: static-fe-rclone
      imagePullSecrets:
      - name: ada-registry
      volumes:
        - name: config
          configMap:
            name: static-fe-cm
        - name: sync-path
          hostPath:
            path: "/mnt/data"
        - name: rclone-configmap-volume
          configMap:
            defaultMode: 0700
            name: rclone-configmap