From 5a1c5fd874b11de3d9c9dd2a69aa21021868730b Mon Sep 17 00:00:00 2001 From: Mizuki Date: Tue, 30 Jan 2024 16:15:03 +0900 Subject: [PATCH] Use sts for op-geth/node and use LoadBalancer for op-geth and blockscout --- templates/k8s/blockscout-deployment.yaml | 1 - .../k8s/blockscout-postgres-deployment.yaml | 1 - templates/k8s/blockscout-service.yaml | 3 +- templates/k8s/env-cm.yaml | 2 ++ templates/k8s/env-secret.yaml | 4 +++ templates/k8s/op-batcher-deployment.yaml | 8 +++-- templates/k8s/op-geth-pvc.yaml | 11 ------- templates/k8s/op-geth-service.yaml | 1 + ...-geth-deployment.yaml => op-geth-sts.yaml} | 20 +++++++----- templates/k8s/op-node-pvc.yaml | 11 ------- templates/k8s/op-node-service.yaml | 4 +++ ...-node-deployment.yaml => op-node-sts.yaml} | 31 ++++++++++++------- templates/k8s/op-proposer-deployment.yaml | 10 ++++-- 13 files changed, 58 insertions(+), 49 deletions(-) delete mode 100644 templates/k8s/op-geth-pvc.yaml rename templates/k8s/{op-geth-deployment.yaml => op-geth-sts.yaml} (92%) delete mode 100644 templates/k8s/op-node-pvc.yaml rename templates/k8s/{op-node-deployment.yaml => op-node-sts.yaml} (77%) diff --git a/templates/k8s/blockscout-deployment.yaml b/templates/k8s/blockscout-deployment.yaml index 3dc1115..0fa09d1 100644 --- a/templates/k8s/blockscout-deployment.yaml +++ b/templates/k8s/blockscout-deployment.yaml @@ -134,7 +134,6 @@ spec: name: blockscout ports: - containerPort: 4000 - hostPort: 4000 protocol: TCP volumeMounts: - mountPath: /genesis.json diff --git a/templates/k8s/blockscout-postgres-deployment.yaml b/templates/k8s/blockscout-postgres-deployment.yaml index c5dea6d..e251b53 100644 --- a/templates/k8s/blockscout-postgres-deployment.yaml +++ b/templates/k8s/blockscout-postgres-deployment.yaml @@ -32,7 +32,6 @@ spec: volumeMounts: - mountPath: /var/lib/postgresql/data name: blockscout-postgres-pvc - restartPolicy: Always volumes: - name: blockscout-postgres-pvc persistentVolumeClaim: diff --git a/templates/k8s/blockscout-service.yaml b/templates/k8s/blockscout-service.yaml index 45ba856..4c2b071 100644 --- a/templates/k8s/blockscout-service.yaml +++ b/templates/k8s/blockscout-service.yaml @@ -6,7 +6,8 @@ metadata: spec: selector: name: blockscout + type: LoadBalancer ports: - protocol: TCP - port: 4000 + port: 80 targetPort: 4000 diff --git a/templates/k8s/env-cm.yaml b/templates/k8s/env-cm.yaml index 2516a41..5099442 100644 --- a/templates/k8s/env-cm.yaml +++ b/templates/k8s/env-cm.yaml @@ -4,3 +4,5 @@ metadata: name: env-cm namespace: l2launcher data: + L1_RPC: "" + L2_CHAIN_ID: "" diff --git a/templates/k8s/env-secret.yaml b/templates/k8s/env-secret.yaml index 638ccd0..c10fa28 100644 --- a/templates/k8s/env-secret.yaml +++ b/templates/k8s/env-secret.yaml @@ -4,3 +4,7 @@ metadata: name: env-secret namespace: l2launcher stringData: + ADMIN_KEY: "" + BATCHER_KEY: "" + PROPOSER_KEY: "" + SEQUENCER_KEY: "" diff --git a/templates/k8s/op-batcher-deployment.yaml b/templates/k8s/op-batcher-deployment.yaml index 149e6cd..ac6c59e 100644 --- a/templates/k8s/op-batcher-deployment.yaml +++ b/templates/k8s/op-batcher-deployment.yaml @@ -41,9 +41,11 @@ spec: key: L1_RPC - name: BATCHER_KEY valueFrom: - configMapKeyRef: - name: env-cm + secretKeyRef: + name: env-secret key: BATCHER_KEY image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-batcher:v1.4.2 name: op-batcher - restartPolicy: Always + ports: + - containerPort: 8548 + protocol: TCP diff --git a/templates/k8s/op-geth-pvc.yaml b/templates/k8s/op-geth-pvc.yaml deleted file mode 100644 index 5ae9929..0000000 --- a/templates/k8s/op-geth-pvc.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: op-geth-pvc - namespace: l2launcher -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 100Mi diff --git a/templates/k8s/op-geth-service.yaml b/templates/k8s/op-geth-service.yaml index ece045e..f8f6fe7 100644 --- a/templates/k8s/op-geth-service.yaml +++ b/templates/k8s/op-geth-service.yaml @@ -6,6 +6,7 @@ metadata: spec: selector: name: op-geth + type: LoadBalancer ports: - protocol: TCP name: rpc diff --git a/templates/k8s/op-geth-deployment.yaml b/templates/k8s/op-geth-sts.yaml similarity index 92% rename from templates/k8s/op-geth-deployment.yaml rename to templates/k8s/op-geth-sts.yaml index d7df3a8..745d112 100644 --- a/templates/k8s/op-geth-deployment.yaml +++ b/templates/k8s/op-geth-sts.yaml @@ -1,5 +1,5 @@ apiVersion: apps/v1 -kind: Deployment +kind: StatefulSet metadata: name: op-geth namespace: l2launcher @@ -7,7 +7,7 @@ spec: selector: matchLabels: name: op-geth - replicas: 1 + replicas: 2 template: metadata: labels: @@ -54,7 +54,7 @@ spec: name: genesis-init-predeploy volumeMounts: - mountPath: /data - name: op-geth-pvc + name: op-geth-volume - mountPath: /genesis name: genesis-pvc - mountPath: /genesis/predeploy.json @@ -102,7 +102,7 @@ spec: protocol: TCP volumeMounts: - mountPath: /data - name: op-geth-pvc + name: op-geth-volume - mountPath: /genesis name: genesis-pvc readOnly: true @@ -110,9 +110,15 @@ spec: - name: genesis-pvc persistentVolumeClaim: claimName: genesis-pvc - - name: op-geth-pvc - persistentVolumeClaim: - claimName: op-geth-pvc - name: predeploy-json-cm configMap: name: predeploy-json-cm + volumeClaimTemplates: + - metadata: + name: op-geth-volume + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Mi diff --git a/templates/k8s/op-node-pvc.yaml b/templates/k8s/op-node-pvc.yaml deleted file mode 100644 index 54227b7..0000000 --- a/templates/k8s/op-node-pvc.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: op-node-pvc - namespace: l2launcher -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 100Mi diff --git a/templates/k8s/op-node-service.yaml b/templates/k8s/op-node-service.yaml index e883244..7df3815 100644 --- a/templates/k8s/op-node-service.yaml +++ b/templates/k8s/op-node-service.yaml @@ -8,5 +8,9 @@ spec: name: op-node ports: - protocol: TCP + name: rpc port: 8547 targetPort: 8547 + - protocol: TCP + name: p2p + port: 9003 diff --git a/templates/k8s/op-node-deployment.yaml b/templates/k8s/op-node-sts.yaml similarity index 77% rename from templates/k8s/op-node-deployment.yaml rename to templates/k8s/op-node-sts.yaml index c2f4c8f..ce21843 100644 --- a/templates/k8s/op-node-deployment.yaml +++ b/templates/k8s/op-node-sts.yaml @@ -1,10 +1,10 @@ apiVersion: apps/v1 -kind: Deployment +kind: StatefulSet metadata: name: op-node namespace: l2launcher spec: - replicas: 1 + replicas: 2 selector: matchLabels: name: op-node @@ -25,8 +25,9 @@ spec: --rollup.config=/genesis/rollup.json \ --rpc.addr=0.0.0.0 \ --rpc.port=8547 \ - --p2p.disable \ --rpc.enable-admin \ + --p2p.listen.ip=0.0.0.0 \ + --p2p.listen.tcp=9003 \ --p2p.sequencer.key=$${SEQUENCER_KEY#0x} \ --l1=$(L1_RPC) \ --l1.rpckind=any \ @@ -42,8 +43,8 @@ spec: key: L1_RPC - name: SEQUENCER_KEY valueFrom: - configMapKeyRef: - name: env-cm + secretKeyRef: + name: env-secret key: SEQUENCER_KEY image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:v1.4.2 livenessProbe: @@ -57,18 +58,26 @@ spec: name: op-node ports: - containerPort: 8547 - hostPort: 8547 + protocol: TCP + - containerPort: 9003 protocol: TCP volumeMounts: - mountPath: /data - name: op-node-pvc + name: op-node-volume - mountPath: /genesis name: genesis-pvc - restartPolicy: Always + readOnly: true volumes: - - name: op-node-pvc - persistentVolumeClaim: - claimName: op-node-pvc - name: genesis-pvc persistentVolumeClaim: claimName: genesis-pvc + readOnly: true + volumeClaimTemplates: + - metadata: + name: op-node-volume + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Mi diff --git a/templates/k8s/op-proposer-deployment.yaml b/templates/k8s/op-proposer-deployment.yaml index 9165bb9..f59da3d 100644 --- a/templates/k8s/op-proposer-deployment.yaml +++ b/templates/k8s/op-proposer-deployment.yaml @@ -31,19 +31,23 @@ spec: key: L1_RPC - name: PROPOSER_KEY valueFrom: - configMapKeyRef: - name: env-cm + secretKeyRef: + name: env-secret key: PROPOSER_KEY command: - sh - -c image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-proposer:v1.4.2 name: op-proposer + ports: + - containerPort: 8560 + protocol: TCP volumeMounts: - mountPath: /genesis name: genesis-pvc - restartPolicy: Always + readOnly: true volumes: - name: genesis-pvc persistentVolumeClaim: claimName: genesis-pvc + readOnly: true