From 978f57604534a92dfe38836521dbc5d826448100 Mon Sep 17 00:00:00 2001 From: Smorci Date: Tue, 3 Sep 2024 14:39:44 +0200 Subject: [PATCH 01/15] Add commands README --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/README.md b/README.md index 32a8c73..059d86a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,40 @@ # ethereum-node-automation Automated solution to setup a local network of at least three ethereum nodes + +``` +kind create cluster --name ethereum-nodes +``` + +``` +flux bootstrap github \ + --owner=$GITHUB_USER \ + --repository=ethereum-node-automation \ + --branch=main \ + --path=./clusters/ethereum-node-automation \ + --personal +``` + +``` +flux create source git ethereum-node-automation \ + --url=https://github.com/Smorci/ethereum-node-automation \ + --branch=main \ + --interval=1m \ + --export > ./clusters/ethereum-node-automation/ethereum-node-automation-source.yaml +``` + +``` +flux create kustomization ethereum-node-automation \ + --target-namespace=ethereum-node-automation \ + --source=ethereum-node-automation \ + --path="./kustomize" \ + --prune=true \ + --wait=true \ + --interval=30m \ + --retry-interval=2m \ + --health-check-timeout=3m \ + --export > ./clusters/ethereum-node-automation/ethereum-node-automation-kustomization.yaml +``` + +``` +flux get kustomizations --watch +``` From 89eb6cd8e93d808936b70f93d21e83bab456c415 Mon Sep 17 00:00:00 2001 From: Szekely-Schnedarek Marton <43480627+Smorci@users.noreply.github.com> Date: Thu, 5 Sep 2024 17:23:58 +0200 Subject: [PATCH 02/15] Update README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 059d86a..18483e1 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,18 @@ Automated solution to setup a local network of at least three ethereum nodes kind create cluster --name ethereum-nodes ``` +``` +./scripts/generate-token.sh +``` + +``` +kubectl create namespace ethereum-node-automation +``` + +``` +kubens ethereum-node-automation +``` + ``` flux bootstrap github \ --owner=$GITHUB_USER \ From fd5cce666c720bb1d96b382f7d19b49433c21abc Mon Sep 17 00:00:00 2001 From: Szekely-Schnedarek Marton <43480627+Smorci@users.noreply.github.com> Date: Fri, 6 Sep 2024 08:43:10 +0200 Subject: [PATCH 03/15] Update README.md --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 18483e1..58d3305 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,19 @@ # ethereum-node-automation -Automated solution to setup a local network of at least three ethereum nodes +Simple to use, packaged, continuously deployed solution to start 3 monitored ethereum nodes in your local environment + +## Pre-requisite +1.Nix version 2.18.2 or higher. Follow the [installation instructions](https://nix.dev/install-nix.html) for your operating system. +2. Github personal access token. Follow the [official documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic) or take a look at the detailed application specific documentation in this repository. + +## `.env` file + +Create a `.env` file in the repository root, adding your github access token +``` +export GITHUB_TOKEN= +``` +> Replace `` with the generated access token in *pre-requisite* section + +## Usage ``` kind create cluster --name ethereum-nodes From a3370b1821a16cb50dea5b96f59e7047e72697e1 Mon Sep 17 00:00:00 2001 From: Szekely-Schnedarek Marton <43480627+Smorci@users.noreply.github.com> Date: Fri, 6 Sep 2024 16:59:23 +0200 Subject: [PATCH 04/15] Update README.md --- README.md | 63 +++++++++++++++++++++++-------------------------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 58d3305..23aa066 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,55 @@ -# ethereum-node-automation -Simple to use, packaged, continuously deployed solution to start 3 monitored ethereum nodes in your local environment +# Ethereum Node Automation +Simple to use, packaged, continuously deployed solution to start 3 monitored ethereum nodes in your local environment. ## Pre-requisite 1.Nix version 2.18.2 or higher. Follow the [installation instructions](https://nix.dev/install-nix.html) for your operating system. 2. Github personal access token. Follow the [official documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic) or take a look at the detailed application specific documentation in this repository. ## `.env` file - Create a `.env` file in the repository root, adding your github access token ``` export GITHUB_TOKEN= ``` -> Replace `` with the generated access token in *pre-requisite* section ## Usage - +### Bootstrap cluster +To start a kubernetes cluster and deploy 3 ethereum [full nodes](https://ethereum.org/en/developers/docs/nodes-and-clients/#what-are-nodes-and-clients) (two clients each), grafana and prometheus in the *ethereum-node-automation* namespace, run: ``` -kind create cluster --name ethereum-nodes +nix run ``` +This will start each deployment and continuously sync with the *main* branch of this repository, with Flux +### Delete cluster +To stop and destroy the cluster on your local machine, you can run: ``` -./scripts/generate-token.sh +nix run .#delete ``` +### Suspend Flux continuous deployment +To stop Flux from continuously syncing the cluster, you can suspend the Flux kustomization, run: ``` -kubectl create namespace ethereum-node-automation +flux suspend kustomization ethereum-node-automation ``` +### Get Flux continuous deployment status +To see the status of the deployment, run: ``` -kubens ethereum-node-automation +flux get kustomizations ``` +## Monitoring +After deploying the applications, there will be a Grafana and a Prometheus deployment in the namespace. To access the Grafan UI, you should port-forward the HTTP port of Grafana: ``` -flux bootstrap github \ - --owner=$GITHUB_USER \ - --repository=ethereum-node-automation \ - --branch=main \ - --path=./clusters/ethereum-node-automation \ - --personal +kubectl port-forward svc/grafana 3000:3000 ``` +After that you can access the UI from your browser at `localhost:3000`. -``` -flux create source git ethereum-node-automation \ - --url=https://github.com/Smorci/ethereum-node-automation \ - --branch=main \ - --interval=1m \ - --export > ./clusters/ethereum-node-automation/ethereum-node-automation-source.yaml -``` +The password for the admin user is `admin`. After logging in it is advised to update the password. -``` -flux create kustomization ethereum-node-automation \ - --target-namespace=ethereum-node-automation \ - --source=ethereum-node-automation \ - --path="./kustomize" \ - --prune=true \ - --wait=true \ - --interval=30m \ - --retry-interval=2m \ - --health-check-timeout=3m \ - --export > ./clusters/ethereum-node-automation/ethereum-node-automation-kustomization.yaml -``` +The instance is provisioned with two dashboards that use Prometheus as a datasource. Prometheus is configured to scrape data from the ethereum clients themselves and the kubernetes resources. -``` -flux get kustomizations --watch -``` +## More details +If you would wish to read more about implementation details check out the detailed documentation in the docs folder. + +## Contributing +Contributions are welcome, feel free to open a discussion on the repository. From 4d24eb71511db818af9292a0b16e22566b914d4a Mon Sep 17 00:00:00 2001 From: Smorci Date: Tue, 3 Sep 2024 14:39:44 +0200 Subject: [PATCH 05/15] Add commands README --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/README.md b/README.md index 32a8c73..059d86a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,40 @@ # ethereum-node-automation Automated solution to setup a local network of at least three ethereum nodes + +``` +kind create cluster --name ethereum-nodes +``` + +``` +flux bootstrap github \ + --owner=$GITHUB_USER \ + --repository=ethereum-node-automation \ + --branch=main \ + --path=./clusters/ethereum-node-automation \ + --personal +``` + +``` +flux create source git ethereum-node-automation \ + --url=https://github.com/Smorci/ethereum-node-automation \ + --branch=main \ + --interval=1m \ + --export > ./clusters/ethereum-node-automation/ethereum-node-automation-source.yaml +``` + +``` +flux create kustomization ethereum-node-automation \ + --target-namespace=ethereum-node-automation \ + --source=ethereum-node-automation \ + --path="./kustomize" \ + --prune=true \ + --wait=true \ + --interval=30m \ + --retry-interval=2m \ + --health-check-timeout=3m \ + --export > ./clusters/ethereum-node-automation/ethereum-node-automation-kustomization.yaml +``` + +``` +flux get kustomizations --watch +``` From 772fca316d3b67c0bfbe9626d46caa41b6428a09 Mon Sep 17 00:00:00 2001 From: Szekely-Schnedarek Marton <43480627+Smorci@users.noreply.github.com> Date: Thu, 5 Sep 2024 17:23:58 +0200 Subject: [PATCH 06/15] Update README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 059d86a..18483e1 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,18 @@ Automated solution to setup a local network of at least three ethereum nodes kind create cluster --name ethereum-nodes ``` +``` +./scripts/generate-token.sh +``` + +``` +kubectl create namespace ethereum-node-automation +``` + +``` +kubens ethereum-node-automation +``` + ``` flux bootstrap github \ --owner=$GITHUB_USER \ From 93d0f6ec60d98733fe88ac121aa1e9950832dad6 Mon Sep 17 00:00:00 2001 From: Szekely-Schnedarek Marton <43480627+Smorci@users.noreply.github.com> Date: Fri, 6 Sep 2024 08:43:10 +0200 Subject: [PATCH 07/15] Update README.md --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 18483e1..58d3305 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,19 @@ # ethereum-node-automation -Automated solution to setup a local network of at least three ethereum nodes +Simple to use, packaged, continuously deployed solution to start 3 monitored ethereum nodes in your local environment + +## Pre-requisite +1.Nix version 2.18.2 or higher. Follow the [installation instructions](https://nix.dev/install-nix.html) for your operating system. +2. Github personal access token. Follow the [official documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic) or take a look at the detailed application specific documentation in this repository. + +## `.env` file + +Create a `.env` file in the repository root, adding your github access token +``` +export GITHUB_TOKEN= +``` +> Replace `` with the generated access token in *pre-requisite* section + +## Usage ``` kind create cluster --name ethereum-nodes From 1e41451ca5c2cd7e4d8e45c660df0fb058887de7 Mon Sep 17 00:00:00 2001 From: Szekely-Schnedarek Marton <43480627+Smorci@users.noreply.github.com> Date: Fri, 6 Sep 2024 16:59:23 +0200 Subject: [PATCH 08/15] Update README.md --- README.md | 63 +++++++++++++++++++++++-------------------------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 58d3305..23aa066 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,55 @@ -# ethereum-node-automation -Simple to use, packaged, continuously deployed solution to start 3 monitored ethereum nodes in your local environment +# Ethereum Node Automation +Simple to use, packaged, continuously deployed solution to start 3 monitored ethereum nodes in your local environment. ## Pre-requisite 1.Nix version 2.18.2 or higher. Follow the [installation instructions](https://nix.dev/install-nix.html) for your operating system. 2. Github personal access token. Follow the [official documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic) or take a look at the detailed application specific documentation in this repository. ## `.env` file - Create a `.env` file in the repository root, adding your github access token ``` export GITHUB_TOKEN= ``` -> Replace `` with the generated access token in *pre-requisite* section ## Usage - +### Bootstrap cluster +To start a kubernetes cluster and deploy 3 ethereum [full nodes](https://ethereum.org/en/developers/docs/nodes-and-clients/#what-are-nodes-and-clients) (two clients each), grafana and prometheus in the *ethereum-node-automation* namespace, run: ``` -kind create cluster --name ethereum-nodes +nix run ``` +This will start each deployment and continuously sync with the *main* branch of this repository, with Flux +### Delete cluster +To stop and destroy the cluster on your local machine, you can run: ``` -./scripts/generate-token.sh +nix run .#delete ``` +### Suspend Flux continuous deployment +To stop Flux from continuously syncing the cluster, you can suspend the Flux kustomization, run: ``` -kubectl create namespace ethereum-node-automation +flux suspend kustomization ethereum-node-automation ``` +### Get Flux continuous deployment status +To see the status of the deployment, run: ``` -kubens ethereum-node-automation +flux get kustomizations ``` +## Monitoring +After deploying the applications, there will be a Grafana and a Prometheus deployment in the namespace. To access the Grafan UI, you should port-forward the HTTP port of Grafana: ``` -flux bootstrap github \ - --owner=$GITHUB_USER \ - --repository=ethereum-node-automation \ - --branch=main \ - --path=./clusters/ethereum-node-automation \ - --personal +kubectl port-forward svc/grafana 3000:3000 ``` +After that you can access the UI from your browser at `localhost:3000`. -``` -flux create source git ethereum-node-automation \ - --url=https://github.com/Smorci/ethereum-node-automation \ - --branch=main \ - --interval=1m \ - --export > ./clusters/ethereum-node-automation/ethereum-node-automation-source.yaml -``` +The password for the admin user is `admin`. After logging in it is advised to update the password. -``` -flux create kustomization ethereum-node-automation \ - --target-namespace=ethereum-node-automation \ - --source=ethereum-node-automation \ - --path="./kustomize" \ - --prune=true \ - --wait=true \ - --interval=30m \ - --retry-interval=2m \ - --health-check-timeout=3m \ - --export > ./clusters/ethereum-node-automation/ethereum-node-automation-kustomization.yaml -``` +The instance is provisioned with two dashboards that use Prometheus as a datasource. Prometheus is configured to scrape data from the ethereum clients themselves and the kubernetes resources. -``` -flux get kustomizations --watch -``` +## More details +If you would wish to read more about implementation details check out the detailed documentation in the docs folder. + +## Contributing +Contributions are welcome, feel free to open a discussion on the repository. From 28bafeee5557073b84789427e5d6cad5537a95aa Mon Sep 17 00:00:00 2001 From: Smorci Date: Fri, 6 Sep 2024 17:03:43 +0200 Subject: [PATCH 09/15] Add DETAILS.md --- docs/DETAILS.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/DETAILS.md diff --git a/docs/DETAILS.md b/docs/DETAILS.md new file mode 100644 index 0000000..e69de29 From 64d4d0edfbbb63bf17a7c8290e24bd636f4f0fe8 Mon Sep 17 00:00:00 2001 From: Szekely-Schnedarek Marton <43480627+Smorci@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:05:24 +0200 Subject: [PATCH 10/15] Update DETAILS.md --- docs/DETAILS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/DETAILS.md b/docs/DETAILS.md index e69de29..464a7cf 100644 --- a/docs/DETAILS.md +++ b/docs/DETAILS.md @@ -0,0 +1 @@ +Test From e5b92b2754d93b50cd972aaf7cd0d908d4c829ab Mon Sep 17 00:00:00 2001 From: Smorci Date: Fri, 6 Sep 2024 17:06:30 +0200 Subject: [PATCH 11/15] Rename DETAILS.md --- docs/{DETAILS.md => README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/{DETAILS.md => README.md} (100%) diff --git a/docs/DETAILS.md b/docs/README.md similarity index 100% rename from docs/DETAILS.md rename to docs/README.md From 94cdc97d88a2c5bff6ac0567e385bef344156c70 Mon Sep 17 00:00:00 2001 From: Szekely-Schnedarek Marton <43480627+Smorci@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:51:22 +0200 Subject: [PATCH 12/15] Update README.md --- docs/README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 464a7cf..3090ebe 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1 +1,19 @@ -Test +# Detailed documentation +This document holds a comprehensive description of the whole system architecture and the system components. The solution focuses on creating a development environment, so further in this document the word environment refers to the local development environment. + +When designing the system the key concepts that guided the decisions were: scalability, observability, simplicity of use, reproducibility, declarativity and reliability. + +## Architecture +The engine of choice for virtualisation is Docker which provides great tooling and support for running workloads in the environment. Docker also enables us to use countless images, integrate with a ton of software and update our workloads seemlessly. Overall it is a great tool to base our architecture on. + +Next, to achieve a scalable solution we needed a container orchestration tool. The most supported one is Kubernetes, which provides great tooling for managing containers and other resources. + +`kind` proved as a great and simple tool for creating clusters in the local environment. Together with `kubectx` it is easy to manage Kubernetes nodes and switch between contexts and namespaces. + +To ensure a reliable system that uses GitOps principles a continuous deployment tool is needed. This role is taken by Flux which is a tool for keeping Kubernetes clusters in sync with sources of configuration (like Git repositories), and automating updates to configuration when there is new code to deploy. Flux works by installing custom Kubernetes resources on the cluster and polling Git sources and Kustomizations to compare them with the actual cluster state. +Flux is a system capable of many things and can be developed in complex and trusted systems, so it is a good choice for a project that could grow. +Having said that, the idea is simple: setup Flux once, than push to the repository and let Flux take care of the rest. + +Achieving observability means that we need a tool for gathering metrics from our workloads and one to visualize the data gathered. The tools of choice are Prometheus for gathering metrics and Grafana for visualizing. These two go hand in hand and are supported by many tools in our stack. + +Lastly we need to choose our Ethereum clients which are also called layers. A full Ethereum node consists of an execution layer, responsible for listening for new transations, executing them in EVM and to manage the database and a consensus layer, responsible for implementing and completing the proof-of-stake algorithm. Two nodes that are well tested, laverage the speed and reliability of Rust and fit well with the rest of our stack are Reth (execution layer) and Lighthouse (consensus layer). From bb73364c01dba15e828c06dabaad9068eff062d5 Mon Sep 17 00:00:00 2001 From: Szekely-Schnedarek Marton <43480627+Smorci@users.noreply.github.com> Date: Fri, 6 Sep 2024 19:26:00 +0200 Subject: [PATCH 13/15] Update README.md --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 23aa066..b07fb5b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Simple to use, packaged, continuously deployed solution to start 3 monitored eth ## Pre-requisite 1.Nix version 2.18.2 or higher. Follow the [installation instructions](https://nix.dev/install-nix.html) for your operating system. 2. Github personal access token. Follow the [official documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic) or take a look at the detailed application specific documentation in this repository. +3. Direnv. Follow the [installation instructions](https://direnv.net/docs/installation.html) ## `.env` file Create a `.env` file in the repository root, adding your github access token @@ -11,6 +12,14 @@ Create a `.env` file in the repository root, adding your github access token export GITHUB_TOKEN= ``` +## Devshell +If you would like to use the development shell provided by the nix flake, run: +``` +direnv allow +``` + +In the shell you can use tools such as `kind` `flux` `kubectl` and `kubectx` + ## Usage ### Bootstrap cluster To start a kubernetes cluster and deploy 3 ethereum [full nodes](https://ethereum.org/en/developers/docs/nodes-and-clients/#what-are-nodes-and-clients) (two clients each), grafana and prometheus in the *ethereum-node-automation* namespace, run: @@ -37,6 +46,8 @@ To see the status of the deployment, run: flux get kustomizations ``` + + ## Monitoring After deploying the applications, there will be a Grafana and a Prometheus deployment in the namespace. To access the Grafan UI, you should port-forward the HTTP port of Grafana: ``` From 80bcd31e4f49d69dec8d36db4886d9f332dc5c7c Mon Sep 17 00:00:00 2001 From: Szekely-Schnedarek Marton <43480627+Smorci@users.noreply.github.com> Date: Fri, 6 Sep 2024 20:02:34 +0200 Subject: [PATCH 14/15] Update README.md --- docs/README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index 3090ebe..1a91985 100644 --- a/docs/README.md +++ b/docs/README.md @@ -14,6 +14,52 @@ To ensure a reliable system that uses GitOps principles a continuous deployment Flux is a system capable of many things and can be developed in complex and trusted systems, so it is a good choice for a project that could grow. Having said that, the idea is simple: setup Flux once, than push to the repository and let Flux take care of the rest. -Achieving observability means that we need a tool for gathering metrics from our workloads and one to visualize the data gathered. The tools of choice are Prometheus for gathering metrics and Grafana for visualizing. These two go hand in hand and are supported by many tools in our stack. +Achieving observability means that we need a tool for gathering metrics from our workloads and one to visualize the data gathered. The tools of choice are Prometheus for gathering metrics and Grafana for visualizing. These two go hand in hand and are supported by many tools in our stack. -Lastly we need to choose our Ethereum clients which are also called layers. A full Ethereum node consists of an execution layer, responsible for listening for new transations, executing them in EVM and to manage the database and a consensus layer, responsible for implementing and completing the proof-of-stake algorithm. Two nodes that are well tested, laverage the speed and reliability of Rust and fit well with the rest of our stack are Reth (execution layer) and Lighthouse (consensus layer). +We also need to choose our Ethereum clients which are also called layers. A full Ethereum node consists of an execution layer, responsible for listening for new transations, executing them in EVM and to manage the database and a consensus layer, responsible for implementing and completing the proof-of-stake algorithm. Two nodes that are well tested, laverage the speed and reliability of Rust and fit well with the rest of our stack are Reth (execution layer) and Lighthouse (consensus layer). + +Lastly to encapsulate everything and abstract away the implementation details from the user the Nix package manager was chosen which is famous for it's reproducible builds. This way the user can start the process by just executing the `nix run` command. + +In the following diagram you can see a visualisation of the architecture + +![image](https://github.com/user-attachments/assets/ad1bab83-d5a8-4731-b929-c99507e54281) + +## Breakdown of the bootstrap process +In Nix, the package is basically a shell application. The function `writeShellApplication` creates a shell script that has some runtime inputs and is checked by `shellcheck`. + +- The bootstrap package (default package in the nix context) starts with sourcing the `.env` file which holds the access token of the user. We will need that for Flux to authenticate the users actions on Github. + +- Afterwards, we use `kind` to create a cluster name `ethereum-node-automation` in the environment of the user. The user can inspect this cluster with `kubectx and kubens`. For further information about how `kind` creates the cluster, see the kind [documentation](https://kind.sigs.k8s.io/). + +- After the cluster is created, we create a namespace for our Ethereum nodes and select that namespace with kubens. + +- The node need a JWT token. We create this with the script found under `scripts/generate-token.sh` which also creates a kubernetes secret from this token. That secret will be mounted in our nodes containers. + +- Here comes Flux. We bootstrap Flux to our cluster, installing the custom resources it needs to automate our infrastructures deployment. + +- We create two Flux resources: GitRepository and Kustomization. The GitRepository resource is responsible for telling Flux what is the source of truth for the cluster configuration. In our case it's this repository's main branch. The Kustomization tells Flux the target of the deployment, the path to the Kubernetes manifests that should be monitored and the sync interval. With these two in the repository, Flux will start syncing the cluster with the repository. + +The deletion process is quite simple, the command `nix run .#delete` runs the delete package, which is a shell application running `kind delete` to delete the local cluster. + +## Monitoring +It is simple in concept: Prometheus scrapes the metrics from the metrics endpoints exposed by the containers and we consume those metrics by providing Prometheus as a datasource for Grafana. + +The Prometheus configuration is as follows: Prometheus scrapes any metrics from kubernetes resources that implement the `metrics-path, port and scrape` Prometheus annotations. It also scrapes metrics from the Kubelet CAdvisor API which provide us metrics about the kubernetes resources (cpu, memory, state, etc.) + +These scraped metrics than are transmitted to Grafana via a datasource. This is provisioned at the time fo deployment. This datasource is then used by two dashboards, which are downloaded and provisined via a shell script in an init container. The dashboards provide information about the nodes and the kubernetes resources. + +## Shortcomings +This solution is not perfect by any means, it has many advantages but it has a lot of flaws. Let's enumerate: +- Although it is simple to use, it is complex underneat, it has many points of failure +- Many things are hardcoded, configuration of the system is not an option +- It is not suitable for a staging or production environment +- It is hard to maintain + +Most of these problems have a solution and they can be fixed with some refactoring and appropiate tooling. + +## Future plans + +- Make a Helm package for the ethereum node +- Use [helmfile](https://github.com/helmfile/helmfile) to create declarative environments +- Refactor code to use variables +- Flux auto image updates From 6f12c7e3355aa7f3da1f12c7809b2d0c331513c6 Mon Sep 17 00:00:00 2001 From: Smorci Date: Fri, 6 Sep 2024 20:08:18 +0200 Subject: [PATCH 15/15] Change to stable nixpkgs version --- flake.lock | 8 ++++---- flake.nix | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 959e344..e150dd0 100644 --- a/flake.lock +++ b/flake.lock @@ -2,16 +2,16 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1725099143, - "narHash": "sha256-CHgumPZaC7z+WYx72WgaLt2XF0yUVzJS60rO4GZ7ytY=", + "lastModified": 1717179513, + "narHash": "sha256-vboIEwIQojofItm2xGCdZCzW96U85l9nDW3ifMuAIdM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5629520edecb69630a3f4d17d3d33fc96c13f6fe", + "rev": "63dacb46bf939521bdc93981b4cbb7ecb58427a0", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "24.05", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index 6e20ba4..c7beaa2 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/24.05"; utils.url = "github:numtide/flake-utils"; };