PreSearch Nodes on Kubernetes

Do repost and rate:

Disclaimer - This post was written for the #SearchWithPresearch Contest. Even though this post is for this contest, it is still relevant for the Awesome Self Hosted series ??

Hi everybody and welcome back! Today we're going to be looking at PreSearch, but specifically, we're going to be looking at running a PRESEARCH node on Kubernetes.  For those who are new to this series, I'm on a mission to document my entire self hosted Kubernetes stack.  Along the way I am also pausing to look at unique and interesting use cases for my Kubernetes cluster.  Showing how easy it is to run a PreSearch node on Kubernetes feels like a great way explore PreSearch while still bring you Awesome Self Hosted content!

Before we jump in, a quick overview of PreSearch is in order.  PreSearch is an up and coming decentralized search engine, with the intention of providing a private search experience.  The way this is achieved is by decentralizing the searching process and relying on the community to run their search nodes so that your individual search history is obfuscated from the web.  It is important to call out that if you are running a PreSearch node, search traffic will come from your IP address (wherever you are running this node), so it is not recommended to run a node from your home network if you are in a repressive country.  You can read the full and official disclaimer from PreSearch here.

Getting Ready

Due to the beta nature of the PreSearch project, at this time, before you can run a node, you need to sign up and join the Telegram group.  Requests to run a node can take up to 24 hours, so you will want to head here and fill out the questionnaire and await approval to run a node.  You'll need a Kubernetes cluster to run this node on for this tutorial.  You have several options - I'll be using my personal, self-hosted Kubernetes cluster (k3s, in my basement! ??), but you can also use any cloud provider such as GCP, AWS, Azure, etc.  Additionally, if you want to follow along Docker for Desktop (Mac | Windows) includes the ability to run a local Kubernetes cluster that you can use!  If you've never used Kubernetes before, but you are a PreSearch node operator, I strongly encourage you to follow along with at least this Docker provided Kubernetes install.  Kubernetes can take your PreSearch Nodes to the next level, since it is a full blown container orchestrator and manager.

As a heads up, I requested access to be a node operator for the purpose of this blog over a day ago, and I just got in, so be patient ??.

Running the PreSearch node

Once you've been approved, you're ready to run your PreSearch node! The complete instructions for running a node are awesome, and cover anything you could need for running this in docker, but, we're interested in Kubernetes for this blog! Docker is great, but, Kubernetes is production grade container orchestration for all your crypto needs!

Is Kubernetes a little aggressive? Maybe. However, it provides some added benefits that you simply don't get when just running in Docker.  The 2 biggest advantages we will be showcasing here are portability and reliability.  Hosted Kubernetes services are popping up everywhere, and so one of these services can be an easy entry-point for reliable compute power for your cryptocurrency needs*.  Once you have your Kubernetes deployments created, you can run your PreSearch node on any Kubernetes cluster.

Let's Get Started

There are 2 steps to this PreSearch node - 1. Saving our registration code to Kubernetes. 2. Deploying our PreSearch node!

We'll save our registration code as a secret, so that your code remains encrypted within the Kubernetes cluster you deploy to.

kubectl create secret generic presearch --from-literal=registration-code={XX_REGISTRATION_CODE_XX} --namespace crypto

You should paste your unique registration code into the above command. Notice that all the work for this blog is being done in the crypto namespace, but you can pick any namespace you'd like!

Next, we need to create our deployment file.  We will use our secret that we just created to populate the REGISTRATION_CODE

environment variable, as per the PreSearch node running instructions.

---kind: DeploymentapiVersion: apps/v1metadata:  name: presearch-node  namespace: cryptospec:  # How many replicas to run?  replicas: 1  selector:    matchLabels:      app: presearch-node  template:    metadata:      labels:        app: presearch-node        version: "0.8.25-testnet"    spec:      containers:      - name: presearch-node        image: presearch/node:0.8.25-testnet        env:        - name: REGISTRATION_CODE          valueFrom:            secretKeyRef:              name: presearch              key: registration-code

You should change the image in this file to be the latest image from the official docker repo.  I've also set the label on this deployment to declare the version, so that it is easy for us to know what version of the PreSearch node we are running later. The metadata.labels section of our deployment can hold any information we think is relevant for us!

Save the above deployment yaml to a file, call it presearch-node.yaml, and then pass this file to Kubernetes to launch your node:

kubectl apply -f presarch-node.yaml

This will launch your PreSearch node, and then the real fun can begin! 

Before we discuss all the advantages running on Kubernetes provides, you'll want to check the logs to ensure your node started without issues.

run kubectl logs -l app=presearch-node -n crypto to grab the logs of all apps labeled 'presearch-node' in our crypto namespace.

if you see

2021-03-27T02:15:44.196Z info:  .((((((((((((((((((((((((((((((.  ((((((((((((((((((((((((((((((((  ((((                        ((((  ((((   (((((((((((*         ((((  ((((   (((((((((((((        ((((  ((((   ((((     (((((       ((((  ((((   ((((     (((((       ((((  ((((   (((((((((((((        ((((  ((((   (((((((((((          ((((  ((((   ((((                 ((((  ((((   ((((   (((((((((((   ((((  ((((   ((((   (((((((((((   ((((  ((((                        ((((  ((((((((((((((((((((((((((((((((  '(((((((((((((((((((((((((((((('2021-03-27T02:15:44.197Z info: presearch-node - v0.8.25Saved public key!Saved private key!2021-03-27T02:15:45.461Z info: Node is listening for searches...

Then you're in business! ??

You can also go to the PreSearch Node Dashboard to see what nodes you have running.  You'll see something like this:

Why All This Work?

If you've made it this far in my blog, you've got PreSearch running on Kubernetes - this has some unique advantages to it over just running this in Docker. 

The first is that you have extreme portability.  You can take your registration code and deployment yaml and run this container on any Kubernetes cluster.  Yes, much of this portability comes from the node being containerized, but the toolset of Kubernetes means that you are able to run your PreSearch node the same way on every Kubernetes cluster. That is simplicity at its best.

The second is that you have the community of the most used container orchestration software behind you. Kubernetes is production-grade, and you can be assured that your workloads are in good hands.  Don't just take my word for it, look at how much activity the #kubernetes hashtag has on Twitter!

Lastly, and perhaps the coolest thing about running on Kubernetes is that you have scaling at your fingertips.  Granted, I don't yet know how intensive running a PreSearch node might be (I'm brand-new to this community), but I do know that PreSearch intends to decentralize their whole platform, which includes their web-crawlers.  The ability to rapidly scale workloads is key to providing enough compute power.

With Kubernetes, you can either change the replica count in the deployment yaml above, or you can even do this on the fly.  To run a second PreSearch Node, all we'd need to run is

kubectl scale deployment/presearch-node --replicas=2 -n crypto

It is truly that simple!

Wrapping it up, thank you for your interest in the PreSearch project and everything they stand for.  I hope this guide to running a PreSearch node on Kubernetes can help you take your nodes to the next level!  I'll be eagerly watching this project as it moves from community test net nodes to true, decentralized community-run mainnet nodes!  Eventually, I will get around to running the PreSearch web-crawler and blog about it once this is opened up to community members, so stay-tuned!  I have a feeling that Kubernetes will really shine for that workload in particular!

Additional Disclaimers

*It is up to you to read the terms and conditions of a cloud hosting provider before you use their compute power for cryptocurrency related things. They could have rules forbidding it.  Cloud compute is just an example, but it is up to you to do your due-diligence.

 

Regulation and Society adoption

Ждем новостей

Нет новых страниц

Следующая новость