
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: reader
spec:
  selector:
    matchLabels:
      app: reader # has to match .spec.template.metadata.labels
  serviceName: "reader"
  replicas: 1 # by default is 1
  template:
    metadata:
      labels:
        app: reader # has to match .spec.selector.matchLabels
        klight.networkId: myFirstNetwork # the label that KLight operator listens to to connect the pod to the network.
    spec:
      containers:
      - name: reader
        image: localhost:32000/reader:0.1.0
        imagePullPolicy: Always
        command: ["./reader"]
        args: ["-lpAddress=$(LP_ADDRESS)"]
        env:
          - name: LP_ADDRESS
            value: ":9081"
      - name: lightpeer
        image: localhost:32000/lightpeer:v0.1.0-k8s
        imagePullPolicy: Always
        command: ["./lightpeer"]
        args: ["-repo=$(LP_BLOCKREPO)", "-host=0.0.0.0", "-otlp=otel-collector.observability.svc.cluster.local:55680", "-v"]
        resources:
          limits:
            cpu: 100m
            memory: 100Mi
          requests:
            cpu: 50m
            memory: 50Mi
        env:
          - name: LP_BLOCKREPO
            value: "/blockRepository"
        ports:
        - containerPort: 9081 # gRPC port.
        volumeMounts:
        - name: reader-lightpeer-sto
          mountPath: /blockRepository
  volumeClaimTemplates:
  - metadata:
      name: reader-lightpeer-sto
      namespace: lightchain
    spec:
      accessModes: 
        - ReadWriteOnce
      resources:
        requests:
          storage: 50Mi
