apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: lacchain-bootnode
  labels:
    app: lacchain-bootnode
  namespace: lacchain-david19
spec:
  replicas: 1
  selector:
    matchLabels:
      app: lacchain-bootnode
  serviceName: lacchain-bootnode
  template:
    metadata:
      labels:
        app: lacchain-bootnode
    spec:
      nodeName: gke-cluster-lacchain-default-pool-5e107968-hpx1
      containers:
        - name: lacchain-bootnode
          image: lacnetnetworks/lacchain-besu:21.1.6
          imagePullPolicy: IfNotPresent
          resources:
            requests:
              cpu: 500m
              memory: 1024Mi
            limits:
              cpu: 1000m
              memory: 2048Mi
          env:
          - name: BESU_LOGGING
            value: INFO 
          - name: P2P_HOST
            value: "34.68.48.0"
          - name: P2P_PORT
            value: "60606"
          volumeMounts:
            - name: genesis-config
              mountPath: /etc/genesis
              readOnly: true
            - name: config-toml-template
              mountPath: /besu-tmp
              readOnly: true
            - name: data
              mountPath: data
          ports:
            - containerPort: 4545
              name: json-rpc
              protocol: TCP
            - containerPort: 4546
              name: ws
              protocol: TCP
            - containerPort: 4547
              name: graphql
              protocol: TCP
            - containerPort: 60606
              name: rlpx
              protocol: TCP
            - containerPort: 60606
              name: discovery
              protocol: UDP
          command:
            - /bin/sh
            - -c
          args:
            - |
             exec 
             envsubst < /besu-tmp/config.toml.template > /opt/lacchain/config.toml;
             /opt/besu/bin/besu --genesis-file=/etc/genesis/genesis.json --data-path=/data public-key  export --to=/data/bootnode ;
             sleep 2;
             /opt/besu/bin/besu --node-private-key-file=/data/key --config-file=/opt/lacchain/config.toml --network-id=648530
      securityContext:
        fsGroup: 2000
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: pvc-data-bootnode
        - name: config-toml-template
          configMap:
            name: besu-config-toml-configmap-bootnode
        - name: genesis-config
          configMap:
            name: besu-genesis-configmap