Update snowball steps to deploy to k8s

This commit is contained in:
Adw8 2024-10-25 13:21:18 +05:30
parent f2e1c176b3
commit a994271c52
2 changed files with 55 additions and 19 deletions

View File

@ -1124,27 +1124,27 @@
<details open>
<summary>snowball-backend</summary>
## Snowball Backend
## Deploy Backend
* Stack: <https://git.vdb.to/cerc-io/snowballtools-base-api-stack/src/branch/main/stack-orchestrator/stacks/snowballtools-base-backend>
* Source repo: <https://git.vdb.to/cerc-io/snowballtools-base>
* Target dir: `/srv/snowball/snowball-deployment`
* Target dir: `/srv/deploy-backend/backend-deployment`
* Cleanup an existing deployment if required:
```bash
cd /srv/snowball
cd /srv/deploy-backend
# Stop the deployment
laconic-so deployment --dir snowball-deployment stop --delete-volumes
laconic-so deployment --dir backend-deployment stop --delete-volumes
# Remove the deployment dir
sudo rm -rf snowball-deployment
sudo rm -rf backend-deployment
# Remove the existing spec file
rm snowball-deployment-spec.yml
rm backend-deployment-spec.yml
```
### Setup
@ -1154,7 +1154,7 @@
```bash
laconic-so fetch-stack git.vdb.to/cerc-io/snowballtools-base-api-stack --pull
# This should clone the testnet-laconicd-stack repo at `/home/dev/cerc/snowballtools-base-api-stack`
# This should clone the snowballtools-base-api-stack repo at `/home/dev/cerc/snowballtools-base-api-stack`
```
* Clone required repositories:
@ -1173,39 +1173,75 @@
# This should create the Docker images: "cerc/snowballtools-base-backend" and "cerc/snowballtools-base-backend-base"
```
* Push the images to the container registry. The container registry will be set up while setting up a service provider
```bash
laconic-so deployment --dir backend-deployment push-images
```
### Deployment
* Create a spec file for the deployment:
```bash
cd /srv/snowball
cd /srv/backend-deployment
laconic-so --stack ~/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend deploy init --output snowball-deployment-spec.yml --config SNOWBALL_BACKEND_CONFIG_FILE_PATH=/config/local.toml
laconic-so --stack ~/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend deploy init --output backend-deployment-spec.yml --config SNOWBALL_BACKEND_CONFIG_FILE_PATH=/config/prod.toml
```
* Edit network in the spec file to map container ports to host ports:
* Edit the spec file to deploy the stack to k8s:
```bash
stack:
/home/dev/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend
deploy-to: k8s
kube-config: /home/dev/.kube/config-vs-narwhal.yaml
image-registry: container-registry.apps.vaasl.io/laconic-registry
config:
SNOWBALL_BACKEND_CONFIG_FILE_PATH: /config/prod.toml
network:
ports:
snowballtools-base-backend:
- '8000:8000'
deploy-backend:
- '8000'
http-proxy:
- host-name: deploy-backend.apps.vaasl.io
routes:
- path: '/'
proxy-to: deploy-backend:8000
volumes:
data:
configmaps:
config: ./configmaps/config
```
* Create a deployment from the spec file:
```bash
laconic-so --stack ~/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend deploy create --deployment-dir snowball-deployment --spec-file snowball-deployment-spec.yml
laconic-so --stack ~/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend deploy create --deployment-dir backend-deployment --spec-file backend-deployment-spec.yml
# This should create the deployment directory at `/srv/deploy-backend/backend-deployment`
```
* Modify file `backend-deployment/kubeconfig.yml` if required
```
apiVersion: v1
...
contexts:
- context:
cluster: ***
user: ***
name: default
...
```
NOTE: `context.name` must be default to use with SO
* Fetch the config template file for the snowball backend:
```bash
# Place in snowball deployment directory
wget -O /srv/snowball/snowball-deployment/data/config/local.toml https://git.vdb.to/cerc-io/testnet-laconicd-stack/raw/branch/main/ops/configs/snowball-config.toml
wget -O /srv/deploy-backend/backend-deployment/configmaps/config/prod.toml https://git.vdb.to/cerc-io/testnet-laconicd-stack/raw/branch/main/ops/configs/backend-deployment.toml
```
* Setup private key and bond id. Execute the following commands in the directory containing `stage2-deployment`
* Setup private key and bond. If not already setup, execute the following commands in the directory containing `stage2-deployment`
* Create a new account and fetch the private key
@ -1288,21 +1324,21 @@
```
* Update `/srv/snowball/snowball-deployment/data/config/local.toml`. Replace `<redacted>` with your credentials. Use the `userKey`, `bondId` and `authority` that you set up
* Update `/srv/snowball/snowball-deployment/data/config/prod.toml`. Replace `<redacted>` with your credentials. Use the `userKey`, `bondId` and `authority` that you set up
### Start
* Start the deployment:
```bash
laconic-so deployment --dir snowball-deployment start
laconic-so deployment --dir backend-deployment start
```
* Check status:
```bash
# Follow logs for snowball container
laconic-so deployment --dir snowball-deployment logs snowballtools-base-backend -f
laconic-so deployment --dir backend-deployment logs snowballtools-base-backend -f
```
</details>
@ -1310,7 +1346,7 @@
<details open>
<summary>snowball-frontend</summary>
## Snowball Frontend
## Deploy Frontend
* Source repo: <https://git.vdb.to/cerc-io/snowballtools-base>