Deploy geth
to a k8s cluster in dev
node running
as an Ethereum single node testnet with proof-of-authority (PoA) consensus
The use of this tool does not guarantee security or usability for any particular purpose. Please review the code and use at your own risk.
first download the code, build container image and push to your container registry.
please make sure go toolchain and docker are installed at relatively newer versions and also update the IMG value to point to your registry
export IMG=docker.io/your-account-name/geth:v1.10.16
make manifests
make docker-build
make docker-push
once the container image is available in your registry you can
deploy geth
to a kubernetes cluster.
make deploy
The status of k8s resources should appear as follows:
kubectl --namespace=geth-system get pods,svc,configmaps,secrets dusy: Thu Mar 3 09:00:15 2022
NAME READY STATUS RESTARTS AGE
pod/geth-controller-manager-65dcc9f484-27dpt 1/1 Running 0 4m18s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/geth-geth ClusterIP 10.107.236.154 <none> 8545/TCP,8546/TCP 4m20s
NAME DATA AGE
configmap/kube-root-ca.crt 1 4m20s
NAME TYPE DATA AGE
secret/artifact-registry-key kubernetes.io/dockerconfigjson 1 4m20s
secret/default-token-m7tpn kubernetes.io/service-account-token 3 4m20s
secret/geth-controller-manager-token-lbn6t kubernetes.io/service-account-token 3 4m20s
Exec into the pod by running geth attach
command as shown below:
make console
Welcome to the Geth JavaScript console!
instance: Geth/v1.10.16-stable-20356e57/linux-arm64/go1.17.7
coinbase: 0x<address redacted>
at block: 1 (Thu Mar 03 2022 04:21:18 GMT+0000 (UTC))
datadir:
modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
To exit, press ctrl-d or type exit
>
Transfer funds to an address:
> eth.sendTransaction({from:eth.coinbase, to:"0x62c1831A63069619EE94d73853C21ceD076d0665", value: web3.toWei(125, "ether")})
First, port-forward RPC
make port-forward-rpc
Forwarding from 127.0.0.1:8545 -> 8545
Forwarding from [::1]:8545 -> 8545
Handling connection for 8545
Handling connection for 8545
Handling connection for 8545
Handling connection for 8545
Handling connection for 8545
Handling connection for 8545
Handling connection for 8545
Handling connection for 8545
Handling connection for 8545
Metamask Chrome extension can be configured to connect to this network.
Note that Metamask smartphone app will not accept http only RPC addresses and therefore in such cases only Chrome extensions can be used. See more: MetaMask/metamask-mobile#2314 (comment)
Connection parameters, typically already setup as Localhost
network:
- RPC: http://127.0.0.1:8545
- ChainID: 1337
- Currency symbol: ETH
At this point the funds transferred in previous should be visible in the Metamask wallet assuming you have configured Metamask with the same address.
First set env. var PROJECT
to point to Google cloud project ID.
Also make sure you have artifact registry API enabled and a repo called
services
has been provisioned for container images to reside in it.
podman
can be used instead of docker
to build and push multi-arch container
images. First build amd64
and arm64
images separately on respective host machines
with these host architectures.
make podman-build
Save/load container images and make sure both amd64
and arm64
images are
present on the same machine for next step to link them togehter in a manifest.
make podman-push
This will push the container images to your registry and link them in a manifest.