Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support devspace local-dev profile for CRIB #12938

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions charts/chainlink-cluster/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Helm
charts/
requirements.lock
.rendered
values-profiles/*
!values-profiles/values-dev.yaml.example
!values-profiles/README.md
2 changes: 1 addition & 1 deletion charts/chainlink-cluster/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ dependencies:
repository: https://grafana.github.io/helm-charts
version: 7.3.2
digest: sha256:37722063f68689c42ac1d6549ddfae4756370c1659b8ac1c0d7da8916c6fad3d
generated: "2024-02-27T11:04:29.920915-06:00"
generated: "2024-04-23T17:49:50.347667-04:00"
2 changes: 1 addition & 1 deletion charts/chainlink-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: chainlink-cluster
description: Chainlink nodes cluster
version: 0.4.0
version: 0.4.2
chainchad marked this conversation as resolved.
Show resolved Hide resolved
appVersion: "2.6.0"
dependencies:
- name: mockserver
Expand Down
179 changes: 166 additions & 13 deletions charts/chainlink-cluster/README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,197 @@
# Chainlink cluster

Example CL nodes cluster for system level tests
Install `kubefwd` (no nixpkg for it yet, planned)

```sh
brew install txn2/tap/kubefwd
```

If you want to build images you need [docker](https://docs.docker.com/engine/install/) service running

Enter the shell (from the root project dir)

```sh
nix develop
```

# Develop
## Install from release
Note: The setup below doesn't work at the moment.

Add the repository
## New cluster

We are using [devspace](https://www.devspace.sh/docs/getting-started/installation?x0=3)

Configure the cluster, see `deployments.app.helm.values` and [values.yaml](./values.yaml) comments for more details

Set up your K8s access

```sh
export DEVSPACE_IMAGE="..."
./setup.sh ${my-personal-namespace-name-crib}
```
helm repo add chainlink-cluster https://github.com/raw/smartcontractkit/chainlink/helm-release/
helm repo update

Create a .env file based on the .env.sample file

```sh
cp .env.sample .env
# Fill in the required values in .env
```

Set default namespace
Build and deploy the current state of your repository

```sh
devspace deploy
```
kubectl create ns cl-cluster
kubectl config set-context --current --namespace cl-cluster

Default `ttl` is `72h`, use `ttl` command to update if you need more time

Valid values are `1h`, `2m`, `3s`, etc. Go time format is invalid `1h2m3s`

```sh
devspace run ttl ${namespace} 120h
```

Install
If you want to deploy an image tag that is already available in ECR, use:

```sh
devspace deploy --override-image-tag "<image-tag>"
```

If you want to deploy an image tag from a public ECR repo, use:

```sh
export DEVSPACE_IMAGE=public.ecr.aws/chainlink/chainlink
devspace deploy --override-image-tag 2.9.0
```

To apply custom TOML configuration specific for your nodes, create a `values-dev.yaml` file in the `./values-profiles` directory. Start by copying the example file:

```sh
cp values-profiles/values-dev.yaml.example values-profiles/values-dev.yaml

```

Then customize the values-dev.yaml file as needed. To use this configuration during deployment, pass the --profile local-dev flag:

```sh
devspace deploy --profile local-dev
```

Forward ports to check UI or run tests

```sh
devspace run connect ${my-personal-namespace-name-crib}
```

List ingress hostnames

```sh
devspace run ingress-hosts
```

Destroy the cluster

```sh
devspace purge
```

## Running load tests

Check this [doc](../../integration-tests/load/ocr/README.md)

If you used `devspace dev ...` always use `devspace reset pods` to switch the pods back

# Helm

If you would like to use `helm` directly, please uncomment data in `values.yaml`

## Install from local files

```sh
helm install -f values.yaml cl-cluster .
```

Forward all apps (in another terminal)

```sh
sudo kubefwd svc -n cl-cluster
```

Then you can connect and run your tests

## Install from release

Add the repository

```sh
helm repo add chainlink-cluster https://github.com/raw/smartcontractkit/chainlink/helm-release/
helm repo update
```

Set default namespace

```sh
kubectl create ns cl-cluster
kubectl config set-context --current --namespace cl-cluster
```

## Create a new release
Note: The setup below doesn't work at the moment.

Bump version in `Chart.yml` add your changes and add `helm_release` label to any PR to trigger a release

## Helm Test

```
```sh
helm test cl-cluster
```

## Uninstall

```
```sh
helm uninstall cl-cluster
```
```

# Grafana dashboard

We are using [Grabana](https://github.com/K-Phoen/grabana) lib to create dashboards programmatically

You can also select dashboard platform in `INFRA_PLATFORM` either `kubernetes` or `docker`

```sh
export LOKI_TENANT_ID=promtail
export LOKI_URL=...
export GRAFANA_URL=...
export GRAFANA_TOKEN=...
export PROMETHEUS_DATA_SOURCE_NAME=Thanos
export LOKI_DATA_SOURCE_NAME=Loki
export INFRA_PLATFORM=kubernetes
export GRAFANA_FOLDER=CRIB
export DASHBOARD_NAME=Core-Cluster-Load

devspace run dashboard_deploy
```

Open Grafana folder `DashboardCoreDebug` and find dashboard `ChainlinkClusterDebug`

# Testing

Deploy your dashboard and run soak/load [tests](../../integration-tests/load/), check [README](../../integration-tests/README.md) for further explanations

```sh
devspace run dashboard_deploy
devspace run workload
devspace run dashboard_test
```

# Local Testing

Go to [dashboard-lib](../../dashboard) and link the modules locally

```sh
cd dashboard
pnpm link --global
cd charts/chainlink-cluster/dashboard/tests
pnpm link --global dashboard-tests
```

Then run the tests with commands mentioned above
18 changes: 11 additions & 7 deletions charts/chainlink-cluster/templates/chainlink-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ data:
CREATE
EXTENSION pg_stat_statements;
default.toml: |
{{ if (hasKey $cfg "toml") }}
{{ $cfg.toml | nindent 4 }}
{{ else }}
{{- if (hasKey $cfg "toml") }}
{{ $cfg.toml | nindent 4 }}
{{- else if and (hasKey $.Values.chainlink.global "toml") $.Values.chainlink.global.toml }}
{{ $.Values.chainlink.global.toml | nindent 4 }}
{{- else }}
RootDir = './clroot'
[Log]
JSONConsole = true
Expand Down Expand Up @@ -57,12 +59,14 @@ data:
{{- end }}
[WebServer.TLS]
HTTPSPort = 0
{{ end }}
{{- end }}
overrides.toml: |
{{ if (hasKey $cfg "overridesToml") }}
{{ $cfg.overridesToml | nindent 4 }}
{{- if (hasKey $cfg "overridesToml") }}
{{- $cfg.overridesToml | nindent 4 }}
{{- else if and (hasKey $.Values.chainlink.global "overridesToml") $.Values.chainlink.global.overridesToml }}
{{- $.Values.chainlink.global.overridesToml | nindent 4 }}
{{ else }}
{{ end }}
{{- end }}
secrets.toml: |
{{ if (hasKey $cfg "secretsToml") }}
{{ $cfg.secretsToml | nindent 4 }}
Expand Down
3 changes: 3 additions & 0 deletions charts/chainlink-cluster/values-profiles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# values-profiles

Store helm values files for different [DevSpace profiles](https://www.devspace.sh/docs/configuration/profiles/) here. The convention is to make the yaml file name in here match the DevSpace profile name.
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Disable geth if using existing testnets.
geth:
enabled: false
chainlink:
global:
toml: |-
RootDir = './clroot'
[Log]
JSONConsole = true
Level = 'debug'
[WebServer]
AllowOrigins = '*'
SecureCookies = false
SessionTimeout = '999h0m0s'
[Feature]
FeedsManager = true
LogPoller = true
UICSAKeys = true
[OCR]
Enabled = true
DefaultTransactionQueueDepth = 0
[P2P]
[P2P.V2]
Enabled = true
ListenAddresses = ['0.0.0.0:6690']
AnnounceAddresses = ['0.0.0.0:6690']
DeltaDial = '500ms'
DeltaReconcile = '5s'
[[EVM]]
# Avax Fuji Testnet
ChainID = "43113"
MinContractPayment = '0'
AutoCreateKey = true
FinalityDepth = 1
[[EVM.Nodes]]
Name = 'avax-fuji-testnet-official'
WSURL = 'wss://api.avax-test.network/ext/bc/C/ws'
HTTPURL = 'https://api.avax-test.network/ext/bc/C/rpc'
[[EVM]]
# BSC Testnet
ChainID = "97"
MinContractPayment = '0'
AutoCreateKey = true
FinalityDepth = 1
[[EVM.Nodes]]
Name = 'bsc-testnet-official'
HTTPURL = 'https://data-seed-prebsc-1-s.bnbchain.org:8545'
WSURL = 'wss://data-seed-prebsc-1-s1.binance.org:8545/'
[WebServer.TLS]
HTTPSPort = 0

overridesToml: |-
[Feature]
LogPoller = true

[Log]
Level = 'debug'
JSONConsole = true

[Log.File]
MaxSize = '0b'

[WebServer]
AllowOrigins = '*'
HTTPPort = 6688
SecureCookies = false
HTTPWriteTimeout = '1m'

[WebServer.RateLimit]
Authenticated = 2000
Unauthenticated = 1000

[WebServer.TLS]
HTTPSPort = 0

[Database]
MaxIdleConns = 50
MaxOpenConns = 50
MigrateOnStartup = true

[OCR2]
Enabled = true
DefaultTransactionQueueDepth = 0

[OCR]
Enabled = false
DefaultTransactionQueueDepth = 0

[P2P]
[P2P.V2]
Enabled = true
ListenAddresses = ['0.0.0.0:6690']
AnnounceAddresses = ['0.0.0.0:6690']
DeltaDial = '500ms'
DeltaReconcile = '5s'
Loading
Loading