From 8b8003a72271cb41349fffe24e17947fa2eb6290 Mon Sep 17 00:00:00 2001 From: Sam Bukowski Date: Thu, 19 Oct 2023 11:46:06 -0600 Subject: [PATCH] first draft of gcp deploy, added todos for A record sections --- docs/dusknet/cloud-rollup-deployment/2-gcp.md | 395 +++++++++++++++++- .../cloud-rollup-deployment/3-azure.md | 12 + docs/dusknet/cloud-rollup-deployment/4-aws.md | 2 +- 3 files changed, 407 insertions(+), 2 deletions(-) diff --git a/docs/dusknet/cloud-rollup-deployment/2-gcp.md b/docs/dusknet/cloud-rollup-deployment/2-gcp.md index 86bb5749..cfaf28ab 100644 --- a/docs/dusknet/cloud-rollup-deployment/2-gcp.md +++ b/docs/dusknet/cloud-rollup-deployment/2-gcp.md @@ -10,4 +10,397 @@ Deploy your rollup to GCP. The list of local dependencies for the following instructions [can be found here](/docs/dusknet/1-overview.md). ::: -TODO! +## Create a GCP (Google) Account + +Follow instructions here: https://console.cloud.google.com/ + +## Install GCP `gcloud` CLI + +Find the correct cli for your OS here: https://cloud.google.com/sdk/docs/install + +## Create a Google Cloud Project + +See the full instructions here: +- https://cloud.google.com/resource-manager/docs/creating-managing-projects + +We recommend using the cli commands, which can be found on the above page by selecting +the `gcloud` tabs within the instructions: + +```bash +gcloud projects create PROJECT_ID +``` + +## Set Default Project + +```bash +gcloud config set project PROJECT_ID +``` + +## Enable Billing + +See the following page for setting up a billing account that suits your needs: +- https://cloud.google.com/billing/docs/how-to/verify-billing-enabled#console + +## Enable GKE API + +```bash +gcloud services enable container.googleapis.com +``` + +## GKE Quickstart + +Follow the Quickstart guide to create your GKE cluster: +- https://cloud.google.com/kubernetes-engine/docs/deploy-app-cluster + +### Create a GKE Cluster + +```bash +gcloud container clusters create-auto hello-cluster \ + --region=us-central1 +``` + +## Configure Kubectl for your GKE Cluster + +:::danger +Due to https://github.com/kubernetes/kubectl/issues/1338 you must run the following commands before configuring your cluster’s credentials, otherwise `helm` will not work. + +```bash +gcloud components install gke-gcloud-auth-plugin +export USE_GKE_GCLOUD_AUTH_PLUGIN=True +``` +::: + +Configure your credentials: + +```bash +gcloud container clusters get-credentials hello-cluster \ + --region us-central1 +``` + +## Deploy Ingress Nginx Controller + +See the Kubernetes GCE-GKE nginx installation guid here: +- https://kubernetes.github.io/ingress-nginx/deploy/#gce-gke + +```bash +kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.2/deploy/static/provider/cloud/deploy.yaml +``` + +## Verify Loadbalancer with external IP + +Run the following command: +```bash +kubectl get svc -n ingress-nginx +``` + +You should see something like this: + +```bash +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +ingress-nginx-controller LoadBalancer 34.118.228.98 34.42.184.206 80:31623/TCP,443:31357/TCP 57s +ingress-nginx-controller-admission ClusterIP 34.118.229.71 443/TCP 57s +``` + +Curl the `EXTERNAL-IP`: +```bash +curl 34.42.184.206 +``` +```html + +404 Not Found + +

404 Not Found

