Skip to content

Commit

Permalink
Merge pull request #40 from RADAR-base/devbox
Browse files Browse the repository at this point in the history
Added devbox
  • Loading branch information
keyvaann authored Jan 8, 2025
2 parents 2e45f2d + 3bd276b commit b8223c2
Show file tree
Hide file tree
Showing 30 changed files with 682 additions and 240 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/cluster.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/config.yaml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Pre-commit hooks

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

permissions: read-all

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install devbox
uses: jetify-com/[email protected]
with:
enable-cache: 'true'

- name: Run pre-commit on all files
run: devbox run -- pre-commit run --verbose --all-files --show-diff-on-failure
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json
Expand Down
51 changes: 51 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: |
(?x)^(
config/README.md|
cluster/README.md
)$
- id: mixed-line-ending
- id: check-yaml
args:
- --allow-multiple-documents
- id: check-added-large-files
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-merge-conflict
- id: no-commit-to-branch
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.96.2
hooks:
- id: terraform_fmt
- id: terraform_validate
- id: terraform_tflint
- id: terraform_trivy
args:
- --args=--severity MEDIUM,HIGH,CRITICAL
- --args=--skip-dirs="*/.terraform"
- --args=--tf-exclude-downloaded-modules
- id: terraform_checkov
args:
- --args=--quiet
- --args=--download-external-modules False
- repo: local
hooks:
- id: terraform-docs-cluster
name: Generate docs for the Terraform cluster/
language: system
entry: terraform-docs markdown table cluster/
pass_filenames: false
files: 'cluster/'
- id: terraform-docs-config
name: Generate docs for the Terraform config/
language: system
entry: terraform-docs markdown table config/
pass_filenames: false
files: 'config/'
15 changes: 0 additions & 15 deletions Makefile

This file was deleted.

34 changes: 20 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ This repository aims to provide [IaC](https://en.wikipedia.org/wiki/Infrastructu

---

[![Terraform validate](https://github.com/phidatalab/RADAR-K8s-Infrastructure/actions/workflows/cluster.yaml/badge.svg)](https://github.com/phidatalab/RADAR-K8s-Infrastructure/actions/workflows/cluster.yaml/badge.svg)
[![Terraform validate](https://github.com/phidatalab/RADAR-K8s-Infrastructure/actions/workflows/config.yaml/badge.svg)](https://github.com/phidatalab/RADAR-K8s-Infrastructure/actions/workflows/config.yaml/badge.svg)
[![Lint and validate](https://github.com/RADAR-base/RADAR-K8s-Infrastructure/actions/workflows/pre-commit.yaml/badge.svg)](https://github.com/phidatalab/RADAR-K8s-Infrastructure/actions/workflows/pre-commit.yaml/badge.svg)
[![Join our community Slack](https://img.shields.io/badge/slack-radarbase-success.svg?logo=slack)](https://docs.google.com/forms/d/e/1FAIpQLScKNZ-QonmxNkekDMLLbP-b_IrNHyDRuQValBy1BAsLOjEFpg/viewform)

# Dependencies

Expand All @@ -18,6 +18,15 @@ It is recommended that you use RADAR-K8s-Infrastructure as a template and create

<img src="./image/use_this_template.png" alt="use this template" width="500" height="124">

## Workspaces

The definition of resources required for running RADAR-base components is located in the `cluster` directory, while other optional resources are defined in the `config` directory. Please treat each directory as a separate workspace and perform terraform operations individually. The `cluster` resources need to be created and made fully available before you proceed with the creation of the `config` ones.

To retain the user-specific configurations for future infrastructure updates, modify `terraform.tfvars` within the workspace and push the change to your repository. If needed, additional variables defined in `variables.tf` can also be included there.
| :information_source: Important Notice |
|:----------------------------------------|
|As a best practice, never save raw values of secret variables in your repository. Instead, always encrypt them before committing. If your cluster is no longer in use, run `terraform destroy` to delete all the associated resources and reduce your cloud spending. If you have resources created within `config`, run `terraform destroy` in that directory before running the counterpart in `cluster`.|

## Configure credentials

```
Expand All @@ -28,15 +37,6 @@ export TF_VAR_AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
export TF_VAR_AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN
```

## Workspaces

The definition of resources required for running RADAR-base components is located in the `cluster` directory, while other optional resources are defined in the `config` directory. Please treat each directory as a separate workspace and perform terraform operations individually. The `cluster` resources need to be created and made fully available before you proceed with the creation of the `config` ones.

To retain the user-specific configurations for future infrastructure updates, modify `terraform.tfvars` within the workspace and push the change to your repository. If needed, additional variables defined in `variables.tf` can also be included there.
| :information_source: Important Notice |
|:----------------------------------------|
|As a best practice, never save raw values of secret variables in your repository. Instead, always encrypt them before committing. If your cluster is no longer in use, run `terraform destroy` to delete all the associated resources and reduce your cloud spending. If you have resources created within `config`, run `terraform destroy` in that directory before running the counterpart in `cluster`.|

## Create the infrastructure

```
Expand Down Expand Up @@ -79,7 +79,7 @@ Created resources:

```
# Make sure to use --region if the cluster is deployed in non-default region and --profile if the cluster is deployed in a non-default AWS account
aws eks update-kubeconfig --name [eks_cluster_name]
aws eks update-kubeconfig --name `terraform output eks_cluster_name` --alias `terraform output eks_cluster_name` --role-arn `terraform output assume_eks_admins_role`
kubectl get nodes
kubectl get pods -A
```
Expand All @@ -91,6 +91,7 @@ terraform output
```

Note that output values can be crucial for configuring certain RADAR-base components prior to deployment. For instance, if you are using the nginx-ingress controller with NLB, specify the subnet(s) and the EIP allocation ID as follows:

```yaml
nginx_ingress:
_install: true
Expand All @@ -105,7 +106,6 @@ nginx_ingress:
You could also automate this value injection by implementing your own templating strategy to customise `production.yaml`.


## Configure the cluster (optional)

N.B.: To get external DNS, Cert Manager and SMTP working via Route 53 (if chosen as your DNS service), you need to configure your registered top-level domain and its corresponding hosted zone ID via variable `domain_name` in [config/terraform.tfvars](./config/terraform.tfvars). Additionally, set `enable_route53` to `true`.
Expand Down Expand Up @@ -134,7 +134,13 @@ Created resources (if all enabled):

## Contributing

Make sure to install [terraform-docs](https://github.com/terraform-docs/terraform-docs) and run `make prepare` before making a commit to make sure the documentation is up to date and the code is valid.
The dependencies and linting tools and managed via Devbox, you need to [install it](https://jetify-com.vercel.app/docs/devbox/installing_devbox/#install-devbox) before proceeding. Once that is done you can run

```
devbox shell
```
To download all of the dependencies and install to Git hooks to lint the configuration before it is commited.
In order to support new version of EKS you need to make sure the addons that we use are compatible with the new target version. You can get a list of addons and their EKS compatiblity with running `aws eks describe-addons-versions` and then searching for the addons that are defined in [cluster/data.tf](./cluster/data.tf).
Expand Down
38 changes: 16 additions & 22 deletions cluster/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b8223c2

Please sign in to comment.