Skip to content

Instantly share code, notes, and snippets.

@exit99
Last active February 8, 2023 14:35
Show Gist options
  • Save exit99/7b647e9feaaf38628538acceabdc2ea4 to your computer and use it in GitHub Desktop.
Save exit99/7b647e9feaaf38628538acceabdc2ea4 to your computer and use it in GitHub Desktop.
Bootstrap a k3s akash provider
# Install K3s
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=traefik" sh -s -
# Setup K3s for Akash
mkdir ~/.kube
sudo cat /etc/rancher/k3s/k3s.yaml | tee ~/.kube/config >/dev/null
kubectl get nodes
kubectl create ns akash-services
kubectl label ns akash-services akash.network/name=akash-services akash.network=true
kubectl create ns ingress-nginx
kubectl label ns ingress-nginx app.kubernetes.io/name=ingress-nginx app.kubernetes.io/instance=ingress-nginx
kubectl create ns lease
kubectl label ns lease akash.network=true
# Install Akash CLI
cd ~
apt install jq -y
apt install unzip -y
curl -sfL https://raw.githubusercontent.com/akash-network/provider/main/install.sh | bash
echo 'alias provider-services="/root/bin/provider-servers"' >> ~/.bashrc
# Configure Wallet
echo 'export AKASH_KEY_NAME={YOUR_KEY_NAME}' >> ~/.bashrc
echo 'export AKASH_KEYRING_BACKEND=os' >> ~/.bashrc
# Configure network
echo 'export AKASH_NET="https://raw.githubusercontent.com/akash-network/net/master/mainnet"' >> ~/.bashrc
echo AKASH_VERSION="$(curl -s https://api.github.com/repos/akash-network/provider/releases/latest | jq -r '.tag_name')" | { read val; echo 'export' $val; } >> ~/.bashrc
# Apply changes to bashrc
source ~/.bashrc
# Import keys (from mnemonic phrase via Kepler wallet)
provider-services keys add $AKASH_KEY_NAME --recover
# More network stuff
export AKASH_CHAIN_ID="$(curl -s "$AKASH_NET/chain-id.txt")"
export AKASH_NODE="$(curl -s "$AKASH_NET/rpc-nodes.txt" | shuf -n 1)"
# Set your account address and check balance
export AKASH_ACCOUNT_ADDRESS={akash2kh...YOUR_ACCOUNT_ADDR_xkh2I}
provider-services query bank balances --node $AKASH_NODE $AKASH_ACCOUNT_ADDRESS
# Export key file
cd ~
(echo "{YOUR_PASS}"; echo "{YOUR_PASS}") | provider-services keys export {YOUR_KEY_NAME} >> key.pem 2>&1
# install helm charts for akash
wget https://get.helm.sh/helm-v3.9.4-linux-amd64.tar.gz
tar -zxvf helm-v3.9.4-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/helm
###Remove any potential prior repo instances
helm repo remove akash
helm repo add akash https://akash-network.github.io/helm-charts
# Configure provider
echo 'export ACCOUNT_ADDRESS={akash...YOUR_ACCOUNT_ADDRESS..}' >> ~/.bashrc
echo 'export KEY_PASSWORD={YOUR_PASSWORD}' >> ~/.bashrc
echo 'export DOMAIN={YOUR_DOMAIN}' >> ~/.bashrc
echo 'export NODE=http://akash-node-1-0:26657' >> ~/.bashrc
helm repo update
cd ~
mkdir provider
cd provider
cat > provider.yaml << EOF
from: "$ACCOUNT_ADDRESS"
key: "$(cat ~/key.pem | openssl base64 -A)"
keysecret: "$(echo $KEY_PASSWORD | openssl base64 -A)"
domain: "$DOMAIN"
node: "$NODE"
widthdrawalperiod: 1h
attributes:
- key: region
value: {YOUR_REGION}
- key: host
value: akash
- key: tier
value: community
- key: organization
value: {YOUR ORG}
EOF
# Install
helm -n akash-services uninstall akash-node
helm install akash-node akash/akash-node -n akash-services
helm install akash-hostname-operator akash/akash-hostname-operator -n akash-services
helm install akash-ingress akash/akash-ingress -n ingress-nginx --set domain=$DOMAIN
# Must wait for the above node to finish.
helm install akash-provider akash/provider -n akash-services -f provider.yaml
# Check it
kubectl get pods -n akash-services
@exit99
Copy link
Author

exit99 commented Feb 6, 2023

The above won't execute. Copy paste each line as you go. Replace {VARIABLE}s with your own values.

@andy108369
Copy link

Cool stuff, this needs to be slightly polished and can go as Quick Provider Bootstrap instructions at https://docs.akash.network

Ideally, with some notes (or a link to such) on how to add more nodes (or remove the old ones) to the k3s cluster.

It does not contain persistent storage nor IP leases but these are available here, and can be just applied over:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment