Skip to content

Commit

Permalink
feat: DEVOPS-1040 snapshot-hub migration to gcp
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlops committed Nov 3, 2023
1 parent 3a32db7 commit 21589d7
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/cicd-prd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
eth-spout,
neo-savant,
governance-api,
governance-snapshot,
]
include:
- application: bluebell-playground
Expand Down Expand Up @@ -66,6 +67,11 @@ jobs:
path: products/governance-api
tag_length: 8
tag_latest: false
- application: governance-snapshot
image_name: governance-snapshot
path: products/governance-snapshot
tag_length: 8
tag_latest: false
env:
DOCKER_DOMAIN: asia-docker.pkg.dev
REGISTRY: asia-docker.pkg.dev/prj-p-devops-services-tvwmrf63/zilliqa-public
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/cicd-stg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:
# devex,
# devex-apollo,
# neo-savant,
governance-api,
# governance-api,
governance-snapshot,
]
include:
# - application: developer-portal
Expand All @@ -52,9 +53,14 @@ jobs:
# path: products/neo-savant
# tag_length: 8
# tag_latest: false
- application: governance-api
image_name: governance-api
path: products/governance-api
# - application: governance-api
# image_name: governance-api
# path: products/governance-api
# tag_length: 8
# tag_latest: false
- application: governance-snapshot
image_name: governance-snapshot
path: products/governance-snapshot
tag_length: 8
tag_latest: false
# - application: pdt
Expand Down
181 changes: 181 additions & 0 deletions products/governance-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,184 @@ $ docker-compose up -d # runing.
https://github.com/Zilliqa/snapshot-spaces/commit/238e87aad231351a51727b06208ab407f0de1dcc

20220216

## Deploying applications with z

`z` is the one-stop shop for the Zilliqa provisioning and deployment operations. To deploy applications with z ensure the `z`
binary is installed in your operative system PATH environment variable. For more details about `z` please refer to the [documentation](https://github.com/Zilliqa/devops/blob/main/docs/z2.md).

## Deploying applications to staging

To deploy the staging environment we need to clone the devops repository and execute `z` from there:

```sh
git clone https://github.com/Zilliqa/devops.git
cd devops
source setenv
```

### Set the following environment variables

- `Z_ENV` to the path in which your `z.yaml` resides.
- `ZQ_USER` to your username (the bit before `@` in your email address)
- `GITHUB_PAT` (if you are deploying staging or production apps) to a classic PAT with all the repo permissions ticked.

for example:

```sh
export Z_ENV=`pwd`/infra/live/gcp/non-production/prj-d-staging/z_ase1.yaml
export ZQ_USER=<user_id>@zilliqa.com
export GITHUB_PAT=<GITHUB_PAT>
```

### Login to Google Cloud

```sh
z login
```

### Add the application to the staging `z.yaml` file. Skip this step if it is an existing application

1. Create a branch:

```sh
git checkout -b users/<username>/add_devex_to_staging_cluster
```

2. In the file `infra/live/gcp/non-production/prj-d-staging/z_ase1.yaml` add the following:

- in `apps` stanza add:

```yaml
clusters:
staging:
apps:
governance-api:
repo: https://github.com/Zilliqa/zilliqa-developer
path: products/governance-api/cd/overlays/staging
track: staging
type: kustomize
```
- in `subdomains` stanza add:

```yaml
infrastructure:
dns:
vars:
subdomains:
governance-api: {}
```

3. Push the changes

```sh
git add .
git commit -m "Add Devex to staging cluster"
git push origin users/<username>/add_devex_to_staging_cluster
```

4. Open a Pull Request to the main branch

5. Apply the changes

```sh
z plan
z apply
```

### Deploy the application

```sh
z app sync --cache-dir=.cache governance-api
```

Verify your application is running correct from the staging URL and with `kubectl` commands (if required).

## Deploying applications to production

To deploy the production environment we need to clone the devops repository and execute `z` from there:

```sh
git clone https://github.com/Zilliqa/devops.git
cd devops
source setenv
```

### Set the following environment variables

- `Z_ENV` to the path in which your `z.yaml` resides.
- `ZQ_USER` to your username (the bit before `@` in your email address)
- `GITHUB_PAT` (if you are deploying staging or production apps) to a classic PAT with all the repo permissions ticked.

for example:

```sh
export Z_ENV=`pwd`/infra/live/gcp/production/prj-p-prod-apps/z_ase1.yaml
export ZQ_USER=<user_id>@zilliqa.com
export GITHUB_PAT=<GITHUB_PAT>
```

### Login to Google Cloud

```sh
z login
```

### Add the application to the production `z.yaml` file. Skip this step if it is an existing application

1. Create a branch:

```sh
git checkout -b users/<username>/add_devex_to_production_cluster
```

2. In the file `infra/live/gcp/production/prj-p-prod-apps/z_ase1.yaml` add the following:

- in `apps` stanza add:

```yaml
clusters:
production:
apps:
governance-api:
repo: https://github.com/Zilliqa/zilliqa-developer
path: products/governance-api/cd/overlays/production
track: production
type: kustomize
```
- in `subdomains` stanza add:

```yaml
infrastructure:
dns:
vars:
subdomains:
governance-api: {}
```

3. Push the changes

```sh
git add .
git commit -m "Add Devex to production cluster"
git push origin users/<username>/add_devex_to_production_cluster
```

4. Open a Pull Request to the main branch

5. Apply the changes

```sh
z plan
z apply
```

### Deploy the application

```sh
z app sync --cache-dir=.cache governance-api
```

Verify your application is running correct from the production URL and with `kubectl` commands (if required).
1 change: 1 addition & 0 deletions products/governance-snapshot
Submodule governance-snapshot added at f615b2

0 comments on commit 21589d7

Please sign in to comment.