The Kube dev environment builds:
- A single-node blockchain network
- An Akash Provider Services Daemon (PSD) for bidding and running workloads.
- A Kubernetes cluster for the PSD to run workloads on.
The instructions below will illustrate how to run a network with a single, local node and execute workloads in kind:
- Initialize blockchain node and client
- Run a single-node network
- Query objects on the network
- Create a provider
- Run provider services
- Create a deployment
- Bid on an order
- Terminate a lease
Four keys and accounts are created. The key names are:
| Key Name | Use |
|---|---|
main |
Primary account (creating deployments, etc...) |
provider |
The provider account (bidding on orders, etc...) |
validator |
The sole validator for the created network |
other |
Misc. account to (receives tokens, etc...) |
Most make commands are configurable and have defaults to make it
such that you don't need to override them for a simple pass-through of
this example.
| Name | Default | Description |
|---|---|---|
KEY_NAME |
main |
standard key name |
PROVIDER_KEY_NAME |
provider |
name of key to use for provider |
DSEQ |
1 | deployment sequence |
GSEQ |
1 | group sequence |
OSEQ |
1 | order sequence |
PRICE |
10uakt | price to bid |
The following steps will bring up a network and allow for interacting with it.
Running through the entire runbook requires three terminals. Each command is marked t1-t3 to indicate a suggested terminal number.
If at any time you'd like to start over with a fresh chain, simply run:
t1 run
make clean kind-cluster-clean
make initStart and initialize kind.
Kubernetes ingress objects present some difficulties for creating development environments. Two options are offered below - the first (random port) is less error-prone and can have multiple instances run concurrently, while the second option arguably has a better payoff.
note: this step waits for Kubernetes metrics to be available, which can take some time. The counter on the left side of the messages is regularly in the 120 range. If it goes beyond 250, there may be a problem.
| Option | t1 Step: 1 | Explanation |
|---|---|---|
| Map random local port to port 80 of your workload | make kind-cluster-setup |
This is less error-prone, but makes it difficult to access your app through the browser. |
| Map localhost port 80 to workload | KIND_CONFIG=kind-config-80.yaml make kube-cluster-create-kind |
If anything else is listening on port 80 (any other web server), this method will fail. If it does succeed, you will be able to browse your app from the browser. |
Initialize keys and accounts:
make initIn a separate terminal, the following command will run the akash node:
make node-runYou can check the status of the network with:
t1 status
make node-statusYou should see blocks being produced - the block height should be increasing.
You can now view genesis accounts that were created:
t1 status
make query-accountsCreate a provider on the network with the following command:
make provider-createView the on-chain representation of the provider with:
t1 status
make query-providerTo run Provider as a simple binary connecting to the cluster, in a third terminal, run the command:
make provider-runQuery the provider service gateway for its status:
t1 status
make provider-statusCreate a deployment from the main account with:
make deployment-createThis particular deployment is created from the sdl file in this directory (deployment.yaml).
Check that the deployment was created. Take note of the dseq - deployment sequence:
t1 status
make query-deploymentsAfter a short time, you should see an order created for this deployment with the following command:
make query-ordersThe Provider Services Daemon should see this order and bid on it.
make query-bidsWhen a bid has been created, you may create a lease:
To create a lease, run
make lease-createYou can see the lease with:
make query-leasesYou should now see "pending" inventory in the provider status:
make provider-statusNow that you have a lease with a provider, you need to send your workload configuration to that provider by sending it the manifest:
make send-manifestYou can check the status of your deployment with:
t1 status
make provider-lease-statusYou can reach your app with the following (Note: Host: header tomfoolery abound)
t1 status
make provider-lease-pingGet service status
t1 service status
make provider-lease-statusFetch logs from deployed service (all pods)
t1 service logs
make provider-lease-logsIf you chose to use port 80 when setting up kind, you can browse to your deployed workload at http://hello.localhost
Updating active Deployments is a two step process. First edit the deployment.yaml with whatever changes are desired. Example; update the image field.
- Update the Akash Network to inform the Provider that a new Deployment declaration is expected.
make deployment-update
- Send the updated manifest to the Provider to run.
make send-manifest
Between the first and second step, the prior deployment's containers will continue to run until the new manifest file is received, validated, and new container group operational. After health checks on updated group are passing; the prior containers will be terminated.
Akash Groups are translated into Kubernetes Deployments, this means that only a few fields from the Akash SDL are mutable. For example image, command, args, env and exposed ports can be modified, but compute resources and placement criteria cannot.
There are a number of ways that a lease can be terminated.
t1 teardown
make bid-closet1 teardown
make lease-closet1 teardown
make group-pauset1 teardown
make group-pauset1 teardown
make deployment-close