diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..b819d1c --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +nix_direnv_watch_file "./nix/env.nix" "./nix/fmt.nix" "./nix/packages.nix" "./nix/shells.nix" "./nix/pre-commit.nix" "./flake.nix" "./parse.nix" +use flake diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..253bcb7 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml new file mode 100644 index 0000000..9385c25 --- /dev/null +++ b/.github/workflows/deployment.yaml @@ -0,0 +1,31 @@ +name: CI-CD + +on: + push: + +jobs: + precommit: + name: Pre-commit Check + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - name: Run pre-commit + run: nix develop .#ci -c ./scripts/ci/pre-commit.sh + + release: + name: Semantic Release + needs: + - precommit + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - uses: rlespinasse/github-slug-action@v3.x + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: nix develop .#releaser -c scripts/ci/release.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cf95946 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.direnv +.task +.pre-commit-config.yaml +.idea +.env +dist +debug.yaml +.DS_Store \ No newline at end of file diff --git a/.gitlint b/.gitlint new file mode 100644 index 0000000..96b180f --- /dev/null +++ b/.gitlint @@ -0,0 +1,6 @@ +[general] +contrib=CT1 +ignore=B6 + +[contrib-title-conventional-commits] +types = action,chore,config,docs,feat,fix,release,upstream diff --git a/Changelog.md b/Changelog.md new file mode 100644 index 0000000..9391526 --- /dev/null +++ b/Changelog.md @@ -0,0 +1,153 @@ +## [1.8.0](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.7.1...v1.8.0) (2024-02-08) + + +### ๐Ÿš€ New Features + +* onyx cluster ([a78ff35](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/a78ff35e8bf488bf165380720dc52abb5c472554)) + + +### ๐Ÿ› Bug Fixes + +* pin npm as releaser ([bfb4bde](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/bfb4bde0104211cd4e28b6cd9509db3b23b3b988)) +* releaser ([f7dd491](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/f7dd49198aa2b2f82a59c8a32b0bf45d9951b71b)) +* semantic releaser ([2f538a8](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/2f538a8ee0ca1aa9a0dc70ae717b6c3a56a728f6)) +* upstream flakes ([3085629](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/308562906af7283a5d14e8a9ef3b089eb244895d)) +* use npm releaser ([fe128bf](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/fe128bf81b7ac0552fcec2aa5734f341e347fadb)) +* use pure nix shell for release ([87bda8a](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/87bda8a17b70a24aaf58c5460aa0a27219d600ec)) + +## [1.7.1](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.7.0...v1.7.1) (2023-11-18) + + +### ๐Ÿ› Bug Fixes + +* allow self-signed CA and cert in virtual clusters ([02fee94](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/02fee9492d4a8e74f32d716492a770ed494b9912)) + +## [1.7.0](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.6.0...v1.7.0) (2023-11-18) + + +### ๐Ÿ“ฆ Upstreams Changes + +* cert manager to 1.13.2 ([07874dc](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/07874dcae623dcf5c27b707cba127ee8afec12cb)) + + +### ๐Ÿš€ New Features + +* ruby values ([4554034](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/455403463f6854c994b92e0bed936cd2d148c9d6)) + +## [1.6.0](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.5.3...v1.6.0) (2023-10-30) + + +### ๐Ÿš€ New Features + +* remove auto-issuing from virtual to physical cluster ([0f99fb5](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/0f99fb58de1f19a6c73e79a039bfd0f11f0548da)) + +## [1.5.3](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.5.2...v1.5.3) (2023-10-29) + + +### ๐Ÿ› Bug Fixes + +* remove issuers from host cluster and move to virtual cluster ([4fdf41f](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/4fdf41f8129d492dc530dd219f588ac175f29f4a)) + +## [1.5.2](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.5.1...v1.5.2) (2023-10-25) + + +### ๐Ÿ› Bug Fixes + +* prevent sync ([3177a1a](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/3177a1a2c1f7e2c6bc0db75f01f91848e77aa7ab)) + +## [1.5.1](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.5.0...v1.5.1) (2023-10-25) + + +### ๐Ÿ› Bug Fixes + +* disable ingress shim ([ff50d90](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/ff50d90cf971138862a55d9aca0aa5e7893ed52e)) + +## [1.5.0](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.4.1...v1.5.0) (2023-10-16) + + +### ๐Ÿš€ New Features + +* values.yaml for vclusters ([2da94af](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/2da94afee8da2030cfc33ed58bfe6af9b7bdb66a)) + +## [1.4.1](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.4.0...v1.4.1) (2023-10-05) + + +### ๐Ÿ› Bug Fixes + +* remove virtual cluster values ([56ef4d1](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/56ef4d18374824b584abd7a6e7ee83dc8482de4a)) + +## [1.4.0](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.3.1...v1.4.0) (2023-10-05) + + +### ๐Ÿš€ New Features + +* pichu, pikachu and raichu values ([df07b8c](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/df07b8c1109b6e931f9ac4dd14f1efd142b0ba28)) + +## [1.3.1](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.3.0...v1.3.1) (2023-10-04) + + +### ๐Ÿ› Bug Fixes + +* entei:opal Taskfile ([1521564](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/1521564a49761a01ffcef33b46c53ea018a7c04d)) + +## [1.3.0](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.2.0...v1.3.0) (2023-10-04) + + +### ๐Ÿš€ New Features + +* **entei-opal:** migrate entei to entei opal ([5e172ba](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/5e172ba358f9e3c1515ed460146c2186403f87d6)) + +## [1.2.0](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.1.3...v1.2.0) (2023-10-03) + + +### ๐Ÿš€ New Features + +* **entei:** initial values.yaml ([e1742c1](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/e1742c194daa1a8f62cbee1f62f8ea5e4e78be6b)) + +## [1.1.3](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.1.2...v1.1.3) (2023-09-30) + + +### ๐Ÿ› Bug Fixes + +* change cluster render to cluster template ([5d0dcb7](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/5d0dcb79d774e3f0401c13adcba81c25472019c1)) + +## [1.1.2](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.1.1...v1.1.2) (2023-09-28) + + +### ๐Ÿ› Bug Fixes + +* incorrect Taskfile release name ([3c6632e](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/3c6632e481b6ae890ec18e9f5406c0d3f052caf5)) +* incorrect Taskfile release name ([a644333](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/a644333faabd2a2fcd24c08a84105525c7c04e8c)) + +## [1.1.1](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.1.0...v1.1.1) (2023-09-27) + + +### ๐Ÿ› Bug Fixes + +* chart helper using wrong chart name and missing yaml anchor ([62b5044](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/62b5044e93623e21aef5de07c181c035f2572fa2)) + +## [1.1.0](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.0.1...v1.1.0) (2023-09-27) + + +### ๐Ÿ“ฆ Upstreams Changes + +* update cert manager to 1.13.1 ([966d609](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/966d609f968b1a2c28cb8563292f0c5e7264d042)) + + +### ๐Ÿš€ New Features + +* setup example with proper documentation ([8777e43](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/8777e43aa964e69f157f1a0448496724ff7b1797)) + +## [1.0.1](https://github.com/AtomiCloud/sulfoxide.sulfur/compare/v1.0.0...v1.0.1) (2023-09-27) + + +### ๐Ÿ› Bug Fixes + +* incorrect k3d configuration ([1aaf822](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/1aaf822f38f7917f5272f6d16f049fb28591faaa)) + +## 1.0.0 (2023-09-27) + + +### ๐Ÿš€ New Features + +* initial commit ([586b5b5](https://github.com/AtomiCloud/sulfoxide.sulfur/commit/586b5b50f684be76fe184276e64b3a72b97058fd)) diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..cc5ff8d --- /dev/null +++ b/README.MD @@ -0,0 +1,18 @@ +# Sulfoxide Lead + +Helm chart to deploy EKS Bootstrap components includingg CSI (EBS and EFS) and LoadBalancer drivers + +## Prerequisites +- nix +- direnv +- docker + +## Helm Docs + +You can view the helm documentation generated at [helm-docs](./chart/README.md) + +## Contributing + +Please contact contributors and read the [developer docs](./docs/developer/CommitConventions.md) for information on contributing to this project. + +- [ernest@atomi.cloud](mailto:ernest@atomi.cloud) diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..189c440 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,50 @@ +version: "3" + +env: + RELEASE_NAME: sulfoxide-krypton + +includes: + util: tasks/Taskfile.util.yaml + entei:onyx: + taskfile: tasks/Taskfile.cluster.yaml + vars: + LANDSCAPE: entei + CLUSTER: onyx + +tasks: + # Utility + start:cluster: + desc: Starts the playground cluster to test helm charts + cmds: + - ./scripts/local/create-k3d-cluster.sh + + stop:cluster: + desc: Destroys the playground cluster to test helm charts + cmds: + - ./scripts/local/delete-k3d-cluster.sh + + # Helm Operations + update: + desc: Update Helm dependencies + dir: chart + cmds: + - helm dependency update + + latest: + desc: Get the latest version of Cert Manager + cmds: + - task: util:latest + vars: + REPO_NAME: aws-ebs-csi-driver + REPO_URL: https://kubernetes-sigs.github.io/aws-ebs-csi-driver + CHART_NAME: aws-ebs-csi-driver + - task: util:latest + vars: + REPO_NAME: aws-efs-csi-driver + REPO_URL: https://kubernetes-sigs.github.io/aws-efs-csi-driver + CHART_NAME: aws-efs-csi-driver + - task: util:latest + vars: + REPO_NAME: eks + REPO_URL: https://aws.github.io/eks-charts + CHART_NAME: aws-load-balancer-controller diff --git a/atomi_release.yaml b/atomi_release.yaml new file mode 100644 index 0000000..122b4f0 --- /dev/null +++ b/atomi_release.yaml @@ -0,0 +1,142 @@ +gitlint: .gitlint + +conventionMarkdown: + path: docs/developer/CommitConventions.md + template: | + --- + id: commit-conventions + title: Commit Conventions + --- + var___convention_docs___ +keywords: + - BREAKING CHANGE + - BREAKING CHANGES + - BREAKING + +branches: + - main + +specialScopes: + no-release: + desc: Prevent release from happening + release: false + +plugins: + - module: "@semantic-release/changelog" + config: + changelogFile: Changelog.md + - module: "@semantic-release/exec" + config: + prepareCmd: ./scripts/ci/publish.sh ${nextRelease.version} + - module: "@semantic-release/git" + config: + message: "release: ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + assets: + - chart/**/*.* + - Changelog.md + - docs/developer/CommitConventions.md + - module: "semantic-release-major-tag" + config: + customTags: + - "v${major}" + - "v${major}.${minor}" + - module: "@semantic-release/github" + +# Helm +types: + - type: upstream + desc: "Changes from dependencies upstream" + section: ๐Ÿ“ฆ Upstreams Changes + scopes: + default: + desc: Generic update from upstream dependencies + release: "minor" + vae: + verb: update upstream + application: , + example: "upstream(mysql): from v5.7 to v8.0" + + - type: config + desc: "Changes to configuration files and scripts" + scopes: + default: + desc: Updates the configuration of the repository, not related to the other scopes + release: false + lint: + desc: Add, update or remove linters + release: false + fmt: + desc: Add, updatge or remove formatters + release: false + build: + desc: Add, update or change build pipelines and generators + release: false + nix: + desc: Add, update or change nix shell + release: false + env: + desc: Add, update or change environment + release: false + ignore: + desc: Add, update or change ignore configurations + release: false + ci: + desc: Add, update or change CI configuration files + release: false + vae: + verb: configure + application: <scope> to <title> + example: "config(ci): setup nix before executing" + + - type: release + desc: Initiate a release (machine initiated) + scopes: + default: + desc: Machine initiated release + release: false + + - type: docs + section: ๐Ÿ“ Documentation Updates + desc: Documentation only changes + scopes: + default: + desc: Update generic documentation file + release: false + vae: + verb: add + application: <scope> documention <title> + example: "docs(developer): on how to install dependency packages" + - type: feat + section: ๐Ÿš€ New Features + desc: A new feature + vae: + verb: add + application: <scope> <title> + example: "feat(rapid): new withdraw api" + scopes: + default: + desc: Release a new features + release: minor + - type: action + desc: Imperative action, mainly changing the values files + scopes: + default: + desc: Imperative action, mainly changing the values files + release: false + - type: fix + section: ๐Ÿ› Bug Fixes + desc: A bug fix + vae: + verb: fix + application: <title> + example: "fix(rapid): deposit api for rapid" + scopes: + default: + desc: Generic fixes + release: patch + - type: chore + desc: Menial Tasks + scopes: + default: + desc: Menial Tasks + release: false diff --git a/chart/.helmignore b/chart/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/chart/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/chart/Chart.lock b/chart/Chart.lock new file mode 100644 index 0000000..3aa6fca --- /dev/null +++ b/chart/Chart.lock @@ -0,0 +1,12 @@ +dependencies: +- name: aws-ebs-csi-driver + repository: https://kubernetes-sigs.github.io/aws-ebs-csi-driver + version: 2.27.0 +- name: aws-efs-csi-driver + repository: https://kubernetes-sigs.github.io/aws-efs-csi-driver + version: 2.5.5 +- name: aws-load-balancer-controller + repository: https://aws.github.io/eks-charts + version: 1.7.1 +digest: sha256:3a2d1c7d55156033a97bd196571a9cb9b8ffb5d5b4b9ec40de7cdd4dc6028312 +generated: "2024-02-15T14:58:27.352153+08:00" diff --git a/chart/Chart.yaml b/chart/Chart.yaml new file mode 100644 index 0000000..4e8b344 --- /dev/null +++ b/chart/Chart.yaml @@ -0,0 +1,21 @@ +apiVersion: v2 +name: sulfoxide-lead +description: Helm chart to deploy EKS Bootstrap components includingg CSI (EBS and EFS) and LoadBalancer drivers +type: application +version: 1.0.0 +appVersion: "0.1.0" +dependencies: + - name: aws-ebs-csi-driver + repository: https://kubernetes-sigs.github.io/aws-ebs-csi-driver + version: 2.27.0 + condition: aws-ebs-csi-driver.enabled + - name: aws-efs-csi-driver + repository: https://kubernetes-sigs.github.io/aws-efs-csi-driver + version: 2.5.5 + condition: aws-efs-csi-driver.enabled + - name: aws-load-balancer-controller + repository: https://aws.github.io/eks-charts + version: 1.7.1 + condition: aws-load-balancer-controller.enabled + + diff --git a/chart/README.md b/chart/README.md new file mode 100644 index 0000000..c4ff7ee --- /dev/null +++ b/chart/README.md @@ -0,0 +1,29 @@ +# sulfoxide-lead + +![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square) + +Helm chart to deploy EKS Bootstrap components includingg CSI (EBS and EFS) and LoadBalancer drivers + +## Requirements + +| Repository | Name | Version | +|------------|------|---------| +| https://aws.github.io/eks-charts | aws-load-balancer-controller | 1.7.1 | +| https://kubernetes-sigs.github.io/aws-ebs-csi-driver | aws-ebs-csi-driver | 2.27.0 | +| https://kubernetes-sigs.github.io/aws-efs-csi-driver | aws-efs-csi-driver | 2.5.5 | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| aws-ebs-csi-driver | object | `{"controller":{"extraVolumeTags":{"<<":{"atomi.cloud/layer":"1","atomi.cloud/platform":"sulfoxide","atomi.cloud/service":"lead"},"atomi.cloud/module":"ebs-controller"},"loggingFormat":"json","podAnnotations":{"<<":{"atomi.cloud/layer":"1","atomi.cloud/platform":"sulfoxide","atomi.cloud/service":"lead"},"atomi.cloud/module":"ebs-controller"},"podLabels":{"<<":{"atomi.cloud/layer":"1","atomi.cloud/platform":"sulfoxide","atomi.cloud/service":"lead"},"atomi.cloud/module":"ebs-controller"},"replicaCount":2,"resources":{"limits":{"cpu":"250m","memory":"512Mi"},"requests":{"cpu":"128m","memory":"256Mi"}},"serviceAccount":{"annotations":{"eks.amazonaws.com/role-arn":"role"},"create":true,"name":"ebs-controller"},"topologySpreadConstraints":[{"labelSelector":null,"matchLabels":{"<<":{"atomi.cloud/layer":"1","atomi.cloud/platform":"sulfoxide","atomi.cloud/service":"lead"}},"maxSkew":1,"topologyKey":"topology.kubernetes.io/zone","whenUnsatisfiable":"ScheduleAnyway"}]},"customLabels":{"<<":{"atomi.cloud/layer":"1","atomi.cloud/platform":"sulfoxide","atomi.cloud/service":"lead"},"atomi.cloud/module":"ebs-controller"},"storageClasses":[]}` | AWS EBS CSI Driver configuration. See [AWS EBS CSI Driver Helm Chart](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/install.md) | +| aws-efs-csi-driver | object | `{"controller":{"create":true,"podAnnotations":{"<<":{"atomi.cloud/layer":"1","atomi.cloud/platform":"sulfoxide","atomi.cloud/service":"lead"},"atomi.cloud/module":"efs-controller"},"resources":{"limits":{"cpu":"250m","memory":"512Mi"},"requests":{"cpu":"128m","memory":"256Mi"}},"serviceAccount":{"annotations":{"eks.amazonaws.com/role-arn":"role"},"create":true,"name":"efs-controller"}},"replicaCount":2,"storageClasses":[]}` | AWS EFS CSI Driver configuration. See [AWS EFS CSI Driver Helm Chart](https://github.com/kubernetes-sigs/aws-efs-csi-driver/tree/master) | +| aws-load-balancer-controller | object | `{"additionalLabels":{"<<":{"atomi.cloud/layer":"1","atomi.cloud/platform":"sulfoxide","atomi.cloud/service":"lead"},"atomi.cloud/module":"elb-controller"},"clusterName":"name","podAnnotations":{"<<":{"atomi.cloud/layer":"1","atomi.cloud/platform":"sulfoxide","atomi.cloud/service":"lead"},"atomi.cloud/module":"elb-controller"},"podLabels":{"<<":{"atomi.cloud/layer":"1","atomi.cloud/platform":"sulfoxide","atomi.cloud/service":"lead"},"atomi.cloud/module":"elb-controller"},"replicaCount":2,"resources":{"limits":{"cpu":"250m","memory":"512Mi"},"requests":{"cpu":"62.5m","memory":"128Mi"}},"serviceAccount":{"annotations":{"eks.amazonaws.com/role-arn":"role"},"create":true,"name":"elb-controller"},"serviceMonitor":{"enabled":true},"topologySpreadConstraints":[{"labelSelector":{"matchLabels":{"<<":{"atomi.cloud/layer":"1","atomi.cloud/platform":"sulfoxide","atomi.cloud/service":"lead"}}},"maxSkew":1,"topologyKey":"topology.kubernetes.io/zone","whenUnsatisfiable":"ScheduleAnyway"}]}` | AWS LoadBalancer Controller configuration. See [AWS LoadBalancer Controller Helm Chart](https://github.com/aws/eks-charts/tree/master/stable/aws-load-balancer-controller) | +| clusterName | string | `"name"` | Cluster name for the EKS cluster | +| modules | object | `{"ebs":"ebs-controller","efs":"efs-controller","elb":"elb-controller"}` | Module labels and annotations, following Service Tree for each EKS plugin | +| role | string | `"role"` | Role ARN for IRSA for service account | +| serviceTree | object | `{"layer":"1","platform":"sulfoxide","service":"lead"}` | AtomiCloud Service Tree. See [ServiceTree](https://atomicloud.larksuite.com/wiki/OkfJwTXGFiMJkrk6W3RuwRrZs64?theme=DARK&contentTheme=DARK#MHw5d76uDo2tBLx86cduFQMRsBb) | +| tags | object | `{"atomi.cloud/layer":"1","atomi.cloud/platform":"sulfoxide","atomi.cloud/service":"lead"}` | Kubernetes labels and annotations, following Service Tree | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.11.1](https://github.com/norwoodj/helm-docs/releases/v1.11.1) \ No newline at end of file diff --git a/chart/charts/aws-ebs-csi-driver-2.27.0.tgz b/chart/charts/aws-ebs-csi-driver-2.27.0.tgz new file mode 100644 index 0000000..30e17a6 Binary files /dev/null and b/chart/charts/aws-ebs-csi-driver-2.27.0.tgz differ diff --git a/chart/charts/aws-efs-csi-driver-2.5.5.tgz b/chart/charts/aws-efs-csi-driver-2.5.5.tgz new file mode 100644 index 0000000..3b09e9a Binary files /dev/null and b/chart/charts/aws-efs-csi-driver-2.5.5.tgz differ diff --git a/chart/charts/aws-load-balancer-controller-1.7.1.tgz b/chart/charts/aws-load-balancer-controller-1.7.1.tgz new file mode 100644 index 0000000..d796146 Binary files /dev/null and b/chart/charts/aws-load-balancer-controller-1.7.1.tgz differ diff --git a/chart/templates/NOTES.txt b/chart/templates/NOTES.txt new file mode 100644 index 0000000..43b1752 --- /dev/null +++ b/chart/templates/NOTES.txt @@ -0,0 +1 @@ +EKS bootstrap completed diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl new file mode 100644 index 0000000..41cbf90 --- /dev/null +++ b/chart/templates/_helpers.tpl @@ -0,0 +1,75 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "sulfoxide-lead.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "sulfoxide-lead.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "sulfoxide-lead.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "sulfoxide-lead.labels" -}} +helm.sh/chart: {{ include "sulfoxide-lead.chart" . }} +{{- range $k, $v := .Values.serviceTree }} +"atomi.cloud/{{ $k }}": "{{ $v }}" +{{- end }} +{{ include "sulfoxide-lead.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Common annotations +*/}} +{{- define "sulfoxide-lead.annotations" -}} +helm.sh/chart: {{ include "sulfoxide-lead.chart" . }} +{{- range $k, $v := .Values.serviceTree }} +"atomi.cloud/{{ $k }}": "{{ $v }}" +{{- end }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "sulfoxide-lead.selectorLabels" -}} +app.kubernetes.io/name: {{ include "sulfoxide-lead.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "sulfoxide-lead.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "sulfoxide-lead.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/chart/values.entei.onyx.yaml b/chart/values.entei.onyx.yaml new file mode 100644 index 0000000..d7361f2 --- /dev/null +++ b/chart/values.entei.onyx.yaml @@ -0,0 +1,74 @@ +serviceTree: + landscape: &landscape entei + cluster: &cluster onyx + +tags: &tags + atomi.cloud/landscape: *landscape + atomi.cloud/cluster: *cluster + +clusterName: &clusterName entei-onyx + +role: &role "arn:aws:iam::767398020544:role/entei-onyx-irsa-2024021506251630470000001f" + + +aws-ebs-csi-driver: + enabled: true + customLabels: + <<: *tags + storageClasses: + - name: ebs + annotations: + storageclass.kubernetes.io/is-default-class: true + labels: + <<: *tags + tr8.io/layer: "1" + + volumeBindingMode: WaitForFirstConsumer + reclaimPolicy: Retain + + parameters: {} + controller: + replicaCount: 2 + podLabels: + <<: *tags + podAnnotations: + <<: *tags + serviceAccount: + annotations: + eks.amazonaws.com/role-arn: *role + extraVolumeTags: + <<: *tags + +aws-efs-csi-driver: + enabled: false + storageClasses: + - name: efs + labels: + <<: *tags + tr8.io/layer: "1" + volumeBindingMode: WaitForFirstConsumer + reclaimPolicy: Retain + parameters: + + replicaCount: 2 + controller: + serviceAccount: + annotations: + eks.amazonaws.com/role-arn: *role + create: true + podAnnotations: + <<: *tags + +aws-load-balancer-controller: + enabled: true + clusterName: *clusterName + replicaCount: 2 + serviceAccount: + annotations: + eks.amazonaws.com/role-arn: *role + additionalLabels: + <<: *tags + podLabels: + <<: *tags + podAnnotations: + <<: *tags diff --git a/chart/values.example.yaml b/chart/values.example.yaml new file mode 100644 index 0000000..aeae6cc --- /dev/null +++ b/chart/values.example.yaml @@ -0,0 +1,54 @@ +serviceTree: + landscape: &landscape entei + cluster: &cluster opal + +tags: &tags + atomi.cloud/landscape: *landscape + atomi.cloud/cluster: *cluster + +clusterName: &clusterName name + +role: &role "role" + + +aws-ebs-csi-driver: + customLabels: + <<: *tags + storageClasses: [] + controller: + replicaCount: 2 + podLabels: + <<: *tags + podAnnotations: + <<: *tags + serviceAccount: + create: true + annotations: + eks.amazonaws.com/role-arn: *role + extraVolumeTags: + <<: *tags + +aws-efs-csi-driver: + storageClasses: [] + replicaCount: 2 + controller: + serviceAccount: + create: true + annotations: + eks.amazonaws.com/role-arn: *role + create: true + podAnnotations: + <<: *tags + +aws-load-balancer-controller: + clusterName: *clusterName + serviceAccount: + create: true + annotations: + eks.amazonaws.com/role-arn: *role + additionalLabels: + <<: *tags + podLabels: + <<: *tags + podAnnotations: + <<: *tags diff --git a/chart/values.yaml b/chart/values.yaml new file mode 100644 index 0000000..464f3e4 --- /dev/null +++ b/chart/values.yaml @@ -0,0 +1,120 @@ +# -- AtomiCloud Service Tree. See [ServiceTree](https://atomicloud.larksuite.com/wiki/OkfJwTXGFiMJkrk6W3RuwRrZs64?theme=DARK&contentTheme=DARK#MHw5d76uDo2tBLx86cduFQMRsBb) +serviceTree: + platform: &platform sulfoxide + service: &service lead + layer: &layer "1" + +# -- Kubernetes labels and annotations, following Service Tree +tags: &tags + atomi.cloud/platform: *platform + atomi.cloud/service: *service + atomi.cloud/layer: *layer + +# -- Cluster name for the EKS cluster +clusterName: &clusterName name + +# -- Role ARN for IRSA for service account +role: &role "role" + +# -- Module labels and annotations, following Service Tree for each EKS plugin +modules: + ebs: &ebs ebs-controller + efs: &efs efs-controller + elb: &elb elb-controller + + + +# -- AWS EBS CSI Driver configuration. See [AWS EBS CSI Driver Helm Chart](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/docs/install.md) +aws-ebs-csi-driver: + customLabels: + <<: *tags + atomi.cloud/module: *ebs + storageClasses: [] + controller: + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: "topology.kubernetes.io/zone" + whenUnsatisfiable: ScheduleAnyway + labelSelector: + matchLabels: + <<: *tags + replicaCount: 2 + podLabels: + <<: *tags + atomi.cloud/module: *ebs + podAnnotations: + <<: *tags + atomi.cloud/module: *ebs + loggingFormat: json + serviceAccount: + create: true + name: *ebs + annotations: + eks.amazonaws.com/role-arn: *role + extraVolumeTags: + <<: *tags + atomi.cloud/module: *ebs + resources: + requests: + cpu: 128m + memory: 256Mi + limits: + cpu: 250m + memory: 512Mi + +# -- AWS EFS CSI Driver configuration. See [AWS EFS CSI Driver Helm Chart](https://github.com/kubernetes-sigs/aws-efs-csi-driver/tree/master) +aws-efs-csi-driver: + storageClasses: [] + replicaCount: 2 + controller: + resources: + requests: + cpu: 128m + memory: 256Mi + limits: + cpu: 250m + memory: 512Mi + serviceAccount: + create: true + name: *efs + annotations: + eks.amazonaws.com/role-arn: *role + create: true + podAnnotations: + <<: *tags + atomi.cloud/module: *efs + +# -- AWS LoadBalancer Controller configuration. See [AWS LoadBalancer Controller Helm Chart](https://github.com/aws/eks-charts/tree/master/stable/aws-load-balancer-controller) +aws-load-balancer-controller: + clusterName: *clusterName + serviceMonitor: + enabled: true + replicaCount: 2 + resources: + requests: + cpu: 62.5m + memory: 128Mi + limits: + cpu: 250m + memory: 512Mi + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: "topology.kubernetes.io/zone" + whenUnsatisfiable: ScheduleAnyway + labelSelector: + matchLabels: + <<: *tags + serviceAccount: + create: true + name: *elb + annotations: + eks.amazonaws.com/role-arn: *role + additionalLabels: + <<: *tags + atomi.cloud/module: *elb + podLabels: + <<: *tags + atomi.cloud/module: *elb + podAnnotations: + <<: *tags + atomi.cloud/module: *elb diff --git a/config/dev.yaml b/config/dev.yaml new file mode 100644 index 0000000..235b44d --- /dev/null +++ b/config/dev.yaml @@ -0,0 +1,3 @@ +landscape: lapras +platform: sulfoxide +service: app-of-apps diff --git a/docs/developer/.gitkeep b/docs/developer/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/developer/CommitConventions.md b/docs/developer/CommitConventions.md new file mode 100644 index 0000000..f6c038a --- /dev/null +++ b/docs/developer/CommitConventions.md @@ -0,0 +1,141 @@ +--- +id: commit-conventions +title: Commit Conventions +--- +This project uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) loosely as the specification +for our commits. + +Commit message will be in the format: + +``` +type(scope): title + +body +``` + +This page will document the types and scopes used. + +# Types + +| Type | Description | +| --------------------- | --------------------------------------------------- | +| [upstream](#upstream) | Changes from dependencies upstream | +| [config](#config) | Changes to configuration files and scripts | +| [release](#release) | Initiate a release (machine initiated) | +| [docs](#docs) | Documentation only changes | +| [feat](#feat) | A new feature | +| [action](#action) | Imperative action, mainly changing the values files | +| [fix](#fix) | A bug fix | +| [chore](#chore) | Menial Tasks | + +## upstream + +Changes from dependencies upstream + +| **V.A.E** | V.A.E values | +| --------------- | ------------------------------------------------------------------------------------- | +| verb | update upstream | +| application | when this commit is applied, it will _update upstream_ `<scope>, <title>` | +| example | upstream(mysql): from v5.7 to v8.0 | +| example applied | when this commit is applied, it will _update upstream_ `mysql`, **from v5.7 to v8.0** | + +| Scope | Description | Bump | +| ------- | ----------------------------------------- | ------- | +| default | Generic update from upstream dependencies | `minor` | + +## config + +Changes to configuration files and scripts + +| **V.A.E** | V.A.E values | +| --------------- | --------------------------------------------------------------------------------------- | +| verb | configure | +| application | when this commit is applied, it will _configure_ `<scope> to <title>` | +| example | config(ci): setup nix before executing | +| example applied | when this commit is applied, it will _configure_ `ci` to **setup nix before executing** | + +| Scope | Description | Bump | +| -------- | ---------------------------------------------------------------------------- | ----- | +| default | Updates the configuration of the repository, not related to the other scopes | `nil` | +| `lint` | Add, update or remove linters | `nil` | +| `fmt` | Add, updatge or remove formatters | `nil` | +| `build` | Add, update or change build pipelines and generators | `nil` | +| `nix` | Add, update or change nix shell | `nil` | +| `env` | Add, update or change environment | `nil` | +| `ignore` | Add, update or change ignore configurations | `nil` | +| `ci` | Add, update or change CI configuration files | `nil` | + +## release + +Initiate a release (machine initiated) + +| Scope | Description | Bump | +| ------- | ------------------------- | ----- | +| default | Machine initiated release | `nil` | + +## docs + +Documentation only changes + +| **V.A.E** | V.A.E values | +| --------------- | ------------------------------------------------------------------------------------------------------------ | +| verb | add | +| application | when this commit is applied, it will _add_ `<scope> documention <title>` | +| example | docs(developer): on how to install dependency packages | +| example applied | when this commit is applied, it will _add_ `developer` documention **on how to install dependency packages** | + +| Scope | Description | Bump | +| ------- | --------------------------------- | ----- | +| default | Update generic documentation file | `nil` | + +## feat + +A new feature + +| **V.A.E** | V.A.E values | +| --------------- | ----------------------------------------------------------------------- | +| verb | add | +| application | when this commit is applied, it will _add_ `<scope> <title>` | +| example | feat(rapid): new withdraw api | +| example applied | when this commit is applied, it will _add_ `rapid` **new withdraw api** | + +| Scope | Description | Bump | +| ------- | ---------------------- | ------- | +| default | Release a new features | `minor` | + +## action + +Imperative action, mainly changing the values files + +| Scope | Description | Bump | +| ------- | --------------------------------------------------- | ----- | +| default | Imperative action, mainly changing the values files | `nil` | + +## fix + +A bug fix + +| **V.A.E** | V.A.E values | +| --------------- | -------------------------------------------------------------------- | +| verb | fix | +| application | when this commit is applied, it will _fix_ `<title>` | +| example | fix(rapid): deposit api for rapid | +| example applied | when this commit is applied, it will _fix_ **deposit api for rapid** | + +| Scope | Description | Bump | +| ------- | ------------- | ------- | +| default | Generic fixes | `patch` | + +## chore + +Menial Tasks + +| Scope | Description | Bump | +| ------- | ------------ | ----- | +| default | Menial Tasks | `nil` | + +# Special Scopes + +| Scope | Description | Bump | +| ------------ | ------------------------------ | ----- | +| `no-release` | Prevent release from happening | `nil` | diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..bb11881 --- /dev/null +++ b/flake.lock @@ -0,0 +1,816 @@ +{ + "nodes": { + "atomipkgs": { + "inputs": { + "dev-atomi": "dev-atomi", + "dev-atomi_classic": "dev-atomi_classic_2", + "dev-npkgs": "dev-npkgs_2", + "dev-npkgs-unstable-05-Oct-2022": "dev-npkgs-unstable-05-Oct-2022_2", + "dev-npkgs-unstable-07-Feb-2024": "dev-npkgs-unstable-07-Feb-2024_2", + "dev-npkgs-unstable-11-Dec-2022": "dev-npkgs-unstable-11-Dec-2022_2", + "fenix": "fenix_2", + "flake-utils": "flake-utils_4", + "npkgs": "npkgs_2", + "npkgs-unstable": "npkgs-unstable_2" + }, + "locked": { + "lastModified": 1707362469, + "narHash": "sha256-rRk9DPJv0xdQrraAbYtP1yivcH5Mz4HhheWKroj/HTc=", + "owner": "kirinnee", + "repo": "test-nix-repo", + "rev": "6ff86a09a767d3e0d20994213e43de507c8a8c37", + "type": "github" + }, + "original": { + "owner": "kirinnee", + "ref": "v23.0.1", + "repo": "test-nix-repo", + "type": "github" + } + }, + "dev-atomi": { + "inputs": { + "dev-atomi_classic": "dev-atomi_classic", + "dev-npkgs": "dev-npkgs", + "dev-npkgs-unstable-05-Oct-2022": "dev-npkgs-unstable-05-Oct-2022", + "dev-npkgs-unstable-07-Feb-2024": "dev-npkgs-unstable-07-Feb-2024", + "dev-npkgs-unstable-11-Dec-2022": "dev-npkgs-unstable-11-Dec-2022", + "fenix": "fenix", + "flake-utils": "flake-utils_2", + "npkgs": "npkgs", + "npkgs-unstable": "npkgs-unstable" + }, + "locked": { + "lastModified": 1707319132, + "narHash": "sha256-L5ekxE6MeA7URMF9M4Gdal5a5fSKAzCGyXGSepI8ozA=", + "owner": "kirinnee", + "repo": "test-nix-repo", + "rev": "099b7e7850d00d0e376aade2b9ad62683e6440a5", + "type": "github" + }, + "original": { + "owner": "kirinnee", + "ref": "v23.0.0", + "repo": "test-nix-repo", + "type": "github" + } + }, + "dev-atomi_classic": { + "inputs": { + "flake-utils": "flake-utils", + "pkgs": "pkgs", + "pkgs_25_Jul_2021": "pkgs_25_Jul_2021" + }, + "locked": { + "lastModified": 1689236000, + "narHash": "sha256-MEqyIPlD4ueJji6FtfDs8qqZifM9hyYH1svBs3oxrrc=", + "owner": "kirinnee", + "repo": "test-nix-repo", + "rev": "2d9d80544d2e81ff736fa23345ad0a9cc5a6c8ab", + "type": "github" + }, + "original": { + "owner": "kirinnee", + "ref": "classic", + "repo": "test-nix-repo", + "type": "github" + } + }, + "dev-atomi_classic_2": { + "inputs": { + "flake-utils": "flake-utils_3", + "pkgs": "pkgs_2", + "pkgs_25_Jul_2021": "pkgs_25_Jul_2021_2" + }, + "locked": { + "lastModified": 1689236000, + "narHash": "sha256-MEqyIPlD4ueJji6FtfDs8qqZifM9hyYH1svBs3oxrrc=", + "owner": "kirinnee", + "repo": "test-nix-repo", + "rev": "2d9d80544d2e81ff736fa23345ad0a9cc5a6c8ab", + "type": "github" + }, + "original": { + "owner": "kirinnee", + "ref": "classic", + "repo": "test-nix-repo", + "type": "github" + } + }, + "dev-npkgs": { + "locked": { + "lastModified": 1704290814, + "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "dev-npkgs-unstable-05-Oct-2022": { + "locked": { + "lastModified": 1664847737, + "narHash": "sha256-Wxl0CtRH3Vo8+qEZ/PbCcx+9D8wEEi56tJPmROum2ss=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "de80d1d04ee691279e1302a1128c082bbda3ab01", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "de80d1d04ee691279e1302a1128c082bbda3ab01", + "type": "indirect" + } + }, + "dev-npkgs-unstable-05-Oct-2022_2": { + "locked": { + "lastModified": 1664847737, + "narHash": "sha256-Wxl0CtRH3Vo8+qEZ/PbCcx+9D8wEEi56tJPmROum2ss=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "de80d1d04ee691279e1302a1128c082bbda3ab01", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "de80d1d04ee691279e1302a1128c082bbda3ab01", + "type": "indirect" + } + }, + "dev-npkgs-unstable-07-Feb-2024": { + "locked": { + "lastModified": 1707092692, + "narHash": "sha256-ZbHsm+mGk/izkWtT4xwwqz38fdlwu7nUUKXTOmm4SyE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "faf912b086576fd1a15fca610166c98d47bc667e", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "faf912b086576fd1a15fca610166c98d47bc667e", + "type": "indirect" + } + }, + "dev-npkgs-unstable-07-Feb-2024_2": { + "locked": { + "lastModified": 1707092692, + "narHash": "sha256-ZbHsm+mGk/izkWtT4xwwqz38fdlwu7nUUKXTOmm4SyE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "faf912b086576fd1a15fca610166c98d47bc667e", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "faf912b086576fd1a15fca610166c98d47bc667e", + "type": "indirect" + } + }, + "dev-npkgs-unstable-11-Dec-2022": { + "locked": { + "lastModified": 1670681895, + "narHash": "sha256-kZH9DSU36W4fn1z81a/24JCGkU517TcY50VE0RFJ9k4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f82f0ec1b70b2879c3f3d9a1015a05c73a90a17c", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "f82f0ec1b70b2879c3f3d9a1015a05c73a90a17c", + "type": "indirect" + } + }, + "dev-npkgs-unstable-11-Dec-2022_2": { + "locked": { + "lastModified": 1670681895, + "narHash": "sha256-kZH9DSU36W4fn1z81a/24JCGkU517TcY50VE0RFJ9k4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f82f0ec1b70b2879c3f3d9a1015a05c73a90a17c", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "f82f0ec1b70b2879c3f3d9a1015a05c73a90a17c", + "type": "indirect" + } + }, + "dev-npkgs_2": { + "locked": { + "lastModified": 1704290814, + "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1706941198, + "narHash": "sha256-t6/qloMYdknVJ9a3QzjylQIZnQfgefJ5kMim50B7dwA=", + "owner": "nix-community", + "repo": "fenix", + "rev": "28dbd8b43ea328ee708f7da538c63e03d5ed93c8", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "fenix_2": { + "inputs": { + "nixpkgs": "nixpkgs_2", + "rust-analyzer-src": "rust-analyzer-src_2" + }, + "locked": { + "lastModified": 1706941198, + "narHash": "sha256-t6/qloMYdknVJ9a3QzjylQIZnQfgefJ5kMim50B7dwA=", + "owner": "nix-community", + "repo": "fenix", + "rev": "28dbd8b43ea328ee708f7da538c63e03d5ed93c8", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_4": { + "inputs": { + "systems": "systems_4" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_5": { + "inputs": { + "systems": "systems_5" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_6": { + "inputs": { + "systems": "systems_6" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703887061, + "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1706732774, + "narHash": "sha256-hqJlyJk4MRpcItGYMF+3uHe8HvxNETWvlGtLuVpqLU0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b8b232ae7b8b144397fdb12d20f592e5e7c1a64d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-sep-24-23": { + "locked": { + "lastModified": 1695360818, + "narHash": "sha256-JlkN3R/SSoMTa+CasbxS1gq+GpGxXQlNZRUh9+LIy/0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e35dcc04a3853da485a396bdd332217d0ac9054f", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "e35dcc04a3853da485a396bdd332217d0ac9054f", + "type": "indirect" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1704874635, + "narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1706732774, + "narHash": "sha256-hqJlyJk4MRpcItGYMF+3uHe8HvxNETWvlGtLuVpqLU0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b8b232ae7b8b144397fdb12d20f592e5e7c1a64d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1695360818, + "narHash": "sha256-JlkN3R/SSoMTa+CasbxS1gq+GpGxXQlNZRUh9+LIy/0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e35dcc04a3853da485a396bdd332217d0ac9054f", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "e35dcc04a3853da485a396bdd332217d0ac9054f", + "type": "indirect" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1704842529, + "narHash": "sha256-OTeQA+F8d/Evad33JMfuXC89VMetQbsU4qcaePchGr4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "eabe8d3eface69f5bb16c18f8662a702f50c20d5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1705856552, + "narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "612f97239e2cc474c13c9dafa0df378058c5ad8d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "npkgs": { + "locked": { + "lastModified": 1704290814, + "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "npkgs-unstable": { + "locked": { + "lastModified": 1707092692, + "narHash": "sha256-ZbHsm+mGk/izkWtT4xwwqz38fdlwu7nUUKXTOmm4SyE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "faf912b086576fd1a15fca610166c98d47bc667e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "npkgs-unstable_2": { + "locked": { + "lastModified": 1707092692, + "narHash": "sha256-ZbHsm+mGk/izkWtT4xwwqz38fdlwu7nUUKXTOmm4SyE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "faf912b086576fd1a15fca610166c98d47bc667e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "npkgs_2": { + "locked": { + "lastModified": 1704290814, + "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pkgs": { + "locked": { + "lastModified": 1643805626, + "narHash": "sha256-AXLDVMG+UaAGsGSpOtQHPIKB+IZ0KSd9WS77aanGzgc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "554d2d8aa25b6e583575459c297ec23750adb6cb", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "554d2d8aa25b6e583575459c297ec23750adb6cb", + "type": "indirect" + } + }, + "pkgs_2": { + "locked": { + "lastModified": 1643805626, + "narHash": "sha256-AXLDVMG+UaAGsGSpOtQHPIKB+IZ0KSd9WS77aanGzgc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "554d2d8aa25b6e583575459c297ec23750adb6cb", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "554d2d8aa25b6e583575459c297ec23750adb6cb", + "type": "indirect" + } + }, + "pkgs_25_Jul_2021": { + "locked": { + "lastModified": 1627107260, + "narHash": "sha256-CwvSwz3kvpp7uEFyOj2Dq6bdtY6P2N0Bzd7ZVgsIICw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "537678cb1ead06fca831077c3b193566cbc3f406", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "537678cb1ead06fca831077c3b193566cbc3f406", + "type": "indirect" + } + }, + "pkgs_25_Jul_2021_2": { + "locked": { + "lastModified": 1627107260, + "narHash": "sha256-CwvSwz3kvpp7uEFyOj2Dq6bdtY6P2N0Bzd7ZVgsIICw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "537678cb1ead06fca831077c3b193566cbc3f406", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "537678cb1ead06fca831077c3b193566cbc3f406", + "type": "indirect" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_6", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs_4", + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1707297608, + "narHash": "sha256-ADjo/5VySGlvtCW3qR+vdFF4xM9kJFlRDqcC9ZGI8EA=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "0db2e67ee49910adfa13010e7f012149660af7f0", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "atomipkgs": "atomipkgs", + "flake-utils": "flake-utils_5", + "nixpkgs": "nixpkgs_3", + "nixpkgs-sep-24-23": "nixpkgs-sep-24-23", + "pre-commit-hooks": "pre-commit-hooks", + "treefmt-nix": "treefmt-nix" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1706875368, + "narHash": "sha256-KOBXxNurIU2lEmO6lR2A5El32X9x8ITt25McxKZ/Ew0=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "8f6a72871ec87ed53cfe43a09fb284168a284e7e", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "rust-analyzer-src_2": { + "flake": false, + "locked": { + "lastModified": 1706875368, + "narHash": "sha256-KOBXxNurIU2lEmO6lR2A5El32X9x8ITt25McxKZ/Ew0=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "8f6a72871ec87ed53cfe43a09fb284168a284e7e", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_5": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_6": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1707300477, + "narHash": "sha256-qQF0fEkHlnxHcrKIMRzOETnRBksUK048MXkX0SOmxvA=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "ac599dab59a66304eb511af07b3883114f061b9d", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7276f00 --- /dev/null +++ b/flake.nix @@ -0,0 +1,66 @@ +{ + inputs = { + # util + flake-utils.url = "github:numtide/flake-utils"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; + + # registry + nixpkgs.url = "nixpkgs/e35dcc04a3853da485a396bdd332217d0ac9054f"; + nixpkgs-sep-24-23.url = "nixpkgs/e35dcc04a3853da485a396bdd332217d0ac9054f"; + atomipkgs.url = "github:kirinnee/test-nix-repo/v23.0.1"; + }; + outputs = + { self + + # utils + , flake-utils + , treefmt-nix + , pre-commit-hooks + + # registries + , atomipkgs + , nixpkgs + , nixpkgs-sep-24-23 + + } @inputs: + (flake-utils.lib.eachDefaultSystem + ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + pkgs-sep-24-23 = nixpkgs-sep-24-23.legacyPackages.${system}; + atomi = atomipkgs.packages.${system}; + pre-commit-lib = pre-commit-hooks.lib.${system}; + in + with rec { + pre-commit = import ./nix/pre-commit.nix { + inherit packages pre-commit-lib formatter; + }; + formatter = import ./nix/fmt.nix { + inherit treefmt-nix pkgs; + }; + packages = import ./nix/packages.nix + { + inherit pkgs pkgs-sep-24-23 atomi; + }; + env = import ./nix/env.nix { + inherit pkgs packages; + }; + devShells = import ./nix/shells.nix { + inherit pkgs env packages; + shellHook = checks.pre-commit-check.shellHook; + }; + checks = { + pre-commit-check = pre-commit; + format = formatter; + }; + }; + { + inherit checks formatter packages devShells; + } + ) + ) + ; + +} diff --git a/infra/k3d.lapras.yaml b/infra/k3d.lapras.yaml new file mode 100644 index 0000000..84f1ca5 --- /dev/null +++ b/infra/k3d.lapras.yaml @@ -0,0 +1,20 @@ +apiVersion: k3d.io/v1alpha4 +kind: Simple +metadata: + name: lapras +servers: 1 +agents: 0 +network: lapras +image: rancher/k3s:v1.25.12-k3s1 +ports: + - port: 20010:80 + nodeFilters: + - loadbalancer + - port: 20011:443 + nodeFilters: + - loadbalancer +registries: + create: + name: lapras.registry.lvh.me + host: "0.0.0.0" + hostPort: "20012" diff --git a/nix/env.nix b/nix/env.nix new file mode 100644 index 0000000..e85f35e --- /dev/null +++ b/nix/env.nix @@ -0,0 +1,41 @@ +{ pkgs, packages }: +with packages; +{ + system = [ + coreutils + sd + bash + jq + yq-go + ]; + + dev = [ + pls + git + skopeo + ]; + + infra = [ + k3d + helm + kubectl + ]; + + main = [ + ]; + + lint = [ + # core + treefmt + + helm-docs + + gitlint + shellcheck + ]; + + releaser = [ + git + sg + ]; +} diff --git a/nix/fmt.nix b/nix/fmt.nix new file mode 100644 index 0000000..66809f9 --- /dev/null +++ b/nix/fmt.nix @@ -0,0 +1,24 @@ +{ treefmt-nix, pkgs, ... }: +let + fmt = { + projectRootFile = "flake.nix"; + + # enable or disable formatters, see https://github.com/numtide/treefmt-nix#supported-programs + programs = { + nixpkgs-fmt = { + enable = true; + }; + prettier = { + enable = true; + }; + shfmt = { + enable = true; + }; + }; + + + }; +in +(treefmt-nix.lib.evalModule pkgs fmt).config.build.wrapper + + diff --git a/nix/packages.nix b/nix/packages.nix new file mode 100644 index 0000000..7cb5a4a --- /dev/null +++ b/nix/packages.nix @@ -0,0 +1,44 @@ +{ pkgs, atomi, pkgs-sep-24-23 }: +let + + all = { + atomipkgs = ( + with atomi; + { + inherit + infisical + pls + sg; + } + ); + sep-24-23 = ( + with pkgs-sep-24-23; + { + inherit + coreutils + sd + bash + git + jq + yq-go + skopeo + + # lint + treefmt + + # infra + k3d + helm-docs + kubectl + gitlint + shellcheck + ; + helm = kubernetes-helm; + + } + ); + }; +in +with all; +atomipkgs // +sep-24-23 diff --git a/nix/pre-commit.nix b/nix/pre-commit.nix new file mode 100644 index 0000000..f2373ad --- /dev/null +++ b/nix/pre-commit.nix @@ -0,0 +1,98 @@ +{ packages, formatter, pre-commit-lib }: +pre-commit-lib.run { + src = ./.; + + # hooks + hooks = { + # formatter + treefmt = { + enable = true; + excludes = [ "chart/.*(yaml|yml)" "chart/README.md" "Changelog.md" "docs/developer/CommitConventions.md" ]; + }; + + # linters From https://github.com/cachix/pre-commit-hooks.nix + shellcheck = { + enable = false; + }; + + a-infisical = { + enable = true; + name = "Secrets Scanning (Past Commits)"; + description = "Scan for possible secrets in past commits"; + entry = "${packages.infisical}/bin/infisical scan . -v"; + language = "system"; + pass_filenames = false; + }; + + a-infisical-staged = { + enable = true; + name = "Secrets Scanning (Staged)"; + description = "Scan for possible secrets in staged files"; + entry = "${packages.infisical}/bin/infisical scan git-changes --staged -v"; + language = "system"; + pass_filenames = false; + }; + + a-helm-lint = { + enable = true; + name = "Helm Lint"; + description = "Lints helm"; + entry = "${packages.helm}/bin/helm lint -f chart/values.yaml chart"; + files = "chart/.*"; + language = "system"; + pass_filenames = false; + }; + + a-gitlint = { + enable = true; + name = "Gitlint"; + description = "Lints git commit message"; + entry = "${packages.gitlint}/bin/gitlint --staged --msg-filename .git/COMMIT_EDITMSG"; + language = "system"; + pass_filenames = false; + stages = [ "commit-msg" ]; + }; + + a-enforce-gitlint = { + enable = true; + name = "Enforce gitlint"; + description = "Enforce atomi_releaser conforms to gitlint"; + entry = "${packages.sg}/bin/sg gitlint"; + files = "(atomi_release\\.yaml|\\.gitlint)"; + language = "system"; + pass_filenames = false; + }; + + a-shellcheck = { + enable = true; + name = "Shell Check"; + entry = "${packages.shellcheck}/bin/shellcheck"; + files = ".*sh$"; + language = "system"; + pass_filenames = true; + }; + + a-enforce-exec = { + enable = true; + name = "Enforce Shell Script executable"; + entry = "${packages.coreutils}/bin/chmod +x"; + files = ".*sh$"; + language = "system"; + pass_filenames = true; + }; + a-helm-docs = { + enable = true; + name = "Helm Docs"; + entry = "${packages.helm-docs}/bin/helm-docs"; + files = ".*"; + language = "system"; + pass_filenames = false; + }; + }; + + settings = { + treefmt = { + package = formatter; + }; + }; +} diff --git a/nix/shells.nix b/nix/shells.nix new file mode 100644 index 0000000..ae01149 --- /dev/null +++ b/nix/shells.nix @@ -0,0 +1,18 @@ +{ pkgs, packages, env, shellHook }: +with env; +{ + default = pkgs.mkShell { + buildInputs = system ++ main ++ dev ++ env.lint ++ infra; + inherit shellHook; + }; + + ci = pkgs.mkShell { + buildInputs = system ++ main ++ lint ++ infra; + inherit shellHook; + }; + + releaser = pkgs.mkShell { + buildInputs = system ++ main ++ lint ++ infra ++ releaser; + inherit shellHook; + }; +} diff --git a/scripts/ci/pre-commit.sh b/scripts/ci/pre-commit.sh new file mode 100755 index 0000000..af245ca --- /dev/null +++ b/scripts/ci/pre-commit.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -eou pipefail + +pre-commit run --all-files -v diff --git a/scripts/ci/publish.sh b/scripts/ci/publish.sh new file mode 100755 index 0000000..1516d43 --- /dev/null +++ b/scripts/ci/publish.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +version="$1" + +set -eou pipefail + +echo "๐Ÿš€ Publishing version ${version}" + +yq eval ".version = \"${version}\"" ./chart/Chart.yaml >"Chart.tmp" +mv "Chart.tmp" ./chart/Chart.yaml + +echo "๐Ÿ“ Generating Documentation" +helm-docs +echo "โœ… Documentation Generated" diff --git a/scripts/ci/release.sh b/scripts/ci/release.sh new file mode 100755 index 0000000..1a0ebf4 --- /dev/null +++ b/scripts/ci/release.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -eou pipefail + +rm .git/hooks/* || true + +sg release -i npm diff --git a/scripts/local/create-k3d-cluster.sh b/scripts/local/create-k3d-cluster.sh new file mode 100755 index 0000000..2e5601b --- /dev/null +++ b/scripts/local/create-k3d-cluster.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +dev_config="$1" + +set -eou pipefail + +[ "$dev_config" = '' ] && dev_config="./config/dev.yaml" + +# check if dev config exists +if [ ! -f "$dev_config" ]; then + echo "โŒ Dev config '$dev_config' does not exist!" + exit 1 +fi + +input="$(yq '.landscape' "$dev_config")" +config="./infra/k3d.$input.yaml" +echo "๐Ÿงฌ Attempting to start cluster '$input' using '$config'..." + +# obtain existing cluster +current="$(k3d cluster ls -o json | jq -r --arg input "${input}" '.[] | select(.name == $input) | .name')" +if [ "$current" = "$input" ]; then + echo "โœ… Cluster already exist!" +else + # ask if to create cluster + echo "๐ŸฅŸ Cluster does not exist, creating..." + k3d cluster create "$input" --config "$config" --wait + echo "๐Ÿš€ Cluster created!" +fi + +echo "๐Ÿ›  Generating kubeconfig" +mkdir -p "$HOME/.kube/configs" +mkdir -p "$HOME/.kube/k3dconfigs" + +echo "๐Ÿ“ Writing to '$HOME/.kube/k3dconfigs/k3d-$input'" +k3d kubeconfig get "$input" >"$HOME/.kube/k3dconfigs/k3d-$input" +KUBECONFIG=$(cd ~/.kube/configs && find "$(pwd)"/* | awk 'ORS=":"')$(cd ~/.kube/k3dconfigs && find "$(pwd)"/* | awk 'ORS=":"') kubectl config view --flatten >~/.kube/config +chmod 600 ~/.kube/config +echo "โœ… Generated kube config file" +# wait for cluster to be ready +echo "๐Ÿ•‘ Waiting for cluster to be ready..." +kubectl --context "k3d-$input" -n kube-system wait --for=jsonpath=.status.readyReplicas=1 --timeout=300s deployment metrics-server +kubectl --context "k3d-$input" -n kube-system wait --for=jsonpath=.status.readyReplicas=1 --timeout=300s deployment coredns +kubectl --context "k3d-$input" -n kube-system wait --for=jsonpath=.status.readyReplicas=1 --timeout=300s deployment local-path-provisioner +kubectl --context "k3d-$input" -n kube-system wait --for=jsonpath=.status.succeeded=1 --timeout=300s job helm-install-traefik-crd +kubectl --context "k3d-$input" -n kube-system wait --for=jsonpath=.status.succeeded=1 --timeout=300s job helm-install-traefik +kubectl --context "k3d-$input" -n kube-system wait --for=jsonpath=.status.readyReplicas=1 --timeout=300s deployment traefik +echo "โœ… Cluster is ready!" diff --git a/scripts/local/delete-k3d-cluster.sh b/scripts/local/delete-k3d-cluster.sh new file mode 100755 index 0000000..0ee6c1c --- /dev/null +++ b/scripts/local/delete-k3d-cluster.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +dev_config="$1" + +set -eou pipefail + +[ "$dev_config" = '' ] && dev_config="./config/dev.yaml" + +# check if dev config exists +if [ ! -f "$dev_config" ]; then + echo "โŒ Dev config '$dev_config' does not exist!" + exit 1 +fi + +input="$(yq '.landscape' "$dev_config")" + +echo "๐Ÿ› ๏ธ Attempting to delete cluster '$input'..." + +# obtain existing cluster +current="$(k3d cluster ls -o json | jq -r --arg input "${input}" '.[] | select(.name == $input) | .name')" +if [ "$current" = "$input" ]; then + echo "๐Ÿ—‘๏ธ Cluster found! Deleting cluster..." + k3d cluster delete "$input" + echo "โœ… Cluster deleted!" +else + echo "โš ๏ธ Cluster does not exist!" +fi +echo "๐Ÿงน Cleaning up kubeconfig files..." +mkdir -p "$HOME/.kube/configs" +mkdir -p "$HOME/.kube/k3dconfigs" +rm "$HOME/.kube/k3dconfigs/k3d-$input" || true +KUBECONFIG=$(cd ~/.kube/configs && find "$(pwd)"/* | awk 'ORS=":"')$(cd ~/.kube/k3dconfigs && find "$(pwd)"/* | awk 'ORS=":"') kubectl config view --flatten >~/.kube/config +chmod 600 ~/.kube/config +echo "โœ… Config is cleared!" diff --git a/tasks/Taskfile.cluster.yaml b/tasks/Taskfile.cluster.yaml new file mode 100644 index 0000000..c92e2e2 --- /dev/null +++ b/tasks/Taskfile.cluster.yaml @@ -0,0 +1,30 @@ +version: "3" + +tasks: + debug: + desc: Debug the helm chart + dir: chart + cmds: + - helm dependency update + - helm template $RELEASE_NAME . --debug --values values.yaml --values values.{{.LANDSCAPE}}.{{.CLUSTER}}.yaml {{.CLI_ARGS}} + + template: + desc: Render the helm chart + dir: chart + cmds: + - helm dependency update + - >- + helm template $RELEASE_NAME . --values values.yaml --values values.{{.LANDSCAPE}}.{{.CLUSTER}}.yaml + {{.CLI_ARGS}} + + install: + desc: Installs the chart + dir: chart + cmds: + - helm dependency update + - helm upgrade --install $RELEASE_NAME . --values values.yaml --values values.{{.LANDSCAPE}}.{{.CLUSTER}}.yaml {{.CLI_ARGS}} + + remove: + desc: Removes an installed release + cmds: + - helm uninstall $RELEASE_NAME diff --git a/tasks/Taskfile.util.yaml b/tasks/Taskfile.util.yaml new file mode 100644 index 0000000..74b0cc4 --- /dev/null +++ b/tasks/Taskfile.util.yaml @@ -0,0 +1,11 @@ +version: "3" + +tasks: + latest: + internal: true + silent: true + desc: Get the latest version of a Helm Chart + cmds: + - helm repo add {{.REPO_NAME}} {{.REPO_URL}} > /dev/null + - helm repo update > /dev/null + - echo "{{.CHART_NAME}}:" $(helm search repo {{.REPO_NAME}}/{{.CHART_NAME}} --versions --max-col-width=0 | grep {{.REPO_NAME}}/{{.CHART_NAME}} | head -n 1 | awk '{print $2}')