kind: Deployment
apiVersion: apps/v1beta1
metadata:
  name: node
  namespace: pow
  labels:
    universe: geth
    component: node
spec:
  replicas: 3
  selector: 
    matchLabels:
      universe: geth
      component: node
  template:
    metadata:
      labels:
        universe: geth
        component: node
    spec:
      priorityClassName: batch-priority
      containers:
        - name: node
          image: ethereum/client-go:alltools-stable
          ports: 
           - containerPort: 8545
             name: rpc
           - containerPort: 8546
             name: ws
           - containerPort: 30303
             name: discovery-tcp
             protocol: TCP
           - containerPort: 30303
             name: discovery-udp
             protocol: UDP
          # Use /bin/sh -c to execute geth so that we have access to HOSTNAME in 
          # the command arguments.
          # https://github.com/kubernetes/kubernetes/issues/57726
          command:
            - "/bin/sh"
            - "-c"
            - >
              geth
              --networkid=1337
              --bootnodesv4=enode://$(BOOTNODE_PUBKEY)@$(GETH_BOOTNODE_V4_SERVICE_HOST):$(GETH_BOOTNODE_V4_SERVICE_PORT_BOOTNODE_UDP) 
              --bootnodesv5=enode://$(BOOTNODE_PUBKEY)@$(GETH_BOOTNODE_V5_SERVICE_HOST):$(GETH_BOOTNODE_V5_SERVICE_PORT_BOOTNODE_UDP)
              --ethstats=$HOSTNAME:$(ETHSTATS_WS_SECRET)@$(GETH_ETHSTATS_SERVICE_HOST):$(GETH_ETHSTATS_SERVICE_PORT)
              --rpc
              --rpcaddr=0.0.0.0
              --rpccorsdomain="*"
              --rpcvhosts="*"
              --ws
              --wsaddr=0.0.0.0
              --wsorigins="*"
              --datadir=/ethereum
              --debug
              --verbosity=4
              --nousb
              --lightserv=50
          volumeMounts:
            - name: chaindata
              mountPath: "/ethereum"
          env:
            - name: ETHSTATS_WS_SECRET
              valueFrom:
                secretKeyRef:
                  name: ethstats-secrets
                  key: ws
            - name: BOOTNODE_PUBKEY
              valueFrom:
                secretKeyRef:
                  name: geth-bootnode-secret
                  key: public_key
          resources:
            requests:
              memory: "500Mi"
              cpu: "100m"
            limits:
              memory: "500Mi"
              cpu: "100m"
      initContainers:
        - name: genesis
          image: ethereum/client-go:alltools-stable
          command: ["geth"]
          args: ["--datadir=/ethereum", "init", "/data/genesis.json"]
          volumeMounts:
            - name: genesis
              mountPath: "/data"
              readOnly: true
            - name: chaindata
              mountPath: "/ethereum"
      volumes:
        - name: chaindata
          emptyDir: {}
        - name: genesis
          configMap: 
            name: genesis
            items:
              - key: json
                path: genesis.json