+
nginx
+ + +``` + +## Create an A Record + +TODO!!! + +:::danger +You must configure a DNS record because our ingress configuration uses name +based virtual routing. +More info here: https://kubernetes.io/docs/concepts/services-networking/ingress/#name-based-virtual-hosting +::: + +![CNAME record Example](../assets/cname-record-example.png) + +## Creating your own Genesis Account + +You can add genesis account(s) to your rollup during configuration. + +You can create an account using + +```bash +cast w new +``` + +to create a new account: + +```bash +Successfully created new keypair. +Address: 0xfFe9...5f8b # +Private key: 0x332e...a8fb # +``` + +You can then `export` the genesis accounts like so: +```bash +export ROLLUP_GENESIS_ACCOUNTS=: +``` + +`export` the private key to the env vars using: +```bash +export ROLLUP_FAUCET_PRIV_KEY= +``` + +:::danger +__NEVER__ use a private key you use on a live network. +::: + +## Configure and Deploy Rollup + +### Update the `helm` Chart + +Pull the [Astria dev-cluster repo](https://github.com/astriaorg/dev-cluster): +```bash +git clone git@github.com:astriaorg/dev-cluster.git +cd dev-cluster +``` + +Within the dev-cluster repo, update the ingress template +`chart/rollup/templates/ingress.yaml` so that each hostname ends in +`` instead of `localdev.me` + +```yaml +... +- host: executor.{{ .Values.config.rollup.name }}. +... +- host: ws-executor.{{ .Values.config.rollup.name }}. +... +- host: faucet.{{ .Values.config.rollup.name }}. +... +- host: blockscout.{{ .Values.config.rollup.name }}. +... +``` + +Add an IngressClass so that the `metadata` section in the same file looks like: + +```yaml +metadata: + name: {{ .Values.config.rollup.name }}-ingress + namespace: {{ .Values.namespace }} + annotations: + kubernetes.io/ingress.class: nginx +``` + +:::tip +You can see an example of these changes in [this PR here](https://github.com/astriaorg/dev-cluster/pull/119/files). +::: + +## Install the `astria-cli` + +Pull the [Astria repo](https://github.com/astriaorg/astria) and install the `astria-cli` + +```bash +git clone git@github.com:astriaorg/astria.git +cd astria +just install-cli +``` + +### Get Current Sequencer Block Height + +```bash +astria-cli sequencer blockheight get \ + --sequencer-url https://rpc.sequencer.dusk-1.devnet.astria.org/ +``` + +Save the returned value for later. You will replace the +`` tag in the following sections with this +value. + +### Set Environment Variables + +Replace the tags in the commands and env vars below, as follows: + +| Var Name | Var Type | Description | +|-----|-----|-----| +| `` | String | The name of your rollup | +| `` | u64 | The id of your network | +| `` | u64 | The height of the sequencer (found above) | +| `` | [u8; 40] | A wallet address | +| `` | u64 | A balance. It is useful to make this a large value. | + + + + + +You can use environment variables to set the configuration for the rollup +config creation. Replace all the `<>` tags with their corresponding values. + +```bash +export ROLLUP_USE_TTY=true +export ROLLUP_LOG_LEVEL=DEBUG +export ROLLUP_NAME= +export ROLLUP_NETWORK_ID= +export ROLLUP_SKIP_EMPTY_BLOCKS=false +export ROLLUP_GENESIS_ACCOUNTS=: +export ROLLUP_SEQUENCER_INITIAL_BLOCK_HEIGHT= +export ROLLUP_SEQUENCER_WEBSOCKET=wss://rpc.sequencer.dusk-1.devnet.astria.org/websocket +export ROLLUP_SEQUENCER_RPC=https://rpc.sequencer.dusk-1.devnet.astria.org +``` + +### Create Config + +Once the environment variables shown above are set, run the following command to +create the rollup config: +```bash +astria-cli rollup config create +``` + +You can then run: + +```sh +cat -rollup-conf.yaml +``` + +to print out the config file contents to double check everything: + +```sh +config: + useTTY: true + logLevel: DEBUG + rollup: + name: + chainId: # derived from rollup name + networkId: + skipEmptyBlocks: true + genesisAccounts: + - address: 0x + balance: '' + sequencer: + initialBlockHeight: + websocket: ws://rpc.sequencer.dusk-1.devnet.astria.org/websocket + rpc: http://rpc.sequencer.dusk-1.devnet.astria.org + celestia: + fullNodeUrl: http://celestia-service:26658 +``` + +Export this file to the env vars as follows: +```bash +export ROLLUP_CONF_FILE=-rollup-conf.yaml +``` + +## Create new sequencer account + +```bash +astria-cli sequencer account create +``` + +```bash +Create Sequencer Account + +Private Key: "0981...691c" +Public Key: "f08e...8a4d" +Address: "8f40...64fb" +``` + +```bash +export SEQUENCER_PRIV_KEY=0981...691c +``` + +### Create Namespace + +```bash +kubectl apply -f kubernetes/namespace.yml +``` + +### Use locally modified chart + +:::danger +You __must__ have modified your local `helm` chart to use your own domain name +as described in [this section here](#update-the-helm-chart). +::: + +Because you needed to modify the host names inside your ingress template you must deploy your rollup using your local chart: + +```bash +export ROLLUP_CHART_PATH="/your_path_to/dev-cluster/charts/rollup" +``` + +### Deploy the Rollup Node + +Use the `astria-cli` to deploy the node. + +```bash +astria-cli rollup deployment create \ + --config $ROLLUP_CONF_FILE \ + --faucet-private-key $ROLLUP_FAUCET_PRIV_KEY \ + --sequencer-private-key $SEQUENCER_PRIV_KEY +``` + +## Observe your Deployment + +Your rollups utility endpoints are as follows: + +| Utility | URL | +|-----|-----| +| Block Explorer | http://blockscout../ | +| Faucet | http://faucet../ | +| RPC | http://executor../ | + +Open the URLs in your browser to view your running rollup. + +## Debug Ingress + +If you would like to view the ingress logs you can use the following: + +```bash +kubectl get po -n ingress-nginx +# get the name of one of the pods +export INGRESS_POD_1=ingress-nginx-controller-6d6559598-ll8gv +# view the logs +kubectl logs $INGRESS_POD_1 -n ingress-nginx +``` + +## Use `cast` to Interact with your Rollup + +```bash +export ETH_RPC_URL=http://executor../ +``` + +```bash +cast block 0 +``` + +Use an address of your choice. + +```bash +export REC_ADDR= +``` + +```bash +cast balance $REC_ADDR +``` + +```bash +cast send $REC_ADDR --value 10000000000000000000 --private-key $ROLLUP_FAUCET_PRIV_KEY +``` + +```bash +cast balance $REC_ADDR +``` + +## Fund you Sequencer Account + +Using your sequencer pub key you created in the [Create a New Sequencer +Account](#create-a-new-sequencer-account), copy and past the +`` into the input on the faucet page, and mint funds +to your account: + +![Sequencer Faucet](../assets/sequencer-faucet.png) diff --git a/docs/dusknet/cloud-rollup-deployment/3-azure.md b/docs/dusknet/cloud-rollup-deployment/3-azure.md index bf9b5ec8..ebe66e2d 100644 --- a/docs/dusknet/cloud-rollup-deployment/3-azure.md +++ b/docs/dusknet/cloud-rollup-deployment/3-azure.md @@ -93,6 +93,18 @@ curl 20.72.189.135 ``` +## Create an A Record + +TODO!!! + +:::danger +You must configure a DNS record because our ingress configuration uses name +based virtual routing. +More info here: https://kubernetes.io/docs/concepts/services-networking/ingress/#name-based-virtual-hosting +::: + +![CNAME record Example](../assets/cname-record-example.png) + ## Creating your own Genesis Account You can add genesis account(s) to your rollup during configuration. diff --git a/docs/dusknet/cloud-rollup-deployment/4-aws.md b/docs/dusknet/cloud-rollup-deployment/4-aws.md index d06157cd..a2f80729 100644 --- a/docs/dusknet/cloud-rollup-deployment/4-aws.md +++ b/docs/dusknet/cloud-rollup-deployment/4-aws.md @@ -122,7 +122,7 @@ curl ac1f86093ea7240c89457da3d5f71fc4-947b3172412ab75c.elb.us-east-1.amazonaws.c ``` -## Create a friendly CNAME record +## Create a CNAME record :::danger You must configure a DNS record because our ingress configuration uses name