Guide for Soroban RPC server on Kubernetes with DigitalOcean

January 20, 2024


Prerequisites

  • A fully registered domain name with an available A record. This tutorial will use rpc.your_domain throughout. You can purchase a domain name on Namecheap or use the domain registrar of your choice. These A records will be directed to a Load Balancer that you will create in later steps.
  • An API testing client. This tutorial will use https://httpie.io/
  • <TODO:Expand on each prerequisite to clarify why it is necessary. For instance, explain why a fully registered domain name is needed and how it will be used.>
Introduction

<TODO:Brief introduction that explains the purpose of the tutorial, what Soroban RPC server is, any benefits of this deployment process>

After finishing this tutorial, you will be able to:

  • Connect to your personal Soroban RPC server
Target audience

<TODO:Specify the knowledge level required (e.g., intermediate knowledge of Kubernetes and DigitalOcean).>

Step by Step Instructions
  • <TODO:In each step, provide a brief rationale for why the step is necessary. This helps learners understand the importance of each action.>
  • <TODO:Include screenshots or GIFs for complex steps, especially in the DigitalOcean control panel or command-line operations.>
  • <TODO:Ensure that links to external resources (like installation guides for doctl, kubectl, and Helm) are up to date.>

Step - Create Kubernetes Cluster in DigitalOcean

A Kubernetes cluster on DigitalOcean has one or more node pools. Each node pool consists of a group of identical worker nodes. Worker nodes are built on Droplets. For this tutorial, we can build a cluster with two worker nodes in one node pool.

Create Kubernetes cluster in DigitalOcean

https://docs.digitalocean.com/products/kubernetes/how-to/create-clusters/#create-a-cluster-using-the-control-panel

To create the cluster following the how-to guide, you need to specify the cluster’s scaling type and add at least one node pool with at least one worker.  We can make sure to use a fixed size cluster and the 2 GB total RAM / 1 vCPU nodes. For a personal RPC server, you can go with the smallest node available.

If you want to create a single node cluster, you will have to select a larger node size.

Step - Follow Getting Started with Kubernetes guide under the Overview Tab

While the cluster is being provisioned, we can follow along with the rest of the setup instructions that appear under the Overview tab by clicking on Get Started

Getting Started
Connecting to Kubernetes

The first step in connecting to Kubernetes requires additional applications:

Install doctl

https://docs.digitalocean.com/reference/doctl/how-to/install/

Install kubectl

https://kubernetes.io/docs/tasks/tools/

Install Helm

https://helm.sh/docs/intro/install/

Verify connectivity to Kubernetes

After we have installed all of the tooling, we can now verify that we can connect to Kubernetes. Clicking on the second step you will be presented with an automated and manual way to verify connectivity. We will use the recommended automated way to verify by copying the provided doctl command into our terminal.

Connect to Kubernetes


Connect to Your Newly Provisioned Cluster Using doctl


Verify Connectivity
kubectl cluster-info

Display addresses of the control plane and cluster services

doctl kubernetes cluster list

Displays a variety of commands that help manage your cluster via DigitalOcean's API

Verify connectivity

Step - Add SDF Helm Chart Repository

One of the tools installed while following the Get Started guide was Helm. Helm is a package manager that helps you manage Kubernetes applications. Helm Charts are what Helm uses to define, install and upgrade Kubernetes applications. SDF provides Helm Charts for the various applications in the Stellar Stack. We want to use the Helm Chart from the SDF Helm Chart Repository to install Soroban RPC.

Add SDF Helm Chart Repository to Your System:

We will first need to add the Helm Chart repository to our system using the following helm commands:

The helm repo add command adds the chart repository to your local Helm registry

helm repo add stellar https://helm.stellar.org/charts

The helm repo update command updates the information of available charts locally from the chart repositories you have added to your Helm registry.

helm repo update
Add and update Helm repo


Step - Deploy Soroban RPC Workload

Now that we have added the SDF chart repository to our local registry and updated the charts that are available to us, we can now deploy a workload using one of the charts available.

We want to start off by creating a deployment configuration file, we can use the testnet values file in the helm charts repo and modify the values we want to change.

Create a local deployment configuration file using the configuration files in the Stellar Helm Chart Repository as a base

https://github.com/stellar/helm-charts/blob/main/charts/soroban-rpc/testnet-values.yaml

Since we will be connecting our RPC server to testnet, we can uncomment update Soroban RPC image tag to the latest version

sorbanRpc:
 ....
    tag: latest
Update config


For the ingress section in the configuration file, add your fully registered domain name for the host value

  • host: rpc.your_domain

We also want to uncomment and update the Ingress class name

  • ingressClassName:nginx

After we have finished with our configuration file, we can use that to install Soroban RPC into our Kubernetes cluster

helm install my-soroban-rpc stellar/soroban-rpc --values=testnet-values.yaml

Step - Verify the Service Is Up and Running

kubectl get service


Step - Installing the Kubernetes Nginx Ingress Controller

https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nginx-ingress-on-digitalocean-kubernetes-using-helm

Even though we have verified that our service is running on our cluster in the previous step, we still cannot access the service from the outside. For that we will need to create an ingress, an ingress is a way for us to expose our service to the outside world. We will use the nginx ingress and we will first need to add the Nginx Helm Chart Repository to our system

Add Nginx Ingress Helm Chart Repository to Your System:

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update


We can now install the nginx ingress into our Kubernetes cluster

helm install nginx-ingress ingress-nginx/ingress-nginx --set controller.publishService.enabled=true
Install Nginx ingress

Run this command to watch the load balancer become available. This process creates a load balancer in the cluster resource group in DigitalOcean.

kubectl --namespace default get services -o wide -w nginx-ingress-ingress-nginx-controller
Watch for ingress creation


Step - Update DNS records to point to DigitalOcean loadbalancer

Now that our RPC service has been deployed and our ingress has been created, we can use the IP address from the newly provisioned load balancer and update our DNS records to match.

We are going to create an A record in our registrar to match


Step - Verify You Can Connect to RPC Service Through Your Fully Qualified Domain

Now that we have updated our DNS records, we can test our endpoint using the FQDN we have set up after those records have propagated. From our terminal, we can use httpie to test the RPC endpoint.

http POST https://rpc.your_domain jsonrpc="2.0"  id=867 method="getHealth"

Step - Cleanup

<TODO:Provide instructions on how to safely dismantle the setup and tips for ongoing maintenance.>

Additional Resources:
  1. https://docs.digitalocean.com/products/kubernetes/how-to/create-clusters/#create-a-cluster-using-the-control-panel
  2. https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nginx-ingress-on-digitalocean-kubernetes-using-helm
  3. https://docs.digitalocean.com/products/kubernetes/getting-started/operational-readiness/enable-https/
  4. https://github.com/stellar/helm-charts/
  5. https://soroban.stellar.org/docs


Grow your business.
Today is the day to build the business of your dreams. Share your mission with the world — and blow your customers away.
Start Now