Skip to content

Commit

Permalink
fix: Provider Documentation and K8s Upgrade(#909) (#910)
Browse files Browse the repository at this point in the history
* `akash` binary documentation cleanup.
  * `akashctl` -> `akash` binary
  * `akt` -> `uakt`

Upgrade kustomize configuration for Kubernetes 1.19

* Corrected `akash` params for configuration commands
* Utilize local directories for kustomization files
* Cleanup akash relevant namespaces with Make.

* Functional _run/single: akash + provider
  * Major change uses the cli flags to `akash provider` to pass
  configuration.
* Kustomize: rename Deployment/Ingress `akashd` -> `akash-node`
  * akash-node URL: akash.localhost (updated Makefiles)
  * Updated documentation
  * k8s internal service `akashd` -> `akash-node`

fixes: https://github.com/ovrclk/akash/issues/909

Signed-off-by: Josh Roppo <josh@akash.network>
  • Loading branch information
Josh Roppo committed Nov 21, 2020
1 parent 5f7f75d commit cc01f0e
Show file tree
Hide file tree
Showing 21 changed files with 140 additions and 94 deletions.
116 changes: 70 additions & 46 deletions _docs/examples/provider/README.md
Expand Up @@ -6,14 +6,21 @@

## Prerequisites

* Akash Network to connect to.
* Established account address with some tokens(for gas) in network to create Provider registration.
* Kubernetes Cluster
* [Akash Kubespray](https://github.com/ovrclk/kubespray/) can help get a functional cluster bootstrapped.
* Provider Pod will require admin authorization.

### Tools

Installed commands:

* [`akash`](https://github.com/ovrclk/akash/releases)
* [`kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl)
* [`kustomize`](https://kubernetes-sigs.github.io/kustomize/installation/)
* [`jq`](https://stedolan.github.io/jq/)
* [`curl`](https://curl.haxx.se/)
* [`kustomize`](https://kubernetes-sigs.github.io/kustomize/installation/)

### Working Directory

Expand All @@ -25,33 +32,46 @@ mkdir akash-demo && cd akash-demo

### Kubernetes Cluster

* A Kubernetes cluster with `kubectl` connected to it.
* A route-able IP address for ingress on the cluster.
* A "star" domain pointing to the cluster route-able IP.
* Version: `1.19+`
* A Kubernetes cluster with your local `kubectl` with admin authentication and authorization.
* A wildcard A Record resolving to a cluster route-able IP. eg: `*.akashian.io`

#### Option 1: [Akash Kubespray](https://github.com/ovrclk/kubespray/)

Akash has created an example Kubespray configuration to provision a Kubernetes installation on linux machines. Included are best practice configuration for CNI `calico` plugin, default Network Policies + Namespaces, `nginx` Ingress Controller, `metrics-server`, `cert-manager`, and Seccomp syscall restrictions.


#### Option 2: GCP Raw VM + k3s Example

*Warning: needs to be updated*

See [here](./kube-gce.md) for seting up these prerequisites
using [GCE](https://cloud.google.com/compute).

### Kubernetes Ingress

In this tutorial, we will be using the domain `akashian.io`.

```sh
PROVIDER_DOMAIN=akashian.io
```

This `PROVIDER_DOMAIN` variable is used to configure the Kubernetes Ingress Controller domain, so for this example, a Deployment's requests will be routed via a random subdomain, eg: `kswtibraxfdhlflhrg6ahe.akashian.io`. A wildcard subdomain DNS entr is necessary to support this, eg `*.akashian.io`. This address can be customized in the [Configure provider services](#configure-provider-services) file's `ingress-domain` field, eg: `ingress-domain=ingress.akashian.io`.
This `PROVIDER_DOMAIN` variable is used to configure the Kubernetes Ingress Controller domain, so for this example, a Deployment's requests will be routed via a random subdomain, eg: `kswtibraxfdhlflhrg6ahe.akashian.io`. A wildcard subdomain DNS entry is necessary to support this, eg `*.akashian.io`. This address can be customized in the [Configure provider services](#configure-provider-services) file's `ingress-domain` field, eg: `ingress-domain=ingress.akashian.io`.

### Akash Network

We'll be connecting to the testnet.

```sh
export AKASHCTL_NODE=tcp://rpc.akashtest.net:26657
export AKASHCTL_CHAIN_ID=testnet-v4
export AKASH_NODE=tcp://rpc-edgenet.akashdev.net:26657
export AKASH_CHAIN_ID=edgenet
export AKASH_KEYRING_BACKEND=test
export AKASH_PROVIDER_KEY=provider
```

## Deploy Provider Services

### Download akashctl
### Download `akash` binary

```sh
curl -sSfL https://raw.githubusercontent.com/ovrclk/akash/master/godownloader.sh | sh
Expand All @@ -60,22 +80,14 @@ curl -sSfL https://raw.githubusercontent.com/ovrclk/akash/master/godownloader.sh
### Configure Akash Client

```sh
export AKASHCTL_HOME="$PWD/home"
mkdir -p "$AKASHCTL_HOME"

./bin/akashctl config node "$AKASHCTL_NODE"
./bin/akashctl config chain-id "$AKASHCTL_CHAIN_ID"
./bin/akashctl config keyring-backend test
./bin/akashctl config broadcast-mode block
./bin/akashctl config trust-node true
./bin/akashctl config indent true
./bin/akashctl config output json
export AKASH_HOME="$PWD/home"
mkdir -p "$AKASH_HOME"
```

### Create Akash Provider Key

```sh
./bin/akashctl keys add provider
akash keys add $AKASH_PROVIDER_KEY --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND
```

### Download Kustomize configuration
Expand All @@ -101,31 +113,33 @@ EOF
View your address with

```sh
./bin/akashctl keys show provider -a
akash keys show provider -a --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND
```

You can fund the address at the testnet [faucet](https://akash.vitwit.com/faucet).

Ensure you have funds with:

```sh
./bin/akashctl query account "$(./bin/akashctl keys show provider -a)"
akash query bank balances --home=$AKASH_HOME --node=$AKASH_NODE "$(akash keys show $AKASH_PROVIDER_KEY -a --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND )"
```

### Create Akash Provider

Register your provider on the Akash Network:

*Replace `--from` flag value with your own*

```sh
./bin/akashctl tx provider create provider.yaml --from provider
akash tx provider create provider.yaml --from $AKASH_PROVIDER_KEY --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND --node=$AKASH_NODE --chain-id=$AKASH_CHAIN_ID
```

### Configure provider services client

```sh
cat <<EOF > client-config.txt
node=$AKASHCTL_NODE
chain-id=$AKASHCTL_CHAIN_ID
node=$AKASH_NODE
chain-id=$AKASH_CHAIN_ID
EOF
```

Expand Down Expand Up @@ -153,17 +167,19 @@ EOF

### Export keys

**Replace "password" below with your own unique secret.**

```sh
echo "password" > key-pass.txt
(cat key-pass.txt; cat key-pass.txt) | ./bin/akashctl keys export provider 2> key.txt
(cat key-pass.txt; cat key-pass.txt) | akash --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND keys export $AKASH_PROVIDER_KEY 2> key.txt
```

### Configure Kubernetes Akash Namespace

Create the `akash-services` namespace for running Provider.

```sh
kubectl apply -f https://raw.githubusercontent.com/ovrclk/akash/master/_docs/kustomize/namespace.yaml
kubectl apply -f https://raw.githubusercontent.com/ovrclk/akash/master/_docs/kustomize/networking/namespace.yaml
```

### Configure Akash Kubernetes CRDs
Expand All @@ -187,31 +203,31 @@ kubectl kustomize . | kubectl apply -f-
### Check status of provider

```sh
./bin/akashctl provider status --provider "$(./bin/akashctl keys show provider -a)"
akash provider status --node=$AKASH_NODE --provider "$(akash keys show $AKASH_PROVIDER_KEY -a --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND)"
```

## Deploy Demo Application

### Create key for deployment

```sh
./bin/akashctl keys add deploy
./bin/akash keys add deploy --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND
```

### Fund your deployment account

View your address with

```sh
./bin/akashctl keys show deploy -a
./bin/akash keys show deploy -a --home=$AKASH_HOME --keyring-backend$AKASH_KEYRING_BACKEND
```

You can fund the address at the testnet [faucet](https://akash.vitwit.com/faucet).

Ensure you have funds with:

```sh
./bin/akashctl query account "$(./bin/akashctl keys show deploy -a)"
./bin/akash query account --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND --node=$AKASH_NODE "$(./bin/akash keys show deploy -a --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND )"
```

### Download Akash SDL file
Expand All @@ -230,25 +246,25 @@ sed -i.bak "s/us-west/us-west-demo-$(whoami)/g" deployment.yaml
### Create Deployment

```sh
./bin/akashctl tx deployment create deployment.yaml --from deploy
./bin/akash --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND --chain-id=$AKASH_CHAIN_ID --node=$AKASH_NODE --from deploy tx deployment create ./deployment.yaml
```

### View Order

```sh
./bin/akashctl query market order list --owner "$(./bin/akashctl keys show deploy -a)"
akash query market order list --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND --owner "$(akash keys show deploy -a --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND)"
```

### View Bids

```sh
./bin/akashctl query market bid list --owner "$(./bin/akashctl keys show deploy -a)"
akash query market bid list --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND --owner "$(akash keys show deploy -a --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND)"
```

### View Leases

```sh
./bin/akashctl query market lease list --owner "$(./bin/akashctl keys show deploy -a)"
akash query market lease list --node=$AKASH_NODE --owner "$(akash keys show deploy -a --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND)"
```

### Capture Deployment Sequence
Expand All @@ -257,42 +273,44 @@ __note:__ This can be set when creating the deployment. It defaults to the
block height at that time.

```sh
DSEQ="$(./bin/akashctl query market lease list \
--owner "$(./bin/akashctl keys show deploy -a)" \
DSEQ="$(akash query market lease list --node=$AKASH_NODE --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND \
--owner "$(akash keys show deploy -a --home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND )" \
| jq -r '.[0].id.dseq')"
```

### Send Manifest

```sh
./bin/akashctl provider send-manifest deployment.yaml \
akash provider send-manifest deployment.yaml --node=$AKASH_NODE \
--home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND \
--dseq "$DSEQ" \
--oseq 1 \
--gseq 1 \
--owner "$(./bin/akashctl keys show deploy -a)" \
--provider "$(./bin/akashctl keys show provider -a)"
--owner "$(./bin/akash keys show deploy -a)" \
--provider "$(./bin/akash keys show provider -a)"
```

### View Lease Status

```sh
./bin/akashctl provider lease-status \
akash provider lease-status --node=$AKASH_NODE \
--home=$AKASH_HOME --keyring-backend=$AKASH_KEYRING_BACKEND \
--dseq "$DSEQ" \
--oseq 1 \
--gseq 1 \
--owner "$(./bin/akashctl keys show deploy -a)" \
--provider "$(./bin/akashctl keys show provider -a)"
--owner "$(./bin/akash keys show deploy -a)" \
--provider "$(./bin/akash keys show provider -a)"
```

### View Site

```sh
./bin/akashctl provider lease-status \
akash provider lease-status \
--dseq "$DSEQ" \
--oseq 1 \
--gseq 1 \
--owner "$(./bin/akashctl keys show deploy -a)" \
--provider "$(./bin/akashctl keys show provider -a)" | \
--owner "$(./bin/akash keys show deploy -a)" \
--provider "$(./bin/akash keys show provider -a)" | \
jq -r '.services[0].uris[0]' | \
while read -r line; do
open "http://$line"
Expand All @@ -302,7 +320,13 @@ DSEQ="$(./bin/akashctl query market lease list \
### Delete Deployment

```sh
./bin/akashctl tx deployment close --dseq $DSEQ --from deploy
akash tx deployment close \
--node=$AKASH_NODE \
--chain-id=$AKASH_CHAIN_ID \
--home=$AKASH_HOME \
--keyring-backend=$AKASH_KEYRING_BACKEND \
--from $OWNER_ADDRESS \
--dseq $DSEQ
```


13 changes: 10 additions & 3 deletions _docs/examples/provider/deployment.yaml
Expand Up @@ -8,14 +8,21 @@ services:
as: 80
to:
- global: true
- port: 2379
to:
- global: true
- port: 2379
to:
- global: true
proto: udp
profiles:
compute:
web:
resources:
cpu:
units: 0.1
memory:
size: 16Mi
size: 64Mi
storage:
size: 128Mi
placement:
Expand All @@ -24,8 +31,8 @@ profiles:
region: us-west
pricing:
web:
denom: akash
amount: 1000
denom: uakt
amount: 10000
deployment:
web:
westcoast:
Expand Down
2 changes: 1 addition & 1 deletion _docs/examples/provider/kube-gce.md
Expand Up @@ -3,7 +3,7 @@
Follow these steps to create a Kubernetes cluster on
[GCE](https://cloud.google.com/compute) using [`gcloud`](https://cloud.google.com/sdk/gcloud).

The K3S portions of this are based off of [this](https://starkandwayne.com/blog/trying-tiny-k3s-on-google-cloud-with-k3sup/)
TODO: update to Kubespray. The K3S portions of this are based off of [this](https://starkandwayne.com/blog/trying-tiny-k3s-on-google-cloud-with-k3sup/)
tutorial.

## Requirements
Expand Down
17 changes: 10 additions & 7 deletions _docs/examples/provider/kustomization.yaml
@@ -1,15 +1,15 @@
bases:
- github.com/ovrclk/akash/_docs/kustomize/akash-provider?ref=master
# - ../../kustomize/akash-provider
# local location: - ../../kustomize/akash-provider

images:
- name: ovrclk/akashctl
namespace: akash-services

images:
- name: ovrclk/akash
##
# akashctl version
# akash version
##

newTag: latest
newTag: 0.9.0-rc3

configMapGenerator:

Expand All @@ -31,6 +31,9 @@ configMapGenerator:
##
- name: akash-provider-config
behavior: merge
literals:
- cluster-node-port-quantity=100
- bid-price-strategy=randomRange
##
# place overrides in provider-config.txt
#
Expand All @@ -50,7 +53,7 @@ patchesJson6902:
- path: gateway-host.yaml
target:
group: networking.k8s.io
version: v1beta1
version: v1
kind: Ingress
name: akash-provider

Expand Down

0 comments on commit cc01f0e

Please sign in to comment.