From fb58bda5898700a94560b1d56aa8781b0eb298df Mon Sep 17 00:00:00 2001 From: Smorci Date: Thu, 5 Sep 2024 21:08:46 +0200 Subject: [PATCH] Add nix shell apps and hardcode number of nodes to 3 --- .gitignore | 1 + flake.nix | 64 ++++++++++++++++++++++++++++++++-- kustomize/consensus-layer.yaml | 2 +- kustomize/execution-layer.yaml | 2 +- 4 files changed, 65 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 92b2793..f00fed8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .direnv +.env diff --git a/flake.nix b/flake.nix index a7aefee..6e20ba4 100644 --- a/flake.nix +++ b/flake.nix @@ -11,8 +11,68 @@ in { devShell = with pkgs; mkShell { - buildInputs = [ fluxcd fluxctl kind kubectx kubectl git openssl ]; + buildInputs = [ fluxcd fluxctl kind kubectx kubectl openssl ]; }; - } + + packages = rec { + default = with pkgs; writeShellApplication { + name = "bootstrap-ethereum-cluster"; + + runtimeInputs = [ kind fluxcd kubectl kubectx openssl ]; + + text = '' + set -e + + # shellcheck source=/dev/null + source .env + + kind create cluster --name ethereum-nodes + + kubectl create namespace ethereum-node-automation + + kubens ethereum-node-automation + + # shellcheck source=/dev/null + source scripts/generate-token.sh + + flux bootstrap github \ + --owner=Smorci \ + --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 + ''; + + }; + delete = with pkgs; writeShellApplication { + name = "delete-ethereum-cluster"; + + runtimeInputs = [ kind ]; + + text = '' + set -e + + kind delete clusters ethereum-nodes + ''; + }; + }; + } ); } diff --git a/kustomize/consensus-layer.yaml b/kustomize/consensus-layer.yaml index 438e574..ad2ddab 100644 --- a/kustomize/consensus-layer.yaml +++ b/kustomize/consensus-layer.yaml @@ -3,7 +3,7 @@ kind: Deployment metadata: name: consensus-layer spec: - replicas: 1 + replicas: 3 selector: matchLabels: app: consensus-layer diff --git a/kustomize/execution-layer.yaml b/kustomize/execution-layer.yaml index bbd9322..1a1e842 100644 --- a/kustomize/execution-layer.yaml +++ b/kustomize/execution-layer.yaml @@ -3,7 +3,7 @@ kind: Deployment metadata: name: execution-layer spec: - replicas: 1 + replicas: 3 selector: matchLabels: app: execution-layer