Skip to content

Commit 13c7aa2

Browse files
jimrightJeremy Wietrzykowski
andauthored
Update GCP for L2 networking deployment (#115)
* Add changes for GCP L2 (private/private) deployment Co-authored-by: Jeremy Wietrzykowski <jeremyw@cloudera.com> Co-authored-by: Jim Enright <jenright@cloudera.com> Signed-off-by: Jim Enright <jenright@cloudera.com>
1 parent f47c8d3 commit 13c7aa2

File tree

6 files changed

+76
-2
lines changed

6 files changed

+76
-2
lines changed

roles/common/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ common__datalake_name: "{{ env.datalake.name | default([commo
149149
common__datalake_name_suffix: "{{ env.datalake.suffix | default(common__datalake_suffix) }}"
150150
common__tunnel: "{{ env.tunnel | default(False) }}"
151151
common__public_endpoint_access: "{{ env.public_endpoint_access | default(not common__tunnel) }}"
152+
common__use_public_ip: "{{ env.public_endpoint_access | default(not common__tunnel) }}"
152153

153154
common__env_admin_password: "{{ globals.admin_password | mandatory }}"
154155
common__aws_policy_urls_default_root: "https://raw.githubusercontent.com/hortonworks/cloudbreak/master/cloud-aws-common/src/main/resources/definitions/cdp"

roles/infrastructure/defaults/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ infra__gcp_project: "{{ common__gcp_project }}"
134134
infra__gcp_storage_location_data: "{{ infra.gcp.storage.path.data | default([infra__storage_name, infra__data_path] | join('-')) }}"
135135
infra__gcp_storage_location_logs: "{{ infra.gcp.storage.path.logs | default([infra__storage_name, infra__logs_path] | join('-')) }}"
136136

137+
infra__gcp_cloud_router_name_suffix: "{{ infra.gcp.network.router.name_suffix | default('router') }}"
138+
infra__gcp_cloud_router_name: "{{ infra.gcp.network.router.name | default([infra__namespace, infra__gcp_cloud_router_name_suffix] | join('-')) }}"
139+
infra__gcp_cloud_router_asn: "{{ infra.gcp.network.router.asn | default(64514) }}"
140+
141+
infra__gcp_cloud_nat_name_suffix: "{{ infra.gcp.network.nat.name_suffix | default('nat') }}"
142+
infra__gcp_cloud_nat_name: "{{ infra.gcp.network.nat.name | default([infra__namespace, infra__gcp_cloud_nat_name_suffix] | join('-')) }}"
143+
137144
# Azure
138145
infra__azure_metagroup_name: "{{ common__azure_metagroup_name }}"
139146

roles/infrastructure/tasks/setup_gcp_network.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,43 @@
7373
--project={{ infra__gcp_project }}
7474
--network={{ infra__vpc_name }}
7575
--service=servicenetworking.googleapis.com
76-
--ranges={{ infra__vpc_svcnet_name }}
76+
--ranges={{ infra__vpc_svcnet_name }}
77+
78+
# Cloud Router and Cloud NAT for L2 networking
79+
- name: Create a Cloud Router
80+
when:
81+
- infra__tunnel
82+
- not infra__public_endpoint_access
83+
google.cloud.gcp_compute_router:
84+
name: "{{ infra__gcp_cloud_router_name }}"
85+
network: "{{ __gcp_vpc_info }}"
86+
bgp:
87+
asn: "{{ infra__gcp_cloud_router_asn }}"
88+
advertise_mode: DEFAULT
89+
region: "{{ infra__region }}"
90+
project: "{{ infra__gcp_project }}"
91+
state: present
92+
93+
- name: Discover Cloud NAT and Create if required
94+
when:
95+
- infra__tunnel
96+
- not infra__public_endpoint_access
97+
block:
98+
- name: Discover Cloud NAT
99+
ansible.builtin.command: >
100+
gcloud compute routers nats describe {{ infra__gcp_cloud_nat_name }}
101+
--router={{ infra__gcp_cloud_router_name }}
102+
--router-region={{ infra__region }}
103+
ignore_errors: true
104+
register: __gcp_nat_discovered
105+
106+
- name: Create Cloud NAT if not discovered
107+
when:
108+
- __gcp_nat_discovered is failed
109+
ansible.builtin.command: >
110+
gcloud compute routers nats create {{ infra__gcp_cloud_nat_name }}
111+
--router={{ infra__gcp_cloud_router_name }}
112+
--router-region={{ infra__region }}
113+
--auto-allocate-nat-external-ips
114+
--nat-all-subnet-ip-ranges
115+
--enable-logging

roles/infrastructure/tasks/teardown_gcp_network.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,32 @@
3232
name: "{{ infra__security_group_default_name }}"
3333
state: absent
3434

35+
- name: Discover Cloud NAT and Delete if required
36+
block:
37+
- name: Delete Cloud NAT
38+
ansible.builtin.command: >
39+
gcloud compute routers nats describe {{ infra__gcp_cloud_nat_name }}
40+
--router={{ infra__gcp_cloud_router_name }}
41+
--router-region={{ infra__region }}
42+
ignore_errors: true
43+
register: __gcp_nat_discovered
44+
45+
- name: Delete Cloud NAT if discovered
46+
when:
47+
- __gcp_nat_discovered is succeeded
48+
ansible.builtin.command: >
49+
gcloud compute routers nats delete {{ infra__gcp_cloud_nat_name }}
50+
--router={{ infra__gcp_cloud_router_name }}
51+
--router-region={{ infra__region }}
52+
53+
- name: Delete a Cloud Router
54+
google.cloud.gcp_compute_router:
55+
name: "{{ infra__gcp_cloud_router_name }}"
56+
network: "{{ __gcp_vpc_info }}"
57+
region: "{{ infra__region }}"
58+
project: "{{ infra__gcp_project }}"
59+
state: absent
60+
3561
- name: Remove GCP VPC Subnets
3662
google.cloud.gcp_compute_subnetwork:
3763
region: "{{ infra__region }}"

roles/platform/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ plat__workload_analytics: "{{ env.workload_analytics | defau
7878
plat__tunnel: "{{ common__tunnel }}"
7979
plat__public_endpoint_access: "{{ common__public_endpoint_access }}"
8080
plat__enable_raz: "{{ env.datalake.enable_raz | default(False) }}"
81+
plat__use_public_ip: "{{ common__use_public_ip }}"
8182

8283
plat__env_admin_password: "{{ common__env_admin_password }}"
8384

roles/platform/tasks/setup_gcp_env.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
cloud: "{{ plat__infra_type }}"
2323
region: "{{ plat__region }}"
2424
public_key_text: "{{ plat__public_key_text }}"
25-
public_ip: yes
25+
public_ip: "{{ plat__use_public_ip }}"
2626
log_location: "gs://{{ plat__gcp_storage_location_logs }}"
2727
log_identity: "{{ plat__gcp_log_identity_name }}@{{ plat__gcp_project }}.iam.gserviceaccount.com"
2828
vpc_id: "{{ plat__vpc_name }}"

0 commit comments

Comments
 (0)