This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement v1 of the healthcheck and create github files for open sour…
…ce (#1)
- Loading branch information
Showing
25 changed files
with
775 additions
and
139 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@vechainfoundation/node-hosting-code-owners |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
# [Project Name] Code of Conduct | ||
Node Healthcheck Code of Conduct | ||
|
||
## 1. Introduction | ||
|
||
The [Project Name] community is dedicated to providing a welcoming, inclusive, and harassment-free environment for everyone, regardless of age, gender, gender identity and expression, sexual orientation, disability, physical appearance, body size, race, ethnicity, nationality, religion, or technical experience. This Code of Conduct outlines our expectations for all members of the [Project Name] community, as well as the consequences for unacceptable behavior. | ||
The Node Healthcheck community is dedicated to providing a welcoming, inclusive, and harassment-free environment for everyone, regardless of age, gender, gender identity and expression, sexual orientation, disability, physical appearance, body size, race, ethnicity, nationality, religion, or technical experience. This Code of Conduct outlines our expectations for all members of the Node Healthcheck community, as well as the consequences for unacceptable behavior. | ||
|
||
We invite all those who participate in [Project Name] to help us create a safe and positive environment for everyone. | ||
We invite all those who participate in Node Healthcheck to help us create a safe and positive environment for everyone. | ||
|
||
## 2. Expected Behavior | ||
|
||
|
@@ -39,21 +39,23 @@ If a community member engages in unacceptable behavior, the community organizers | |
|
||
## 5. Reporting Guidelines | ||
|
||
If you are subject to or witness unacceptable behavior, or have any other concerns, please notify a community organizer as soon as possible. You can contact the project maintainer at [[email protected]]. | ||
|
||
Additionally, community organizers are available to help community members engage with local law enforcement or to otherwise help those experiencing unacceptable behavior feel safe. In the context of in-person events, organizers will also provide escorts as desired by the person experiencing distress. | ||
If you are subject to or witness unacceptable behavior, or have any other concerns, please [contact us](#8-contact-information) as soon as possible. | ||
|
||
## 6. Addressing Grievances | ||
|
||
If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify the project maintainer with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies. | ||
If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should [contact us](#8-contact-information) with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies. | ||
|
||
## 7. Scope | ||
|
||
We expect all community participants (contributors, paid or otherwise; sponsors; and other guests) to abide by this Code of Conduct in all community venues--online and in-person--as well as in all one-on-one communications pertaining to community business. | ||
|
||
## 8. Contact Information | ||
|
||
You can contact the project maintainer at [[email protected]]. | ||
* Project maintainer [email protected] | ||
* Project maintainer [email protected] | ||
* Main contributor [email protected] | ||
* Discord https://discord.com/invite/vechain #support | ||
* Support https://support.vechain.org | ||
|
||
## 9. License and Attribution | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# Node Healthcheck | ||
|
||
![Node Hosting Project Logo](images/node-hosting.png) | ||
|
||
## Introduction | ||
|
||
This is a simple API that checks the health of a vechain node by comparing the timestamp of its latest block with the current time. If the timestamp is within an acceptable tolerance setting, it is considered healthy. | ||
|
||
The main purpose of this tool is to be used in load balancers and availability monitors, to determine whether a node is not only online, but also fully synchronized with the blockchain. Moreover, it provides a `metrics` endpoint that is compatible with [prometheus](https://github.com/prometheus/prometheus) and exposes node health information to it. | ||
|
||
The API contains two endpoints: | ||
|
||
- `/healthcheck` | ||
|
||
used by ALB to determine whether the node is online | ||
|
||
- `/metrics` | ||
|
||
used by Prometheus to collect health metrics, such as the last block timestamp, number of seconds since last block and node health status. | ||
|
||
![Node Hosting Design Diagram - Healthcheck](images/architecture-diagram-healthcheck.webp) | ||
|
||
## Table of Contents | ||
|
||
- [Node Healthcheck](#node-healthcheck) | ||
- [Introduction](#introduction) | ||
- [Table of Contents](#table-of-contents) | ||
- [Getting Started](#getting-started) | ||
- [Configuration](#configuration) | ||
- [NODE\_URL](#node_url) | ||
- [NODE\_HEALTHCHECK\_PORT](#node_healthcheck_port) | ||
- [NODE\_HEALTHCHECK\_TOLERANCE\_IN\_SECONDS](#node_healthcheck_tolerance_in_seconds) | ||
- [Using Node](#using-node) | ||
- [Using Docker](#using-docker) | ||
- [Release new docker image](#release-new-docker-image) | ||
- [Contributing](#contributing) | ||
- [Roadmap](#roadmap) | ||
- [Changelog](#changelog) | ||
- [License](#license) | ||
- [Credits](#credits) | ||
|
||
## Getting Started | ||
|
||
You can run the application with node, or in a container using docker. | ||
|
||
### Configuration | ||
|
||
You may override the default configuration by modifying the `.env` file. | ||
|
||
#### NODE_URL | ||
|
||
The URL of the node to be monitored by the healthcheck. Defaults to `https://node-test.vechain.org` | ||
|
||
#### NODE_HEALTHCHECK_PORT | ||
|
||
The port of the healthcheck API. Defaults to `11012` | ||
|
||
#### NODE_HEALTHCHECK_TOLERANCE_IN_SECONDS | ||
|
||
The amount of seconds before the healthcheck classifies the node as `unhealthy`. Defaults to `15` | ||
|
||
### Using Node | ||
|
||
To install and run the application with [node version 16.20.2](https://nodejs.org/dist/v16.20.2/), run the following commands in the root directory of the project: | ||
|
||
```bash | ||
cd src | ||
npm ci | ||
npm start | ||
``` | ||
|
||
### Using Docker | ||
|
||
To build and run the image with docker, run the following commands in the root directory of the project: | ||
|
||
```bash | ||
docker build . -t node-healthcheck:dev | ||
docker run -d \ | ||
--name node-hc \ | ||
-p 11012:11012 \ | ||
-e NODE_URL=https://mainnet.vechain.org \ | ||
node-healthcheck:dev | ||
``` | ||
|
||
To download and run the image with docker: | ||
|
||
```bash | ||
docker run -d \ | ||
--name node-hc \ | ||
-p 11012:11012 \ | ||
-e NODE_URL=https://mainnet.vechain.org \ | ||
public.ecr.aws/vechainfoundation/node-healthcheck:latest | ||
``` | ||
|
||
For more image tags, refer to our [Container Registry](https://gallery.ecr.aws/vechainfoundation/node-healthcheck). | ||
|
||
#### Release new docker image | ||
|
||
To release a new version of the exporter, follow these steps: | ||
1. If you haven't done so already, enable multi-architecture builds on your system: | ||
1. Enable Docker BuildKit for multi-architecture builds by setting the environment variable in your shell profile: `export DOCKER_BUILDKIT=1` | ||
2. Create Docker BuildKit builder on your system: `docker buildx create --use` | ||
2. You will also need to have the AWS CLI installed and configured with credentials for ECR through profile `prod-node-devops`. | ||
3. Run `./release.sh <version>` to build and push the image to ECR, where `<version>` is the tag for the new image. | ||
4. Verify that the new release was correctly pushed to [the docker repository](https://gallery.ecr.aws/vechainfoundation/node-healthcheck). | ||
|
||
### Contributing | ||
|
||
If you want to contribute to this project and make it better, your help is very welcome. Contributing is also a great way to learn more about social coding on Github, new technologies and and their ecosystems and how to make constructive, helpful bug reports, feature requests and the noblest of all contributions: a good, clean pull request. | ||
|
||
For more details and guidelines on how to contribute, refer to [CONTRIBUTING](CONTRIBUTING.md). | ||
|
||
### Roadmap | ||
|
||
We are planning to add more features to this application going forward. More details to follow and suggestions are always welcome in the form of [GitHub issues](https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-an-issue). | ||
|
||
### Changelog | ||
|
||
- v1 [31-Mar-2023] Add prometheus metrics for node health | ||
- v0 [08-Feb-2023] Implement a basic healthcheck API for nodes, based on block timestamps | ||
|
||
### License | ||
|
||
This project is licensed under [the MIT license](LICENSE.md). | ||
|
||
### Credits | ||
|
||
Special recognition to the main contributors: | ||
- @fabiorigam |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Build | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
jobs: | ||
gitleaks: | ||
name: GitLeaks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: gitleaks/gitleaks-action@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }} | ||
|
||
sonarcloud: | ||
name: SonarCloud | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy | ||
- name: SonarCloud Scan | ||
uses: SonarSource/sonarcloud-github-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
|
||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./scripts | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up QEMU dependency | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Build docker image | ||
run: ./build.sh | ||
- name: Run docker image | ||
run: ./run.sh | ||
- name: Smoke test | ||
run: ./test.sh |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/node_modules/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Build stage for amd64 architecture | ||
FROM --platform=linux/amd64 node:gallium-alpine3.18 AS builder-amd64 | ||
|
||
WORKDIR /app | ||
# Copy the package.json and package-lock.json to the container | ||
COPY ./src/package*.json . | ||
RUN npm ci --ignore-scripts | ||
# Copy the rest of the application code to the container | ||
COPY ./src . | ||
|
||
# Build stage for arm64/v8 architecture | ||
FROM --platform=linux/arm64/v8 node:gallium-alpine3.18 AS builder-arm64 | ||
|
||
WORKDIR /app | ||
# Copy the package.json and package-lock.json to the container | ||
COPY ./src/package*.json . | ||
RUN npm ci --ignore-scripts | ||
# Copy the rest of the application code to the container | ||
COPY ./src . | ||
|
||
# Production stage | ||
FROM node:gallium-alpine3.18 AS runtime | ||
|
||
RUN addgroup -S nonroot && adduser -S nonroot -G nonroot | ||
WORKDIR /app | ||
|
||
# Copy the files from the appropriate builder stage based on the target architecture | ||
COPY --from=builder-amd64 /app /app | ||
COPY --from=builder-arm64 /app /app | ||
USER nonroot | ||
|
||
# Set the default command to run when starting the container | ||
CMD ["npm", "start"] |
Oops, something went wrong.