apiVersion: apps/v1
kind: Deployment
metadata:
  name: oracle-publisher
  namespace: besu-network
  labels:
    app: oracle-publisher
spec:
  replicas: 1
  selector:
    matchLabels:
      app: oracle-publisher
  template:
    metadata:
      labels:
        app: oracle-publisher
    spec:
      containers:
        - name: oracle-publisher
          image: oracle-publisher:v1.0.0
          imagePullPolicy: IfNotPresent
          env:
            - name: RPC_URL
              valueFrom:
                configMapKeyRef:
                  name: oracle-config
                  key: rpc_url
            - name: AGGREGATOR_ADDRESS
              valueFrom:
                configMapKeyRef:
                  name: oracle-config
                  key: aggregator_address
            - name: PRIVATE_KEY
              valueFrom:
                secretKeyRef:
                  name: oracle-keys
                  key: private_key
            - name: HEARTBEAT
              valueFrom:
                configMapKeyRef:
                  name: oracle-config
                  key: heartbeat
            - name: DEVIATION_THRESHOLD
              valueFrom:
                configMapKeyRef:
                  name: oracle-config
                  key: deviation_threshold
            - name: DATA_SOURCE_1_URL
              valueFrom:
                configMapKeyRef:
                  name: oracle-config
                  key: data_source_1_url
            - name: DATA_SOURCE_1_PARSER
              valueFrom:
                configMapKeyRef:
                  name: oracle-config
                  key: data_source_1_parser
          resources:
            requests:
              cpu: "100m"
              memory: "256Mi"
            limits:
              cpu: "500m"
              memory: "512Mi"
          livenessProbe:
            httpGet:
              path: /metrics
              port: 8000
            initialDelaySeconds: 30
            periodSeconds: 30
          readinessProbe:
            httpGet:
              path: /metrics
              port: 8000
            initialDelaySeconds: 10
            periodSeconds: 10
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: oracle-config
  namespace: besu-network
data:
  rpc_url: "http://besu-rpc:8545"
  aggregator_address: ""
  heartbeat: "60"
  deviation_threshold: "0.5"
  data_source_1_url: ""
  data_source_1_parser: "price"
---
apiVersion: v1
kind: Service
metadata:
  name: oracle-publisher
  namespace: besu-network
  labels:
    app: oracle-publisher
spec:
  type: ClusterIP
  ports:
    - name: metrics
      port: 8000
      targetPort: 8000
      protocol: TCP
  selector:
    app: oracle-publisher

