Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fast-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ludoo committed Jan 6, 2025
2 parents 510d76d + 325a997 commit 8ab982c
Show file tree
Hide file tree
Showing 26 changed files with 1,670 additions and 123 deletions.
76 changes: 76 additions & 0 deletions adrs/fast/addon-stages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Add-on stages

**authors:** [Ludo](https://github.com/ludoo), [Julio](https://github.com/juliocc)
**date:** Jan 5, 2025

## Status

Under implementation

## Context

Some optional features are too complex to directly embed in stages, as they would complicate the variable scope, need to be replicated across parallel stages, and introduce a lot of nested code for the benefit of a small subset of users.

This need has surfaced with the network security stage, which has taken the approach of spreading its resources across different stages (security, networking, and its own netsec) and resulted in very layered, complicated code which is not easy to deploy or maintain.

This is how the current netsec stage looks like from a resource perspective:

![image](https://github.com/user-attachments/assets/c9778cd8-8dd4-4f7c-b74b-c5d8ad7e7d30)

Furthermore, the stage also tries to do "too much", by behaving as a full stage and adopting a design that statically maps its resources onto all FAST environments and networks. This results in code that is really hard to adapt for real life use cases and impossible to keep forward compatible, as changes are extensive and spread out across three stages.

## Proposal

The proposal is to adopt a completely different approach, where large optional featuresets that we don't want to embed in our default stages should become "addon stages" that:

- reuse the IaC service account and bucket of the stage they interact with (e.g. networking for network security) to eliminate the need for custom IAM
- encapsulate all their resources in a single root module (the add-on stage)
- don't implement a static design but deal with the smallest possible unit of work, so that they can be cloned to implement different designs via tfvars
- provide optional FAST output variables for the main stages

This is what the network security stage looks like, once refactored according this proposal:

![image](https://github.com/user-attachments/assets/748b8b53-8df7-444e-9c71-f74e462a96f1)

With this approach

- there are no dependencies in resman except for a providers file that adds a prefix to the state backend and reuses networking service accounts and bucket
- the stage design does not deal with environments, but simply implements one complete set of NGFW resources in a given project (typically the net landing or shared environment project) and allows free configuration of zones and VPC attachments
- any relevant resource already defined in the "main" stages can be referred to via interpolation, by using the stages outputs as contexts

The code then becomes really simple to use, read and evolve since it's essentially decoupled from the main stages except for a handful of FAST interface variables.

Add-on stages should live in a separate folder from stages, and once we finally manage to reafctor networking into a simple stage, we go back to having a clear progression for main stages that should make it easier for users to get to grips with FAST's complexity. We might also want to scrap the plugins folder, and replace with a short document explaining the pattern.

```bash
fast
├── addons
├── 1-tenant-factory
└── 2-network-security
├── assets
│   └── templates
├── extras
│   ├── 0-cicd-github
│   └── 0-cicd-gitlab
├── plugins
│   └── 2-networking-serverless-connector
└── stages
├── 0-bootstrap
├── 1-resman
├── 1-vpcsc
├── 2-networking-a-simple
├── 2-networking-b-nva
├── 2-networking-c-separate-envs
├── 2-project-factory
├── 2-security
├── 3-gcve-dev
└── 3-gke-dev
```

## Decision

TBD

## Consequences

This approach also maps well to the current tenant factory stage, which essentially acts as a parallel resman stage reusing the same set of IaC resources.
2 changes: 1 addition & 1 deletion blueprints/data-solutions/bq-ml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ module "test" {
prefix = "prefix"
}
# tftest modules=9 resources=68
# tftest modules=9 resources=69
```
2 changes: 1 addition & 1 deletion blueprints/data-solutions/data-playground/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ module "test" {
parent = "folders/467898377"
}
}
# tftest modules=8 resources=67
# tftest modules=8 resources=68
```
4 changes: 2 additions & 2 deletions blueprints/data-solutions/vertex-mlops/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module "test" {
project_id = "test-dev"
}
}
# tftest modules=11 resources=89
# tftest modules=11 resources=90
```
<!-- BEGIN TFDOC -->
## Variables
Expand Down Expand Up @@ -128,5 +128,5 @@ module "test" {
project_id = "test-dev"
}
}
# tftest modules=13 resources=94 e2e
# tftest modules=13 resources=95 e2e
```
3 changes: 3 additions & 0 deletions blueprints/data-solutions/vertex-mlops/vertex.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,7 @@ resource "google_workbench_instance" "playground" {
depends_on = [
google_project_iam_member.shared_vpc,
]
lifecycle {
ignore_changes = [gce_setup[0].metadata["resource-url"]]
}
}
20 changes: 10 additions & 10 deletions blueprints/secops/bindplane-gke/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ Access the management console leveraging credentials bootstrapped via terraform

| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
| [bindplane_secrets](variables.tf#L26) | Bindplane secrets. | <code title="object&#40;&#123;&#10; license &#61; string&#10; user &#61; optional&#40;string, &#34;admin&#34;&#41;&#10; password &#61; optional&#40;string, null&#41;&#10; sessions_secret &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> || |
| [network_config](variables.tf#L57) | Shared VPC network configurations to use for GKE cluster. | <code title="object&#40;&#123;&#10; host_project &#61; optional&#40;string&#41;&#10; network_self_link &#61; string&#10; subnet_self_link &#61; string&#10; ip_range_gke_master &#61; string&#10; secondary_pod_range_name &#61; optional&#40;string, &#34;pods&#34;&#41;&#10; secondary_services_range_name &#61; optional&#40;string, &#34;services&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> || |
| [prefix](variables.tf#L79) | Prefix used for resource names. | <code>string</code> || |
| [project_id](variables.tf#L98) | Project id, references existing project if `project_create` is null. | <code>string</code> || |
| [region](variables.tf#L103) | GCP region. | <code>string</code> || |
| [bindplane_config](variables.tf#L17) | Bindplane config. | <code title="object&#40;&#123;&#10; tls_certificate_cer &#61; optional&#40;string, null&#41;&#10; tls_certificate_key &#61; optional&#40;string, null&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [cluster_config](variables.tf#L36) | GKE cluster configuration. | <code title="object&#40;&#123;&#10; cluster_name &#61; optional&#40;string, &#34;bindplane-op&#34;&#41;&#10; master_authorized_ranges &#61; optional&#40;map&#40;string&#41;, &#123;&#10; rfc-1918-10-8 &#61; &#34;10.0.0.0&#47;8&#34;&#10; &#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [dns_config](variables.tf#L47) | DNS config. | <code title="object&#40;&#123;&#10; bootstrap_private_zone &#61; optional&#40;bool, false&#41;&#10; domain &#61; optional&#40;string, &#34;example.com&#34;&#41;&#10; hostname &#61; optional&#40;string, &#34;bindplane&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [postgresql_config](variables.tf#L69) | Cloud SQL postgresql config. | <code title="object&#40;&#123;&#10; availability_type &#61; optional&#40;string, &#34;REGIONAL&#34;&#41;&#10; database_version &#61; optional&#40;string, &#34;POSTGRES_13&#34;&#41;&#10; tier &#61; optional&#40;string, &#34;db-g1-small&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [project_create](variables.tf#L89) | Provide values if project creation is needed, uses existing project if null. Parent is in 'folders/nnn' or 'organizations/nnn' format. | <code title="object&#40;&#123;&#10; billing_account_id &#61; string&#10; parent &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [bindplane_secrets](variables.tf#L27) | Bindplane secrets. | <code title="object&#40;&#123;&#10; license &#61; string&#10; user &#61; optional&#40;string, &#34;admin&#34;&#41;&#10; password &#61; optional&#40;string, null&#41;&#10; sessions_secret &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> || |
| [network_config](variables.tf#L58) | Shared VPC network configurations to use for GKE cluster. | <code title="object&#40;&#123;&#10; host_project &#61; optional&#40;string&#41;&#10; network_self_link &#61; string&#10; subnet_self_link &#61; string&#10; ip_range_gke_master &#61; string&#10; secondary_pod_range_name &#61; optional&#40;string, &#34;pods&#34;&#41;&#10; secondary_services_range_name &#61; optional&#40;string, &#34;services&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> || |
| [prefix](variables.tf#L80) | Prefix used for resource names. | <code>string</code> || |
| [project_id](variables.tf#L99) | Project id, references existing project if `project_create` is null. | <code>string</code> || |
| [region](variables.tf#L104) | GCP region. | <code>string</code> || |
| [bindplane_config](variables.tf#L17) | Bindplane config. | <code title="object&#40;&#123;&#10; image_tag &#61; optional&#40;string, &#34;&#34;&#41;&#10; tls_certificate_cer &#61; optional&#40;string, null&#41;&#10; tls_certificate_key &#61; optional&#40;string, null&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [cluster_config](variables.tf#L37) | GKE cluster configuration. | <code title="object&#40;&#123;&#10; cluster_name &#61; optional&#40;string, &#34;bindplane-op&#34;&#41;&#10; master_authorized_ranges &#61; optional&#40;map&#40;string&#41;, &#123;&#10; rfc-1918-10-8 &#61; &#34;10.0.0.0&#47;8&#34;&#10; &#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [dns_config](variables.tf#L48) | DNS config. | <code title="object&#40;&#123;&#10; bootstrap_private_zone &#61; optional&#40;bool, false&#41;&#10; domain &#61; optional&#40;string, &#34;example.com&#34;&#41;&#10; hostname &#61; optional&#40;string, &#34;bindplane&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [postgresql_config](variables.tf#L70) | Cloud SQL postgresql config. | <code title="object&#40;&#123;&#10; availability_type &#61; optional&#40;string, &#34;REGIONAL&#34;&#41;&#10; database_version &#61; optional&#40;string, &#34;POSTGRES_13&#34;&#41;&#10; tier &#61; optional&#40;string, &#34;db-g1-small&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [project_create](variables.tf#L90) | Provide values if project creation is needed, uses existing project if null. Parent is in 'folders/nnn' or 'organizations/nnn' format. | <code title="object&#40;&#123;&#10; billing_account_id &#61; string&#10; parent &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |

## Outputs

Expand Down
7 changes: 7 additions & 0 deletions blueprints/secops/bindplane-gke/config/values.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ config:
# of pods is recommended.
replicas: 2

image:
# -- Image name to be used. Defaults to `ghcr.io/observiq/bindplane-ee`.
name: ""
# Overrides the image tag whose default is {{ .Chart.AppVersion }}
# -- Image tag to use. Defaults to the version defined in the Chart's release.
tag: ${tag}

resources:
# Allow cpu bursting by leaving limits.cpu unset
requests:
Expand Down
1 change: 1 addition & 0 deletions blueprints/secops/bindplane-gke/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ resource "helm_release" "bindplane" {
gcp_project_id = module.project.project_id
hostname = "${var.dns_config.hostname}.${var.dns_config.domain}"
address = "ingress"
tag = var.bindplane_config.image_tag
})]

depends_on = [
Expand Down
1 change: 1 addition & 0 deletions blueprints/secops/bindplane-gke/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
variable "bindplane_config" {
description = "Bindplane config."
type = object({
image_tag = optional(string, "")
tls_certificate_cer = optional(string, null)
tls_certificate_key = optional(string, null)
})
Expand Down
Loading

0 comments on commit 8ab982c

Please sign in to comment.