diff --git a/Kubernetes/.helmignore b/Kubernetes/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/Kubernetes/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/Kubernetes/Chart.yaml b/Kubernetes/Chart.yaml new file mode 100644 index 0000000..bbd8c38 --- /dev/null +++ b/Kubernetes/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: DockerCompose-to-K8S +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/Kubernetes/templates/beacon-chain-service.yaml b/Kubernetes/templates/beacon-chain-service.yaml new file mode 100644 index 0000000..078664f --- /dev/null +++ b/Kubernetes/templates/beacon-chain-service.yaml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: Service +metadata: + name: beacon-chain + namespace: {{ .Release.Namespace }} +spec: + selector: + app: beacon-chain + ports: + - name: grpc-port + protocol: TCP + port: 4000 + targetPort: 4000 + - name: http-port + protocol: TCP + port: 3500 + targetPort: 3500 + - name: api-port + protocol: TCP + port: 8080 + targetPort: 8080 + - name: pprof-port + protocol: TCP + port: 6060 + targetPort: 6060 + - name: metrics-port + protocol: TCP + port: 9090 + targetPort: 9090 + type: ClusterIP diff --git a/Kubernetes/templates/beacon-chain.yaml b/Kubernetes/templates/beacon-chain.yaml new file mode 100644 index 0000000..bdf7fd6 --- /dev/null +++ b/Kubernetes/templates/beacon-chain.yaml @@ -0,0 +1,94 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: beacon-chain + namespace: {{ .Release.Namespace }} +spec: + replicas: 1 + selector: + matchLabels: + app: beacon-chain + template: + metadata: + labels: + app: beacon-chain + spec: + serviceAccountName: kubectl-sa + initContainers: + # - name: create-beacon-chain-genesis + # image: "{{ .Values.image.createBeaconChainGenesis }}" + # args: + # - testnet + # - generate-genesis + # - --fork=capella + # - --num-validators=64 + # - --genesis-time-delay=60 + # - --output-ssz={{ .Values.volumes.consensus }}/genesis.ssz + # - --chain-config-file={{ .Values.volumes.consensus }}/config.yml + # - --geth-genesis-json-in={{ .Values.volumes.execution }}/genesis.json + # - --geth-genesis-json-out={{ .Values.volumes.execution }}/genesis.json + # volumeMounts: + # - name: consensus + # mountPath: {{ .Values.volumes.consensus }} + # - name: execution + # mountPath: {{ .Values.volumes.execution }} + - name: wait-for-create-beacon-chain-genesis + image: "{{ .Values.image.kubectlImage }}" # This image includes kubectl and can be used to run wait commands + imagePullPolicy: "{{ .Values.image.pullPolicy }}" + command: + - /bin/sh + - -c + - | + echo "Waiting for create-beacon-chain-genesis Job to complete..." + until kubectl get job create-beacon-chain-genesis -n {{ .Release.Namespace }} -o jsonpath='{.status.succeeded}' | grep "1"; do + echo "Job not completed yet. Checking again in 10 seconds..." + sleep 10 + done + echo "create-beacon-chain-genesis Job completed successfully." + containers: + - name: beacon-chain + image: "{{ .Values.image.beaconChain }}" + imagePullPolicy: "{{ .Values.image.pullPolicy }}" + volumeMounts: + - name: consensus + mountPath: {{ .Values.volumes.consensus }} + - name: execution + mountPath: {{ .Values.volumes.execution }} + - name: jwtsecret-volume + mountPath: {{ .Values.volumes.execution }}/jwtsecret + subPath: jwtsecret + args: + - --datadir={{ .Values.volumes.consensus }}/beacondata + - --min-sync-peers=0 + - --genesis-state={{ .Values.volumes.consensus }}/genesis.ssz + - --bootstrap-node= + - --interop-eth1data-votes + - --chain-config-file={{ .Values.volumes.consensus }}/config.yml + - --contract-deployment-block=0 + - --chain-id=32382 + - --rpc-host=0.0.0.0 + - --grpc-gateway-host=0.0.0.0 + - --execution-endpoint=http://geth:8551 #geth clusterIP service + - --accept-terms-of-use + - --jwt-secret={{ .Values.volumes.execution }}/jwtsecret + - --suggested-fee-recipient=0x1d6197196c227e2be52c917b62343f7815638b2d + - --minimum-peers-per-subnet=0 + - --enable-debug-rpc-endpoints + - --force-clear-db + ports: + {{- range .Values.ports.beaconChain }} + - containerPort: {{ . }} + {{- end }} + + volumes: + - name: consensus + hostPath: + path: {{ .Values.volumes.localconsensus }} + - name: execution + hostPath: + path: {{ .Values.volumes.localexecution }} + - name: jwtsecret-volume + secret: + secretName: jwtsecret + nodeSelector: + kubernetes.io/arch: amd64 diff --git a/Kubernetes/templates/consensus-configmap.yaml b/Kubernetes/templates/consensus-configmap.yaml new file mode 100644 index 0000000..11b3870 --- /dev/null +++ b/Kubernetes/templates/consensus-configmap.yaml @@ -0,0 +1,35 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: mqube-config + namespace: {{ .Release.Namespace }} +data: + config.yml: | + CONFIG_NAME: interop + PRESET_BASE: interop + + # Genesis + GENESIS_FORK_VERSION: 0x20000089 + + # Altair + ALTAIR_FORK_EPOCH: 0 + ALTAIR_FORK_VERSION: 0x20000090 + + # Merge + BELLATRIX_FORK_EPOCH: 0 + BELLATRIX_FORK_VERSION: 0x20000091 + TERMINAL_TOTAL_DIFFICULTY: 0 + + # Capella + CAPELLA_FORK_EPOCH: 0 + CAPELLA_FORK_VERSION: 0x20000092 + MAX_WITHDRAWALS_PER_PAYLOAD: 16 + + DENEB_FORK_VERSION: 0x20000093 + + # Time parameters + SECONDS_PER_SLOT: 12 + SLOTS_PER_EPOCH: 6 + + # Deposit contract + DEPOSIT_CONTRACT_ADDRESS: 0x4242424242424242424242424242424242424242 diff --git a/Kubernetes/templates/create-beacon-chain-genesis.yaml b/Kubernetes/templates/create-beacon-chain-genesis.yaml new file mode 100644 index 0000000..46ac365 --- /dev/null +++ b/Kubernetes/templates/create-beacon-chain-genesis.yaml @@ -0,0 +1,36 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: create-beacon-chain-genesis +spec: + template: + spec: + containers: + - name: create-beacon-chain-genesis + image: "{{ .Values.image.createBeaconChainGenesis }}" + imagePullPolicy: "{{ .Values.image.pullPolicy }}" + args: + - testnet + - generate-genesis + - --fork=capella + - --num-validators=64 + - --genesis-time-delay=60 + - --output-ssz={{ .Values.volumes.consensus }}/genesis.ssz + - --chain-config-file={{ .Values.volumes.consensus }}/config.yml + - --geth-genesis-json-in={{ .Values.volumes.execution }}/genesis.json + - --geth-genesis-json-out={{ .Values.volumes.execution }}/genesis.json + volumeMounts: + - name: consensus + mountPath: {{ .Values.volumes.consensus }} + - name: execution + mountPath: {{ .Values.volumes.execution }} + restartPolicy: OnFailure + volumes: + - name: consensus + hostPath: + path: {{ .Values.volumes.localconsensus }} + - name: execution + hostPath: + path: {{ .Values.volumes.localexecution }} + nodeSelector: + kubernetes.io/arch: amd64 \ No newline at end of file diff --git a/Kubernetes/templates/enable-job-listing-role.yaml b/Kubernetes/templates/enable-job-listing-role.yaml new file mode 100644 index 0000000..aa7aeb5 --- /dev/null +++ b/Kubernetes/templates/enable-job-listing-role.yaml @@ -0,0 +1,9 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + namespace: {{ .Release.Namespace }} + name: job-reader +rules: +- apiGroups: ["batch"] + resources: ["jobs"] + verbs: ["get", "list"] diff --git a/Kubernetes/templates/execution-configmap.yaml b/Kubernetes/templates/execution-configmap.yaml new file mode 100644 index 0000000..05a6cbc --- /dev/null +++ b/Kubernetes/templates/execution-configmap.yaml @@ -0,0 +1,118 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: genesis-config + namespace: {{ .Release.Namespace }} +data: + genesis.json: | + { + "config": { + "chainId": 32382, + "homesteadBlock": 0, + "daoForkSupport": true, + "eip150Block": 0, + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "muirGlacierBlock": 0, + "berlinBlock": 0, + "londonBlock": 0, + "arrowGlacierBlock": 0, + "grayGlacierBlock": 0, + "shanghaiTime": 1694203366, + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true + }, + "nonce": "0x0", + "timestamp": "0x64fb7de6", + "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000123463a4b065722e99115d6c222f267d9cabb5240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "gasLimit": "0x1c9c380", + "difficulty": "0x1", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "alloc": { + "123463a4b065722e99115d6c222f267d9cabb524": { + "balance": "0x43c33c1937564800000" + }, + "14dc79964da2c08b23698b3d3cc7ca32193d9955": { + "balance": "0x21e19e0c9bab2400000" + }, + "15d34aaf54267db7d7c367839aaf71a00a2c6a65": { + "balance": "0x21e19e0c9bab2400000" + }, + "1cbd3b2770909d4e10f157cabc84c7264073c9ec": { + "balance": "0x21e19e0c9bab2400000" + }, + "23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f": { + "balance": "0x21e19e0c9bab2400000" + }, + "2546bcd3c84621e976d8185a91a922ae77ecec30": { + "balance": "0x21e19e0c9bab2400000" + }, + "3c44cdddb6a900fa2b585dd299e03d12fa4293bc": { + "balance": "0x21e19e0c9bab2400000" + }, + "4242424242424242424242424242424242424242": { + "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100b6578063621fd130146101e3578063c5f2892f14610273575b600080fd5b34801561005057600080fd5b5061009c6004803603602081101561006757600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916906020019092919050505061029e565b604051808215151515815260200191505060405180910390f35b6101e1600480360360808110156100cc57600080fd5b81019080803590602001906401000000008111156100e957600080fd5b8201836020820111156100fb57600080fd5b8035906020019184600183028401116401000000008311171561011d57600080fd5b90919293919293908035906020019064010000000081111561013e57600080fd5b82018360208201111561015057600080fd5b8035906020019184600183028401116401000000008311171561017257600080fd5b90919293919293908035906020019064010000000081111561019357600080fd5b8201836020820111156101a557600080fd5b803590602001918460018302840111640100000000831117156101c757600080fd5b909192939192939080359060200190929190505050610370565b005b3480156101ef57600080fd5b506101f8610fd0565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561023857808201518184015260208101905061021d565b50505050905090810190601f1680156102655780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561027f57600080fd5b50610288610fe2565b6040518082815260200191505060405180910390f35b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061036957507f85640907000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9050919050565b603087879050146103cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806116ec6026913960400191505060405180910390fd5b60208585905014610428576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260368152602001806116836036913960400191505060405180910390fd5b60608383905014610484576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602981526020018061175f6029913960400191505060405180910390fd5b670de0b6b3a76400003410156104e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806117396026913960400191505060405180910390fd5b6000633b9aca0034816104f457fe5b061461054b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806116b96033913960400191505060405180910390fd5b6000633b9aca00348161055a57fe5b04905067ffffffffffffffff80168111156105c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001806117126027913960400191505060405180910390fd5b60606105cb82611314565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a610600602054611314565b60405180806020018060200180602001806020018060200186810386528e8e82818152602001925080828437600081840152601f19601f82011690508083019250505086810385528c8c82818152602001925080828437600081840152601f19601f82011690508083019250505086810384528a818151815260200191508051906020019080838360005b838110156106a657808201518184015260208101905061068b565b50505050905090810190601f1680156106d35780820380516001836020036101000a031916815260200191505b508681038352898982818152602001925080828437600081840152601f19601f820116905080830192505050868103825287818151815260200191508051906020019080838360005b8381101561073757808201518184015260208101905061071c565b50505050905090810190601f1680156107645780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b6040516020018084848082843780830192505050826fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff1916815260100193505050506040516020818303038152906040526040518082805190602001908083835b6020831061080e57805182526020820191506020810190506020830392506107eb565b6001836020036101000a038019825116818451168082178552505050505050905001915050602060405180830381855afa158015610850573d6000803e3d6000fd5b5050506040513d602081101561086557600080fd5b8101908080519060200190929190505050905060006002808888600090604092610891939291906115da565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108eb57805182526020820191506020810190506020830392506108c8565b6001836020036101000a038019825116818451168082178552505050505050905001915050602060405180830381855afa15801561092d573d6000803e3d6000fd5b5050506040513d602081101561094257600080fd5b8101908080519060200190929190505050600289896040908092610968939291906115da565b6000801b604051602001808484808284378083019250505082815260200193505050506040516020818303038152906040526040518082805190602001908083835b602083106109cd57805182526020820191506020810190506020830392506109aa565b6001836020036101000a038019825116818451168082178552505050505050905001915050602060405180830381855afa158015610a0f573d6000803e3d6000fd5b5050506040513d6020811015610a2457600080fd5b810190808051906020019092919050505060405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b60208310610a8e5780518252602082019150602081019050602083039250610a6b565b6001836020036101000a038019825116818451168082178552505050505050905001915050602060405180830381855afa158015610ad0573d6000803e3d6000fd5b5050506040513d6020811015610ae557600080fd5b810190808051906020019092919050505090506000600280848c8c604051602001808481526020018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610b615780518252602082019150602081019050602083039250610b3e565b6001836020036101000a038019825116818451168082178552505050505050905001915050602060405180830381855afa158015610ba3573d6000803e3d6000fd5b5050506040513d6020811015610bb857600080fd5b8101908080519060200190929190505050600286600060401b866040516020018084805190602001908083835b60208310610c085780518252602082019150602081019050602083039250610be5565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610c935780518252602082019150602081019050602083039250610c70565b6001836020036101000a038019825116818451168082178552505050505050905001915050602060405180830381855afa158015610cd5573d6000803e3d6000fd5b5050506040513d6020811015610cea57600080fd5b810190808051906020019092919050505060405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b60208310610d545780518252602082019150602081019050602083039250610d31565b6001836020036101000a038019825116818451168082178552505050505050905001915050602060405180830381855afa158015610d96573d6000803e3d6000fd5b5050506040513d6020811015610dab57600080fd5b81019080805190602001909291905050509050858114610e16576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252605481526020018061162f6054913960600191505060405180910390fd5b6001602060020a0360205410610e77576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061160e6021913960400191505060405180910390fd5b60016020600082825401925050819055506000602054905060008090505b6020811015610fb75760018083161415610ec8578260008260208110610eb757fe5b018190555050505050505050610fc7565b600260008260208110610ed757fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b60208310610f335780518252602082019150602081019050602083039250610f10565b6001836020036101000a038019825116818451168082178552505050505050905001915050602060405180830381855afa158015610f75573d6000803e3d6000fd5b5050506040513d6020811015610f8a57600080fd5b8101908080519060200190929190505050925060028281610fa757fe5b0491508080600101915050610e95565b506000610fc057fe5b5050505050505b50505050505050565b6060610fdd602054611314565b905090565b6000806000602054905060008090505b60208110156111d057600180831614156110e05760026000826020811061101557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b60208310611071578051825260208201915060208101905060208303925061104e565b6001836020036101000a038019825116818451168082178552505050505050905001915050602060405180830381855afa1580156110b3573d6000803e3d6000fd5b5050506040513d60208110156110c857600080fd5b810190808051906020019092919050505092506111b6565b600283602183602081106110f057fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061114b5780518252602082019150602081019050602083039250611128565b6001836020036101000a038019825116818451168082178552505050505050905001915050602060405180830381855afa15801561118d573d6000803e3d6000fd5b5050506040513d60208110156111a257600080fd5b810190808051906020019092919050505092505b600282816111c057fe5b0491508080600101915050610ff2565b506002826111df602054611314565b600060401b6040516020018084815260200183805190602001908083835b6020831061122057805182526020820191506020810190506020830392506111fd565b6001836020036101000a0380198251168184511680821785525050505050509050018267ffffffffffffffff191667ffffffffffffffff1916815260180193505050506040516020818303038152906040526040518082805190602001908083835b602083106112a55780518252602082019150602081019050602083039250611282565b6001836020036101000a038019825116818451168082178552505050505050905001915050602060405180830381855afa1580156112e7573d6000803e3d6000fd5b5050506040513d60208110156112fc57600080fd5b81019080805190602001909291905050509250505090565b6060600867ffffffffffffffff8111801561132e57600080fd5b506040519080825280601f01601f1916602001820160405280156113615781602001600182028036833780820191505090505b50905060008260c01b90508060076008811061137957fe5b1a60f81b8260008151811061138a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350806006600881106113c657fe5b1a60f81b826001815181106113d757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060056008811061141357fe5b1a60f81b8260028151811061142457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060046008811061146057fe5b1a60f81b8260038151811061147157fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350806003600881106114ad57fe5b1a60f81b826004815181106114be57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350806002600881106114fa57fe5b1a60f81b8260058151811061150b57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060016008811061154757fe5b1a60f81b8260068151811061155857fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060006008811061159457fe5b1a60f81b826007815181106115a557fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b600080858511156115ea57600080fd5b838611156115f757600080fd5b600185028301915084860390509450949250505056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a2646970667358221220230afd4b6e3551329e50f1239e08fa3ab7907b77403c4f237d9adf679e8e43cf64736f6c634300060b0033", + "balance": "0x0" + }, + "4e59b44847b379578588920ca78fbf26c0b4956c": { + "code": "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", + "balance": "0x0" + }, + "5678e9e827b3be0e3d4b910126a64a697a148267": { + "balance": "0x43c33c1937564800000" + }, + "70997970c51812dc3a010c7d01b50e0d17dc79c8": { + "balance": "0x21e19e0c9bab2400000" + }, + "71be63f3384f5fb98995898a86b02fb2426c5788": { + "balance": "0x21e19e0c9bab2400000" + }, + "8626f6940e2eb28930efb4cef49b2d1f2c9c1199": { + "balance": "0x21e19e0c9bab2400000" + }, + "90f79bf6eb2c4f870365e785982e1f101e93b906": { + "balance": "0x21e19e0c9bab2400000" + }, + "976ea74026e726554db657fa54763abd0c3a0aa9": { + "balance": "0x21e19e0c9bab2400000" + }, + "9965507d1a55bcc2695c58ba16fb37d819b0a4dc": { + "balance": "0x21e19e0c9bab2400000" + }, + "a0ee7a142d267c1f36714e4a8f75612f20a79720": { + "balance": "0x21e19e0c9bab2400000" + }, + "bcd4042de499d14e55001ccbb24a551f3b954096": { + "balance": "0x21e19e0c9bab2400000" + }, + "bda5747bfd65f08deb54cb465eb87d40e51b197e": { + "balance": "0x21e19e0c9bab2400000" + }, + "cd3b766ccdd6ae721141f452c550ca635964ce71": { + "balance": "0x21e19e0c9bab2400000" + }, + "dd2fd4581271e230360230f9337d5c0430bf44c0": { + "balance": "0x21e19e0c9bab2400000" + }, + "df3e18d64bc6a983f673ab319ccae4f1a57c7097": { + "balance": "0x21e19e0c9bab2400000" + }, + "f39fd6e51aad88f6f4ce6ab8827279cfffb92266": { + "balance": "0x21e19e0c9bab2400000" + }, + "fabb0ac9d68b0b445fb7357272ff202c5651694a": { + "balance": "0x21e19e0c9bab2400000" + } + }, + "number": "0x0", + "gasUsed": "0x0", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "baseFeePerGas": null, + "excessBlobGas": null, + "blobGasUsed": null + } \ No newline at end of file diff --git a/Kubernetes/templates/geth-genesis.yaml b/Kubernetes/templates/geth-genesis.yaml new file mode 100644 index 0000000..982b240 --- /dev/null +++ b/Kubernetes/templates/geth-genesis.yaml @@ -0,0 +1,57 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: geth-genesis + namespace: {{ .Release.Namespace }} +spec: + template: + spec: + serviceAccountName: kubectl-sa + initContainers: + - name: geth-remove-db + image: "{{ .Values.image.gethRemoveDb }}" + imagePullPolicy: "{{ .Values.image.pullPolicy }}" + command: ["rm", "-rf", "/execution/geth"] + volumeMounts: + - name: execution + mountPath: {{ .Values.volumes.execution }} + - name: wait-for-create-beacon-chain-genesis + image: "{{ .Values.image.kubectlImage }}" # This image includes kubectl and can be used to run wait commands + imagePullPolicy: "{{ .Values.image.pullPolicy }}" + command: + - /bin/sh + - -c + - | + echo "Waiting for create-beacon-chain-genesis Job to complete..." + until kubectl get job create-beacon-chain-genesis -n {{ .Release.Namespace }} -o jsonpath='{.status.succeeded}' | grep "1"; do + echo "Job not completed yet. Checking again in 10 seconds..." + sleep 10 + done + echo "create-beacon-chain-genesis Job completed successfully." + containers: + - name: geth-genesis + image: "{{ .Values.image.gethGenesis }}" + imagePullPolicy: "{{ .Values.image.pullPolicy }}" + command: ["geth", "--datadir={{ .Values.volumes.execution }}", "init", "{{ .Values.volumes.execution }}/genesis.json"] + volumeMounts: + - name: execution + mountPath: {{ .Values.volumes.execution }} + - name: genesis-config-volume + mountPath: {{ .Values.volumes.execution }}/genesis.json + subPath: genesis.json + env: + - name: GETH_PORT + value: "8545" + + restartPolicy: OnFailure + volumes: + - name: execution + hostPath: + path: {{ .Values.volumes.localexecution }} + - name: genesis-config-volume + configMap: + name: genesis-config + nodeSelector: + kubernetes.io/arch: amd64 + + backoffLimit: 4 \ No newline at end of file diff --git a/Kubernetes/templates/geth-service.yaml b/Kubernetes/templates/geth-service.yaml new file mode 100644 index 0000000..d57b0c8 --- /dev/null +++ b/Kubernetes/templates/geth-service.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +kind: Service +metadata: + name: geth + namespace: default # Change if necessary +spec: + selector: + app: geth + ports: + - name: rpc-port + protocol: TCP + port: 8545 + targetPort: 8545 + - name: ws-port + protocol: TCP + port: 8546 + targetPort: 8546 + - name: authrpc-port + protocol: TCP + port: 8551 + targetPort: 8551 + type: ClusterIP diff --git a/Kubernetes/templates/geth.yaml b/Kubernetes/templates/geth.yaml new file mode 100644 index 0000000..72fe415 --- /dev/null +++ b/Kubernetes/templates/geth.yaml @@ -0,0 +1,79 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: geth +spec: + replicas: 1 + selector: + matchLabels: + app: geth + template: + metadata: + labels: + app: geth + spec: + serviceAccountName: kubectl-sa + initContainers: + - name: wait-for-geth-genesis + image: "{{ .Values.image.kubectlImage }}" + imagePullPolicy: "{{ .Values.image.pullPolicy }}" + command: + - /bin/sh + - -c + - | + echo "Waiting for geth-genesis Job to complete..." + until kubectl get job geth-genesis -n {{ .Release.Namespace }} -o jsonpath='{.status.succeeded}' | grep "1"; do + echo "Job not completed yet. Checking again in 10 seconds..." + sleep 10 + done + echo "geth-genesis Job completed successfully." + containers: + - name: geth + image: "{{ .Values.image.geth }}" + imagePullPolicy: "{{ .Values.image.pullPolicy }}" + args: + - --http + - --http.api=eth,net,web3 + - --http.addr=0.0.0.0 + - --http.corsdomain=* + - --ws + - --ws.api=eth,net,web3 + - --ws.addr=0.0.0.0 + - --ws.origins=* + - --authrpc.vhosts=* + - --authrpc.addr=0.0.0.0 + - --authrpc.jwtsecret={{ .Values.volumes.execution }}/jwtsecret + - --datadir={{ .Values.volumes.execution }} + - --allow-insecure-unlock + - --unlock=0x1d6197196c227e2be52c917b62343f7815638b2d + - --password={{ .Values.volumes.execution }}/geth_password.txt + - --nodiscover + - --syncmode=full + ports: + {{- range .Values.ports.geth }} + - containerPort: {{ . }} + {{- end }} + volumeMounts: + - name: execution + mountPath: {{ .Values.volumes.execution }} + - name: jwtsecret-volume + mountPath: {{ .Values.volumes.execution }}/jwtsecret + subPath: jwtsecret + - name: geth-password-volume + mountPath: {{ .Values.volumes.execution }}/geth_password.txt + subPath: geth_password.txt + env: + - name: GETH_PORT + value: "80" + volumes: + - name: execution + hostPath: + path: {{ .Values.volumes.localexecution }} + - name: jwtsecret-volume + secret: + secretName: jwtsecret + - name: geth-password-volume + secret: + secretName: geth-password + nodeSelector: + kubernetes.io/arch: amd64 diff --git a/Kubernetes/templates/geth_password-secret.yaml b/Kubernetes/templates/geth_password-secret.yaml new file mode 100644 index 0000000..3e3271b --- /dev/null +++ b/Kubernetes/templates/geth_password-secret.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: geth-password + namespace: {{ .Release.Namespace }} +type: Opaque +stringData: + geth_password.txt: | + 1 \ No newline at end of file diff --git a/Kubernetes/templates/jwtsecret.yaml b/Kubernetes/templates/jwtsecret.yaml new file mode 100644 index 0000000..86b246a --- /dev/null +++ b/Kubernetes/templates/jwtsecret.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: jwtsecret + namespace: {{ .Release.Namespace }} +type: Opaque +data: + jwtsecret: MHhmYWQyNzA5ZDBiYjAzYmYwZThiYTNjOTliZWExOTQ1NzVkM2U5ODg2MzEzM2QxYWY2MzhlZDA1NmQxZDU5MzQ1 \ No newline at end of file diff --git a/Kubernetes/templates/roleBinding.yaml b/Kubernetes/templates/roleBinding.yaml new file mode 100644 index 0000000..368707c --- /dev/null +++ b/Kubernetes/templates/roleBinding.yaml @@ -0,0 +1,13 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: read-jobs + namespace: {{ .Release.Namespace }} +subjects: +- kind: ServiceAccount + name: kubectl-sa + namespace: {{ .Release.Namespace }} +roleRef: + kind: Role + name: job-reader + apiGroup: rbac.authorization.k8s.io diff --git a/Kubernetes/templates/serviceAccount.yaml b/Kubernetes/templates/serviceAccount.yaml new file mode 100644 index 0000000..6fbc9cf --- /dev/null +++ b/Kubernetes/templates/serviceAccount.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: kubectl-sa + namespace: {{ .Release.Namespace }} diff --git a/Kubernetes/templates/validator-service.yaml b/Kubernetes/templates/validator-service.yaml new file mode 100644 index 0000000..238292e --- /dev/null +++ b/Kubernetes/templates/validator-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: validator + namespace: default # Change if necessary +spec: + selector: + app: validator + ports: + - name: grpc-port + protocol: TCP + port: {{ .Values.ports.validator }} + targetPort: {{ .Values.ports.validator }} + type: ClusterIP diff --git a/Kubernetes/templates/validator.yaml b/Kubernetes/templates/validator.yaml new file mode 100644 index 0000000..b29be12 --- /dev/null +++ b/Kubernetes/templates/validator.yaml @@ -0,0 +1,54 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: validator + namespace: {{ .Release.Namespace }} +spec: + replicas: 1 + selector: + matchLabels: + app: validator + template: + metadata: + labels: + app: validator + spec: + serviceAccountName: kubectl-sa + initContainers: + - name: wait-for-beacon-chain + image: busybox + imagePullPolicy: "{{ .Values.image.pullPolicy }}" + command: + - /bin/sh + - -c + - | + echo "Waiting for beacon-chain service to become available..." + until nc -zv beacon-chain 4000; do + echo "Beacon chain is not available yet. Checking again in 10 seconds..." + sleep 10 + done + echo "Beacon chain service is available. Starting validator container." + + containers: + - name: validator + image: "{{ .Values.image.validator }}" + imagePullPolicy: "{{ .Values.image.pullPolicy }}" + args: + - "--beacon-rpc-provider=beacon-chain:4000" + - "--datadir={{ .Values.volumes.consensus }}/validatordata" + - "--accept-terms-of-use" + - "--interop-num-validators=64" + - "--interop-start-index=0" + - "--chain-config-file={{ .Values.volumes.consensus }}/config.yml" + - "--force-clear-db" + ports: + - containerPort: {{ .Values.ports.validator }} + volumeMounts: + - name: consensus + mountPath: {{ .Values.volumes.consensus }} + volumes: + - name: consensus + hostPath: + path: {{ .Values.volumes.localconsensus }} + nodeSelector: + kubernetes.io/arch: amd64 diff --git a/Kubernetes/values.yaml b/Kubernetes/values.yaml new file mode 100644 index 0000000..82e181f --- /dev/null +++ b/Kubernetes/values.yaml @@ -0,0 +1,38 @@ +image: + createBeaconChainGenesis: gcr.io/prysmaticlabs/prysm/cmd/prysmctl:latest + gethRemoveDb: alpine:latest + gethGenesis: ethereum/client-go:latest + beaconChain: gcr.io/prysmaticlabs/prysm/beacon-chain:latest + geth: ethereum/client-go:latest + validator: gcr.io/prysmaticlabs/prysm/validator:latest + kubectlImage: bitnami/kubectl:latest + pullPolicy: IfNotPresent + + +volumes: + consensus: /consensus + execution: /execution + localconsensus: /mnt/docker/consensus + localexecution: /mnt/docker/execution + +mountPath: + consensus: /consensus/config.yml + execution: /execution/genesis.json + +chainId: 32382 + +jwtSecret: /execution/jwtsecret +passwordFile: /execution/geth_password.txt + +ports: + beaconChain: + - 4000 + - 3500 + - 8080 + - 6060 + - 9090 + geth: + - 8551 + - 8545 + - 8546 + validator: 8081