Skip to content

Commit a706aad

Browse files
author
iru
authored
feat: enable benchmark on single-account-k8s (#83)
1 parent 064c186 commit a706aad

File tree

9 files changed

+87
-53
lines changed

9 files changed

+87
-53
lines changed

README.md

+36-32
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
# Sysdig Secure for Cloud in GCP
22

33
Terraform module that deploys the [**Sysdig Secure for Cloud** stack in **Google Cloud**](https://docs.sysdig.com/en/docs/installation/sysdig-secure-for-cloud/deploy-sysdig-secure-for-cloud-on-gcp/).
4-
<br/>It provides unified threat detection, compliance, forensics and analysis.
4+
<br/>
55

6-
There are three major components:
6+
Provides unified threat-detection, compliance, forensics and analysis through these major components:
7+
8+
* **[CSPM/Compliance](https://docs.sysdig.com/en/docs/sysdig-secure/benchmarks/)**: It evaluates periodically your cloud configuration, using Cloud Custodian, against some benchmarks and returns the results and remediation you need to fix. Managed through `cloud-bench` module. <br/>
9+
10+
* **[CIEM](https://docs.sysdig.com/en/docs/sysdig-secure/posture/)**: Permissions and Entitlements management. Requires BOTH modules `cloud-connector` and `cloud-bench`. <br/>
11+
12+
* **[Cloud Threat Detection](https://docs.sysdig.com/en/docs/sysdig-secure/insights/)**: Tracks abnormal and suspicious activities in your cloud environment based on Falco language. Managed through `cloud-connector` module. <br/>
13+
14+
* **[Cloud Scanning](https://docs.sysdig.com/en/docs/sysdig-secure/scanning/)**: Automatically scans all container images pushed to the registry or as soon a new task which involves a container is spawned in your account. Managed through `cloud-connector`. <br/>
715

8-
* **CSPM/Compliance**: It evaluates periodically your cloud configuration, using Cloud Custodian, against some benchmarks and returns the results and remediation you need to fix. Managed through [cloud-bench module](https://github.com/sysdiglabs/terraform-google-secure-for-cloud/tree/master/modules/services/cloud-bench).
9-
<br/><br/>
10-
* **Cloud Threat Detection**: Tracks abnormal and suspicious activities in your cloud environment based on Falco language. Managed through [cloud-connector module](https://github.com/sysdiglabs/terraform-google-secure-for-cloud/tree/master/modules/services/cloud-connector).
11-
<br/><br/>
12-
* **Cloud Scanning**: Automatically scans all container images pushed to the registry or as soon a new task which involves a container is spawned in your account. Managed through [cloud-connector module](https://github.com/sysdiglabs/terraform-google-secure-for-cloud/tree/master/modules/services/cloud-connector).
13-
<br/><br/>
1416

1517
For other Cloud providers check: [AWS](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud), [Azure](https://github.com/sysdiglabs/terraform-azurerm-secure-for-cloud)
1618

@@ -133,38 +135,40 @@ In the `cloud-connector` logs you should see similar logs to these
133135
134136
## Troubleshooting
135137
136-
### Q1: Getting "Error creating WorkloadIdentityPool: googleapi: Error 409: Requested entity already exists"<br/>
137-
A1: Currently Sysdig Backend does not support dynamic WorkloadPool and it's name is fixed to `sysdiglcoud`.
138-
<br/>Besides, Google, only performs a soft-deletion of this resource.
139-
https://cloud.google.com/iam/docs/manage-workload-identity-pools-providers#delete-pool
138+
### Q: Getting "Error creating WorkloadIdentityPool: googleapi: Error 409: Requested entity already exists"<br/>
139+
A: Currently Sysdig Backend does not support dynamic WorkloadPool and it's name is fixed to `sysdiglcoud`.
140+
<br/>Besides, Google, only performs a soft-deletion of this resource.
141+
https://cloud.google.com/iam/docs/manage-workload-identity-pools-providers#delete-pool
140142

141143
> You can undelete a pool for up to 30 days after deletion. After 30 days, deletion is permanent. Until a pool is permanently deleted, you cannot reuse its name when creating a new workload identity pool.<br/>
142144

143-
S1: For the moment, federation workload identity pool+provider have fixed name. In case you want to reuse it, you can reactivate and import it, into your terraform state manually.
144-
```bash
145-
# re-activate pool and provider
146-
$ gcloud iam workload-identity-pools undelete sysdigcloud --location=global
147-
$ gcloud iam workload-identity-pools providers undelete sysdigcloud --workload-identity-pool="sysdigcloud" --location=global
145+
S: For the moment, federation workload identity pool+provider have fixed name. In case you want to reuse it, you can reactivate and import it, into your terraform state manually.
146+
```bash
147+
# re-activate pool and provider
148+
$ gcloud iam workload-identity-pools undelete sysdigcloud --location=global
149+
$ gcloud iam workload-identity-pools providers undelete sysdigcloud --workload-identity-pool="sysdigcloud" --location=global
150+
151+
# import to terraform state
152+
# input your project-id, and for organization example, change the import resource accordingly
153+
$ terraform import 'module.sfc_example_single-project.module.cloud_bench[0].module.trust_relationship["<YOUR_PROJECT_ID>"].google_iam_workload_identity_pool.pool' sysdigcloud
154+
$ terraform import 'module.sfc_example_single-project.module.cloud_bench[0].module.trust_relationship["<YOUR_PROJECT_ID>"].google_iam_workload_identity_pool_provider.pool_provider' sysdigcloud/sysdigcloud
155+
```
156+
157+
### Q: Scanning does not seem to work<br/>
158+
A: Verify that `gcr` topic exists. If `create_gcr_topic` is set to false and `gcr` topic is not found, the GCR scanning is ommited and won't be deployed. For more info see GCR PubSub topic.
159+
<br/><br/>
148160
149-
# import to terraform state
150-
# input your project-id, and for organization example, change the import resource accordingly
151-
$ terraform import 'module.sfc_example_single-project.module.cloud_bench[0].module.trust_relationship["<YOUR_PROJECT_ID>"].google_iam_workload_identity_pool.pool' sysdigcloud
152-
$ terraform import 'module.sfc_example_single-project.module.cloud_bench[0].module.trust_relationship["<YOUR_PROJECT_ID>"].google_iam_workload_identity_pool_provider.pool_provider' sysdigcloud/sysdigcloud
153-
```
161+
### Q: Scanning, I get an error saying:
162+
```
163+
error starting scan runner for image ****: rpc error: code = PermissionDenied desc = Cloud Build API has not been used in project *** before or it is disabled.
164+
Enable it by visiting https://console.developers.google.com/apis/api/cloudbuild.googleapis.com/overview?project=*** then retry.
154165
155-
### Q2: Scanning does not seem to work<br/>
156-
A2: Verify that `gcr` topic exists. If `create_gcr_topic` is set to false and `gcr` topic is not found, the GCR scanning is ommited and won't be deployed. For more info see GCR PubSub topic.
166+
If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry
167+
```
168+
A: Do as the error says and activate CloudBuild API. Check the list of all the required APIs that need to be activated per feature module.
157169
<br/><br/>
158170
159-
### Q3: Scanning, I get an error saying:
160-
```
161-
error starting scan runner for image ****: rpc error: code = PermissionDenied desc = Cloud Build API has not been used in project *** before or it is disabled.
162-
Enable it by visiting https://console.developers.google.com/apis/api/cloudbuild.googleapis.com/overview?project=*** then retry.
163171
164-
If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry
165-
```
166-
A3: Do as the error says and activate CloudBuild API. Check the list of all the required APIs that need to be activated per feature module.
167-
<br/><br/>
168172
## Authors
169173
170174
Module is maintained and supported by [Sysdig](https://sysdig.com).

examples/single-project-k8s/README.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
Deploy Sysdig Secure for Cloud in a provided existing Kubernetes Cluster.
44

5-
- Sysdig **Helm** charts will be used to deploy the secure-for-cloud stack:
6-
- [Cloud-Connector Chart](https://charts.sysdig.com/charts/cloud-connector/)
7-
- Because these charts require specific GCP credentials to be passed by parameter, a new service account + key will
8-
be created within the project. See [`credentials.tf`](./credentials.tf)
9-
- Used architecture is similar to [single-project](../single-project) but changing Cloud Run <---> with an existing K8s
5+
- Sysdig **Helm** [cloud-connector chart](https://charts.sysdig.com/charts/cloud-connector/) will be used to deploy threat-detection and scanning features
6+
<br/>Because these charts require specific GCP credentials to be passed by parameter, a new service account + key will be created
7+
within the project. See [`credentials.tf`](https://github.com/sysdiglabs/terraform-google-secure-for-cloud/blob/master/examples/single-project-k8s/credentials.tf)
8+
- Used architecture is similar to [single-project](https://github.com/sysdiglabs/terraform-google-secure-for-cloud/blob/master/examples/single-project) but changing Cloud Run <---> with an existing K8s
109

1110
All the required resources and workloads will be run under the same GCP project.
1211

@@ -71,6 +70,7 @@ Notice that:
7170

7271
| Name | Source | Version |
7372
|------|--------|---------|
73+
| <a name="module_cloud_bench"></a> [cloud\_bench](#module\_cloud\_bench) | ../../modules/services/cloud-bench | |
7474
| <a name="module_connector_project_sink"></a> [connector\_project\_sink](#module\_connector\_project\_sink) | ../../modules/infrastructure/project_sink | |
7575

7676
## Resources
@@ -89,7 +89,10 @@ Notice that:
8989
| Name | Description | Type | Default | Required |
9090
|------|-------------|------|---------|:--------:|
9191
| <a name="input_sysdig_secure_api_token"></a> [sysdig\_secure\_api\_token](#input\_sysdig\_secure\_api\_token) | Sysdig's Secure API Token | `string` | n/a | yes |
92+
| <a name="input_benchmark_regions"></a> [benchmark\_regions](#input\_benchmark\_regions) | List of regions in which to run the benchmark. If empty, the task will contain all regions by default. | `list(string)` | `[]` | no |
93+
| <a name="input_benchmark_role_name"></a> [benchmark\_role\_name](#input\_benchmark\_role\_name) | The name of the Service Account that will be created. | `string` | `"sysdigcloudbench"` | no |
9294
| <a name="input_cloud_connector_image"></a> [cloud\_connector\_image](#input\_cloud\_connector\_image) | Cloud-connector image to deploy | `string` | `"quay.io/sysdig/cloud-connector"` | no |
95+
| <a name="input_deploy_benchmark"></a> [deploy\_benchmark](#input\_deploy\_benchmark) | whether benchmark module is to be deployed | `bool` | `true` | no |
9396
| <a name="input_name"></a> [name](#input\_name) | Name to be assigned to all child resources. A suffix may be added internally when required. Use default value unless you need to install multiple instances | `string` | `"sfc"` | no |
9497
| <a name="input_sysdig_secure_endpoint"></a> [sysdig\_secure\_endpoint](#input\_sysdig\_secure\_endpoint) | Sysdig Secure API endpoint | `string` | `"https://secure.sysdig.com"` | no |
9598

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module "cloud_bench" {
2+
count = var.deploy_benchmark ? 1 : 0
3+
source = "../../modules/services/cloud-bench"
4+
5+
is_organizational = false
6+
role_name = "${var.name}${var.benchmark_role_name}"
7+
project_id = data.google_client_config.current.project
8+
regions = var.benchmark_regions
9+
}

examples/single-project-k8s/variables.tf

+22
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@ variable "sysdig_secure_api_token" {
77
# --------------------------
88
# optionals, with defaults
99
# -------------------------
10+
11+
# benchmark
12+
variable "deploy_benchmark" {
13+
type = bool
14+
description = "whether benchmark module is to be deployed"
15+
default = true
16+
}
17+
18+
variable "benchmark_regions" {
19+
type = list(string)
20+
description = "List of regions in which to run the benchmark. If empty, the task will contain all regions by default."
21+
default = []
22+
}
23+
24+
variable "benchmark_role_name" {
25+
type = string
26+
description = "The name of the Service Account that will be created."
27+
default = "sysdigcloudbench"
28+
}
29+
30+
31+
# general
1032
variable "sysdig_secure_endpoint" {
1133
type = string
1234
default = "https://secure.sysdig.com"

examples/single-project/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ module "secure-for-cloud_example_single-project" {
9393
| <a name="input_sysdig_secure_api_token"></a> [sysdig\_secure\_api\_token](#input\_sysdig\_secure\_api\_token) | Sysdig's Secure API Token | `string` | n/a | yes |
9494
| <a name="input_benchmark_regions"></a> [benchmark\_regions](#input\_benchmark\_regions) | List of regions in which to run the benchmark. If empty, the task will contain all regions by default. | `list(string)` | `[]` | no |
9595
| <a name="input_benchmark_role_name"></a> [benchmark\_role\_name](#input\_benchmark\_role\_name) | The name of the Service Account that will be created. | `string` | `"sysdigcloudbench"` | no |
96-
| <a name="input_deploy_bench"></a> [deploy\_bench](#input\_deploy\_bench) | whether benchmark module is to be deployed | `bool` | `true` | no |
96+
| <a name="input_deploy_benchmark"></a> [deploy\_benchmark](#input\_deploy\_benchmark) | whether benchmark module is to be deployed | `bool` | `true` | no |
9797
| <a name="input_name"></a> [name](#input\_name) | Name to be assigned to all child resources. A suffix may be added internally when required. Use default value unless you need to install multiple instances | `string` | `"sfc"` | no |
9898
| <a name="input_sysdig_secure_endpoint"></a> [sysdig\_secure\_endpoint](#input\_sysdig\_secure\_endpoint) | Sysdig Secure API endpoint | `string` | `"https://secure.sysdig.com"` | no |
9999

examples/single-project/benchmark.tf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module "cloud_bench" {
2+
count = var.deploy_benchmark ? 1 : 0
3+
source = "../../modules/services/cloud-bench"
4+
5+
is_organizational = false
6+
role_name = "${var.name}${var.benchmark_role_name}"
7+
project_id = data.google_client_config.current.project
8+
regions = var.benchmark_regions
9+
}

examples/single-project/main.tf

-13
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,3 @@ module "pubsub_http_subscription" {
6262

6363
push_http_endpoint = "${module.cloud_connector.cloud_run_service_url}/gcr_scanning"
6464
}
65-
66-
#######################
67-
# BENCHMARKS #
68-
#######################
69-
module "cloud_bench" {
70-
count = var.deploy_bench ? 1 : 0
71-
source = "../../modules/services/cloud-bench"
72-
73-
is_organizational = false
74-
role_name = "${var.name}${var.benchmark_role_name}"
75-
project_id = data.google_client_config.current.project
76-
regions = var.benchmark_regions
77-
}

examples/single-project/variables.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ variable "name" {
2626

2727
# benchmark
2828

29-
variable "deploy_bench" {
29+
variable "deploy_benchmark" {
3030
type = bool
3131
description = "whether benchmark module is to be deployed"
3232
default = true

test/fixtures/single-project/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ module "sfc_example_single_project" {
2121
sysdig_secure_api_token = var.sysdig_secure_api_token
2222
sysdig_secure_endpoint = var.sysdig_secure_endpoint
2323
name = "sfc${random_string.random.result}"
24-
deploy_bench = false
24+
deploy_benchmark = false
2525
}

0 commit comments

Comments
 (0)