Skip to content

Commit 6c194a0

Browse files
authored
Merge branch 'master' into cloud_functions_trigger_v2_optionals
2 parents 78d20b1 + df539b5 commit 6c194a0

File tree

16 files changed

+226
-95
lines changed

16 files changed

+226
-95
lines changed

blueprints/cloud-operations/network-dashboard/README.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,25 @@ Three metric descriptors are created for each monitored resource: usage, limit a
1616
Clone this repository, then go through the following steps to create resources:
1717
- Create a terraform.tfvars file with the following content:
1818
```tfvars
19-
organization_id = "<YOUR-ORG-ID>"
20-
billing_account = "<YOUR-BILLING-ACCOUNT>"
21-
monitoring_project_id = "project-0" # Monitoring project where the dashboard will be created and the solution deployed
22-
monitored_projects_list = ["project-1", "project2"] # Projects to be monitored by the solution
23-
monitored_folders_list = ["folder_id"] # Folders to be monitored by the solution
24-
v2 = false # Set to true to use V2 Cloud Functions environment
25-
```
19+
organization_id = "<YOUR-ORG-ID>"
20+
billing_account = "<YOUR-BILLING-ACCOUNT>"
21+
monitoring_project_id = "<YOUR-MONITORING-PROJECT>"
22+
# Monitoring project where the dashboard will be created and the solution deployed, a project named "mon-network-dahshboard" will be created if left blank
23+
monitored_projects_list = ["project-1", "project2"]
24+
# Projects to be monitored by the solution
25+
monitored_folders_list = ["folder_id"]
26+
# Folders to be monitored by the solution
27+
prefix = "<YOUR-PREFIX>"
28+
# Monitoring project name prefix, monitoring project name is <YOUR-PREFIX>-network-dashboard, ignored if monitoring_project_id variable is provided
29+
cf_version = V1|V2
30+
# Set to V2 to use V2 Cloud Functions environment
31+
```
2632
- `terraform init`
2733
- `terraform apply`
2834
2935
Note: Org level viewing permission is required for some metrics such as firewall policies.
3036
31-
Once the resources are deployed, go to the following page to see the dashboard: https://console.cloud.google.com/monitoring/dashboards?project=<YOUR-MONITORING-PROJECT>.
32-
A dashboard called "quotas-utilization" should be created.
37+
Once the resources are deployed, go to the following page to see the dashboard: https://console.cloud.google.com/monitoring/dashboards?project=<YOUR-MONITORING-PROJECT> a dashboard called "quotas-utilization" should be created.
3338
3439
The Cloud Function runs every 10 minutes by default so you should start getting some data points after a few minutes.
3540
You can use the metric explorer to view the data points for the different custom metrics created: https://console.cloud.google.com/monitoring/metrics-explorer?project=<YOUR-MONITORING-PROJECT>.
@@ -69,7 +74,6 @@ Note that metrics are created in the cloud-function/metrics.yaml file. You can a
6974
- The CF assumes custom routes importing/exporting is ON, this impacts static and dynamic routes usage calculation
7075
- The CF assumes all networks in peering groups have the same global routing and custom routes sharing configuration
7176
72-
7377
## Next steps and ideas
7478
In a future release, we could support:
7579
- Google managed VPCs that are peered with PSA (such as Cloud SQL or Memorystore)
@@ -87,13 +91,13 @@ If you are interested in this and/or would like to contribute, please contact le
8791
|---|---|:---:|:---:|:---:|
8892
| [billing_account](variables.tf#L17) | The ID of the billing account to associate this project with | <code></code> | ✓ | |
8993
| [monitored_projects_list](variables.tf#L36) | ID of the projects to be monitored (where limits and quotas data will be pulled) | <code>list&#40;string&#41;</code> | ✓ | |
90-
| [organization_id](variables.tf#L47) | The organization id for the associated services | <code></code> || |
91-
| [prefix](variables.tf#L51) | Customer name to use as prefix for monitoring project | <code></code> || |
94+
| [organization_id](variables.tf#L46) | The organization id for the associated services | <code></code> | ✓ | |
95+
| [prefix](variables.tf#L50) | Customer name to use as prefix for monitoring project | <code></code> | ✓ | |
9296
| [cf_version](variables.tf#L21) | Cloud Function version 2nd Gen or 1st Gen. Possible options: 'V1' or 'V2'.Use CFv2 if your Cloud Function timeouts after 9 minutes. By default it is using CFv1. | <code></code> | | <code>V1</code> |
9397
| [monitored_folders_list](variables.tf#L30) | ID of the projects to be monitored (where limits and quotas data will be pulled) | <code>list&#40;string&#41;</code> | | <code>&#91;&#93;</code> |
9498
| [monitoring_project_id](variables.tf#L41) | Monitoring project where the dashboard will be created and the solution deployed; a project will be created if set to empty string | <code></code> | | |
95-
| [project_monitoring_services](variables.tf#L55) | Service APIs enabled in the monitoring project if it will be created. | <code></code> | | <code title="&#91;&#10; &#34;artifactregistry.googleapis.com&#34;,&#10; &#34;cloudasset.googleapis.com&#34;,&#10; &#34;cloudbilling.googleapis.com&#34;,&#10; &#34;cloudbuild.googleapis.com&#34;,&#10; &#34;cloudresourcemanager.googleapis.com&#34;,&#10; &#34;cloudscheduler.googleapis.com&#34;,&#10; &#34;compute.googleapis.com&#34;,&#10; &#34;cloudfunctions.googleapis.com&#34;,&#10; &#34;iam.googleapis.com&#34;,&#10; &#34;iamcredentials.googleapis.com&#34;,&#10; &#34;logging.googleapis.com&#34;,&#10; &#34;monitoring.googleapis.com&#34;,&#10; &#34;run.googleapis.com&#34;,&#10; &#34;serviceusage.googleapis.com&#34;&#10;&#93;">&#91;&#8230;&#93;</code> |
96-
| [region](variables.tf#L75) | Region used to deploy the cloud functions and scheduler | <code></code> | | <code>europe-west1</code> |
97-
| [schedule_cron](variables.tf#L80) | Cron format schedule to run the Cloud Function. Default is every 10 minutes. | <code></code> | | <code>&#42;&#47;10 &#42; &#42; &#42; &#42;</code> |
99+
| [project_monitoring_services](variables.tf#L54) | Service APIs enabled in the monitoring project if it will be created. | <code></code> | | <code title="&#91;&#10; &#34;artifactregistry.googleapis.com&#34;,&#10; &#34;cloudasset.googleapis.com&#34;,&#10; &#34;cloudbilling.googleapis.com&#34;,&#10; &#34;cloudbuild.googleapis.com&#34;,&#10; &#34;cloudfunctions.googleapis.com&#34;,&#10; &#34;cloudresourcemanager.googleapis.com&#34;,&#10; &#34;cloudscheduler.googleapis.com&#34;,&#10; &#34;compute.googleapis.com&#34;,&#10; &#34;iam.googleapis.com&#34;,&#10; &#34;iamcredentials.googleapis.com&#34;,&#10; &#34;logging.googleapis.com&#34;,&#10; &#34;monitoring.googleapis.com&#34;,&#10; &#34;pubsub.googleapis.com&#34;,&#10; &#34;run.googleapis.com&#34;,&#10; &#34;servicenetworking.googleapis.com&#34;,&#10; &#34;serviceusage.googleapis.com&#34;,&#10; &#34;storage-component.googleapis.com&#34;&#10;&#93;">&#91;&#8230;&#93;</code> |
100+
| [region](variables.tf#L76) | Region used to deploy the cloud functions and scheduler | <code></code> | | <code>europe-west1</code> |
101+
| [schedule_cron](variables.tf#L81) | Cron format schedule to run the Cloud Function. Default is every 10 minutes. | <code></code> | | <code>&#42;&#47;10 &#42; &#42; &#42; &#42;</code> |
98102
99103
<!-- END TFDOC -->

blueprints/cloud-operations/network-dashboard/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ locals {
3030
module "project-monitoring" {
3131
count = var.monitoring_project_id == "" ? 1 : 0
3232
source = "../../../modules/project"
33-
name = "monitoring"
33+
name = "network-dashboards"
3434
parent = "organizations/${var.organization_id}"
3535
prefix = var.prefix
3636
billing_account = var.billing_account

blueprints/cloud-operations/network-dashboard/tests/variables.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ variable "project_vm_services" {
3636
"servicenetworking.googleapis.com",
3737
]
3838
}
39-
4039
variable "region" {
4140
description = "Region used to deploy subnets"
4241
default = "europe-west1"
@@ -45,4 +44,4 @@ variable "region" {
4544
variable "zone" {
4645
description = "Zone used to deploy vms"
4746
default = "europe-west1-b"
48-
}
47+
}

blueprints/cloud-operations/network-dashboard/variables.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ variable "monitoring_project_id" {
4343
default = ""
4444
}
4545

46-
4746
variable "organization_id" {
4847
description = "The organization id for the associated services"
4948
}
@@ -59,19 +58,21 @@ variable "project_monitoring_services" {
5958
"cloudasset.googleapis.com",
6059
"cloudbilling.googleapis.com",
6160
"cloudbuild.googleapis.com",
61+
"cloudfunctions.googleapis.com",
6262
"cloudresourcemanager.googleapis.com",
6363
"cloudscheduler.googleapis.com",
6464
"compute.googleapis.com",
65-
"cloudfunctions.googleapis.com",
6665
"iam.googleapis.com",
6766
"iamcredentials.googleapis.com",
6867
"logging.googleapis.com",
6968
"monitoring.googleapis.com",
69+
"pubsub.googleapis.com",
7070
"run.googleapis.com",
71-
"serviceusage.googleapis.com"
71+
"servicenetworking.googleapis.com",
72+
"serviceusage.googleapis.com",
73+
"storage-component.googleapis.com"
7274
]
7375
}
74-
7576
variable "region" {
7677
description = "Region used to deploy the cloud functions and scheduler"
7778
default = "europe-west1"

blueprints/networking/filtering-proxy-psc/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ module "project" {
2727
services = [
2828
"dns.googleapis.com",
2929
"compute.googleapis.com",
30-
"logging.googleapis.com"
30+
"logging.googleapis.com",
31+
"monitoring.googleapis.com"
3132
]
3233
}
3334

blueprints/networking/filtering-proxy-psc/squid.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ http_port 0.0.0.0:3128 require-proxy-header
44
# only proxy, don't cache
55
cache deny all
66

7+
# redirect all logs to /dev/stdout
8+
logfile_rotate 0
9+
cache_log stdio:/dev/stdout
10+
access_log stdio:/dev/stdout
11+
cache_store_log stdio:/dev/stdout
12+
13+
pid_filename /var/run/squid/squid.pid
14+
715
acl ssl_ports port 443
816
acl safe_ports port 80
917
acl safe_ports port 443

modules/cloud-config-container/squid/cloud-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ write_files:
6868
[Service]
6969
Environment="HOME=/home/squid"
7070
ExecStartPre=/usr/bin/docker-credential-gcr configure-docker
71-
ExecStart=/usr/bin/docker run --rm --name=squid \
71+
ExecStart=/usr/bin/docker run --rm --name=squid \
7272
--network host \
7373
-v /etc/squid:/etc/squid \
74-
gcr.io/pso-cft-fabric/squid:0.10
74+
gcr.io/pso-cft-fabric/squid:20221116
7575
ExecStop=/usr/bin/docker stop squid
7676
ExecStopPost=/usr/bin/docker rm squid
7777

modules/cloud-config-container/squid/docker/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ FROM debian:buster-slim
1717
ENV SQUID_VERSION=4.6 \
1818
SQUID_CACHE_DIR=/var/spool/squid \
1919
SQUID_LOG_DIR=/var/log/squid \
20+
SQUID_PID_DIR=/var/run/squid \
2021
SQUID_USER=proxy
2122

2223
RUN apt-get update \
@@ -26,5 +27,12 @@ RUN apt-get update \
2627
COPY entrypoint.sh /sbin/entrypoint.sh
2728
RUN chmod 755 /sbin/entrypoint.sh
2829

30+
# Create the PID file directory as root, as the non-privileged user squid is not
31+
# allowed to write in /var/run.
32+
RUN mkdir -p ${SQUID_PID_DIR} \
33+
&& chown ${SQUID_USER}:${SQUID_USER} ${SQUID_PID_DIR}
34+
35+
USER ${SQUID_USER}
36+
2937
EXPOSE 3128/tcp
3038
ENTRYPOINT ["/sbin/entrypoint.sh"]

modules/cloud-config-container/squid/docker/cloudbuild.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ steps:
2424
- .
2525

2626
substitutions:
27-
_IMAGE_VERSION: "20210215"
27+
_IMAGE_VERSION: "20221116"
2828
images:
2929
- "gcr.io/$PROJECT_ID/squid:${_IMAGE_VERSION}"
3030
- "gcr.io/$PROJECT_ID/squid:latest"

modules/cloud-config-container/squid/squid.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ http_port 0.0.0.0:3128
44
# only proxy, don't cache
55
cache deny all
66

7+
# redirect all logs to /dev/stdout
8+
logfile_rotate 0
9+
cache_log stdio:/dev/stdout
10+
access_log stdio:/dev/stdout
11+
cache_store_log stdio:/dev/stdout
12+
13+
pid_filename /var/run/squid/squid.pid
14+
715
acl ssl_ports port 443
816
acl safe_ports port 80
917
acl safe_ports port 443

0 commit comments

Comments
 (0)