# // Copyright 2020 Stefan Prisca
# //
# // Licensed under the Apache License, Version 2.0 (the "License");
# // you may not use this file except in compliance with the License.
# // You may obtain a copy of the License at
# //
# //     http://www.apache.org/licenses/LICENSE-2.0
# //
# // Unless required by applicable law or agreed to in writing, software
# // distributed under the License is distributed on an "AS IS" BASIS,
# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# // See the License for the specific language governing permissions and
# // limitations under the License.

apiVersion: v1
kind: Pod
metadata:
  name: lightwriter
  labels:
    klight.networkId : k8sPodNetwork
spec:
  volumes:
  - name: tempsto
    emptyDir: {}
  containers:
  - name: klightpeer
    image: localhost:32000/klight.peer:v0.1.0-k8s
    imagePullPolicy: Always
    command: ["./klightpeer"]
    args: ["-repo=$(LP_BLOCKREPO)", "-host=0.0.0.0", "-otlp=otel-collector.observability.svc.cluster.local:55680", "-v", "-statePath=$(STATE_PATH)"]
    resources:
      limits:
        cpu: 100m
        memory: 100Mi
      requests:
        cpu: 50m
        memory: 50Mi
    env:
      - name: LP_BLOCKREPO
        value: "/usr/share/tempsto"
      - name: STATE_PATH
        value: "/usr/share/tempsto/index.html" 
    ports:
    - containerPort: 9081 # gRPC port.
    volumeMounts:
    - name: tempsto
      mountPath: /usr/share/tempsto
  - name: writer
    image: debian
    volumeMounts:
    - name: tempsto
      mountPath: /tempsto
    command: ["/bin/sh", "-c"]
    args:
      - while true; do
          date >> /tempsto/index.html;
          sleep 1;
        done