blob: e81bdf2a9c8d06701ecb23b7e5ba35bdf26625d7 [file] [log] [blame]
Zack Williams794532a2021-03-18 17:38:36 -07001..
2 SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
3 SPDX-License-Identifier: Apache-2.0
4
5VPN Bootstrap
6=============
7
Hyunsun Moona703edf2021-07-29 15:55:15 -07008This section guides you through setting up a VPN connection between Aether Central in GCP and ACE.
9We will be using GitOps based Aether CI/CD system for this and all you need to do is to
10create a couple of patches to Aether GitOps repositories.
11Note that some of the steps described here are not directly related to setting up a VPN,
Zack Williams794532a2021-03-18 17:38:36 -070012but rather are a prerequisite for adding a new ACE.
13
Hyunsun Moona703edf2021-07-29 15:55:15 -070014Add deployment jobs
15-------------------
16First, you need to add Jenkins jobs to Aether CI/CD system that build and apply
17infrastructure change plans for the new edge. This is done by creating a patch to
18**aether-ci-management** repository.
Zack Williams794532a2021-03-18 17:38:36 -070019
Hyunsun Moona703edf2021-07-29 15:55:15 -070020Download **aether-ci-management** repository.
Zack Williams794532a2021-03-18 17:38:36 -070021
Hyunsun Moona703edf2021-07-29 15:55:15 -070022.. code-block:: shell
23
24 $ cd $WORKDIR
25 $ git clone "ssh://[username]@gerrit.opencord.org:29418/aether-ci-management"
26
27Add the jobs for the new cluster at the end of the `cd-pipeline-terraform-ace` project job list.
28Make sure to add both pre-merge and post-merge jobs.
29Note that the cluster name specified here will be used in the rest of the deployment procedure.
30
31.. code-block:: diff
32
33 $ cd $WORKDIR/aether-ci-management
34 $ vi jjb/repos/cd-pipeline-terraform.yaml
35
36 # Add jobs for the new cluster
37 diff jjb/repos/cd-pipeline-terraform.yamll
38 --- a/jjb/repos/cd-pipeline-terraform.yaml
39 +++ b/jjb/repos/cd-pipeline-terraform.yaml
40 @@ -227,3 +227,9 @@
41 - 'cd-pipeline-terraform-postmerge-cluster':
42 pod: 'production'
43 cluster: 'ace-eks'
44 + - 'cd-pipeline-terraform-premerge-cluster':
45 + pod: 'production'
46 + cluster: 'ace-test'
47 + - 'cd-pipeline-terraform-postmerge-cluster':
48 + pod: 'production'
49 + cluster: 'ace-test'
50
51Commit your change and wait for the jobs you just added available in Aether Jenkins.
52
53.. code-block:: shell
54
55 $ git status
56 Changes not staged for commit:
57
58 modified: jjb/repos/cd-pipeline-terraform.yaml
59
60 $ git add .
61 $ git commit -m "Add test ACE deployment job"
62 $ git review
63
64Gather VPN information
65----------------------
Zack Williams794532a2021-03-18 17:38:36 -070066
67* Make sure firewall in front of ACE allows UDP port 500, UDP port 4500, and
68 ESP packets from **gcpvpn1.infra.aetherproject.net(35.242.47.15)** and
69 **gcpvpn2.infra.aetherproject.net(34.104.68.78)**
70
71* Make sure that the external IP on ACE side is owned by or routed to the
72 management node
73
74To help your understanding, the following sample ACE environment will be used
75in the rest of this section. Make sure to replace the sample values when you
76actually create a review request.
77
78+-----------------------------+----------------------------------+
Hyunsun Moona703edf2021-07-29 15:55:15 -070079| Management node external IP | 66.201.42.222 |
Zack Williams794532a2021-03-18 17:38:36 -070080+-----------------------------+----------------------------------+
81| ASN | 65003 |
82+-----------------------------+----------------------------------+
83| GCP BGP IP address | Tunnel 1: 169.254.0.9/30 |
84| +----------------------------------+
85| | Tunnel 2: 169.254.1.9/30 |
86+-----------------------------+----------------------------------+
87| ACE BGP IP address | Tunnel 1: 169.254.0.10/30 |
88| +----------------------------------+
89| | Tunnel 2: 169.254.1.10/30 |
90+-----------------------------+----------------------------------+
91| PSK | UMAoZA7blv6gd3IaArDqgK2s0sDB8mlI |
92+-----------------------------+----------------------------------+
Hyunsun Moona703edf2021-07-29 15:55:15 -070093| Management Subnet | 10.32.4.0/24 |
Zack Williams794532a2021-03-18 17:38:36 -070094+-----------------------------+----------------------------------+
Hyunsun Moona703edf2021-07-29 15:55:15 -070095| K8S Subnet | Pod IP: 10.33.0.0/17 |
Zack Williams794532a2021-03-18 17:38:36 -070096| +----------------------------------+
Hyunsun Moona703edf2021-07-29 15:55:15 -070097| | Cluster IP: 10.33.128.0/17 |
Zack Williams794532a2021-03-18 17:38:36 -070098+-----------------------------+----------------------------------+
99
Hyunsun Moona703edf2021-07-29 15:55:15 -0700100.. note::
101 Use `this site <https://cloud.google.com/network-connectivity/docs/vpn/how-to/generating-pre-shared-key/>`_ to generate a new strong pre-shared key.
Zack Williams794532a2021-03-18 17:38:36 -0700102
Hyunsun Moona703edf2021-07-29 15:55:15 -0700103.. attention::
Zack Williams794532a2021-03-18 17:38:36 -0700104
Hyunsun Moona703edf2021-07-29 15:55:15 -0700105 If you are adding another ACE to an existing VPN connection, go to
106 :ref:`Add ACE to an existing VPN connection <add_ace_to_vpn>`
Zack Williams794532a2021-03-18 17:38:36 -0700107
Andy Bavier802cce52021-07-29 12:15:15 -0700108Get access to encrypted files in aether-pod-configs repository
109--------------------------------------------------------------
110
111`git-crypt <https://github.com/AGWA/git-crypt>` is used to securely store encrypted files
112in the aether-pod-configs repository. Before proceeding, (1) install git-crypt and `gpg <https://gnupg.org/>`,
113(2) create a GPG keypair, and (3) ask a member of the Aether OPs team add your public key
114to the aether-pod-configs keyring. To create the keypair follow these steps:
115
116.. code-block:: shell
117
118 $ gpg --full-generate-key
119 $ gpg --output <key-name>.gpg --armor --export <your-email-address>
120
Zack Williams794532a2021-03-18 17:38:36 -0700121.. _update_global_resource:
122
123Update global resource maps
124---------------------------
125
Hyunsun Moona703edf2021-07-29 15:55:15 -0700126Download aether-pod-configs repository.
127
128.. code-block:: shell
129
130 $ cd $WORKDIR
131 $ git clone "ssh://[username]@gerrit.opencord.org:29418/aether-pod-configs"
Andy Bavier802cce52021-07-29 12:15:15 -0700132 $ git-crypt unlock
Hyunsun Moona703edf2021-07-29 15:55:15 -0700133
Zack Williams794532a2021-03-18 17:38:36 -0700134Add a new ACE information at the end of the following global resource maps.
135
136* ``user_map.tfvars``
137* ``cluster_map.tfvars``
138* ``vpn_map.tfvars``
139
140As a note, you can find several other global resource maps under the
Hyunsun Moona703edf2021-07-29 15:55:15 -0700141``production`` directory. Resource definitions that need to be shared among
Zack Williams794532a2021-03-18 17:38:36 -0700142clusters or are better managed in a single file to avoid configuration
143conflicts are maintained in this way.
144
145.. code-block:: diff
146
147 $ cd $WORKDIR/aether-pod-configs/production
148 $ vi user_map.tfvars
149
150 # Add the new cluster admin user at the end of the map
151 $ git diff user_map.tfvars
152 --- a/production/user_map.tfvars
153 +++ b/production/user_map.tfvars
154 @@ user_map = {
155 username = "menlo"
156 password = "changeme"
157 global_roles = ["user-base", "catalogs-use"]
158 + },
159 + test_admin = {
160 + username = "test"
161 + password = "changeme"
162 + global_roles = ["user-base", "catalogs-use"]
163 }
164 }
165
166.. code-block:: diff
167
168 $ cd $WORKDIR/aether-pod-configs/production
169 $ vi cluster_map.tfvars
170
171 # Add the new K8S cluster information at the end of the map
172 $ git diff cluster_map.tfvars
173 --- a/production/cluster_map.tfvars
174 +++ b/production/cluster_map.tfvars
175 @@ cluster_map = {
176 kube_dns_cluster_ip = "10.53.128.10"
177 cluster_domain = "prd.menlo.aetherproject.net"
178 calico_ip_detect_method = "can-reach=www.google.com"
179 + },
180 + ace-test = {
181 + cluster_name = "ace-test"
Hyunsun Moona703edf2021-07-29 15:55:15 -0700182 + management_subnets = ["10.32.4.0/24"]
Zack Williams794532a2021-03-18 17:38:36 -0700183 + k8s_version = "v1.18.8-rancher1-1"
Hyunsun Moona703edf2021-07-29 15:55:15 -0700184 + k8s_pod_range = "10.33.0.0/17"
185 + k8s_cluster_ip_range = "10.33.128.0/17"
186 + kube_dns_cluster_ip = "10.33.128.10"
Zack Williams794532a2021-03-18 17:38:36 -0700187 + cluster_domain = "prd.test.aetherproject.net"
188 + calico_ip_detect_method = "can-reach=www.google.com"
189 }
190 }
191 }
192
193.. code-block:: diff
194
195 $ cd $WORKDIR/aether-pod-configs/production
196 $ vi vpn_map.tfvars
197
198 # Add VPN and tunnel information at the end of the map
199 $ git diff vpn_map.tfvars
200 --- a/production/vpn_map.tfvars
201 +++ b/production/vpn_map.tfvars
202 @@ vpn_map = {
203 bgp_peer_ip_address_1 = "169.254.0.6"
204 bgp_peer_ip_range_2 = "169.254.1.5/30"
205 bgp_peer_ip_address_2 = "169.254.1.6"
206 + },
207 + ace-test = {
208 + peer_name = "production-ace-test"
Hyunsun Moona703edf2021-07-29 15:55:15 -0700209 + peer_vpn_gateway_address = "66.201.42.222"
Zack Williams794532a2021-03-18 17:38:36 -0700210 + tunnel_shared_secret = "UMAoZA7blv6gd3IaArDqgK2s0sDB8mlI"
211 + bgp_peer_asn = "65003"
212 + bgp_peer_ip_range_1 = "169.254.0.9/30"
213 + bgp_peer_ip_address_1 = "169.254.0.10"
214 + bgp_peer_ip_range_2 = "169.254.1.9/30"
215 + bgp_peer_ip_address_2 = "169.254.1.10"
216 }
217 }
218
219.. note::
220 Unless you have a specific requirement, set ASN and BGP addresses to the next available values in the map.
221
222
223Create ACE specific configurations
224----------------------------------
225
226In this step, we will create a directory under `production` with the same name
227as ACE, and add several Terraform configurations and Ansible inventory needed
228to configure a VPN connection.
Zack Williams794532a2021-03-18 17:38:36 -0700229Throughout the deployment procedure, this directory will contain all ACE
230specific configurations.
231
232Run the following commands to auto-generate necessary files under the target
233ACE directory.
234
235.. code-block:: shell
236
237 $ cd $WORKDIR/aether-pod-configs/tools
Hyunsun Moona703edf2021-07-29 15:55:15 -0700238 $ cp ace_config.yaml.example ace_config.yaml
239 $ vi ace_config.yaml
240 # Set all values
Zack Williams794532a2021-03-18 17:38:36 -0700241
Zack Williams794532a2021-03-18 17:38:36 -0700242 $ make vpn
243 Created ../production/ace-test
244 Created ../production/ace-test/main.tf
245 Created ../production/ace-test/variables.tf
246 Created ../production/ace-test/gcp_fw.tf
247 Created ../production/ace-test/gcp_ha_vpn.tf
248 Created ../production/ace-test/ansible
249 Created ../production/ace-test/backend.tf
250 Created ../production/ace-test/cluster_val.tfvars
251 Created ../production/ace-test/ansible/hosts.ini
252 Created ../production/ace-test/ansible/extra_vars.yml
253
Zack Williams794532a2021-03-18 17:38:36 -0700254
Hyunsun Moona703edf2021-07-29 15:55:15 -0700255Commit your change
256------------------
Zack Williams794532a2021-03-18 17:38:36 -0700257
258.. code-block:: shell
259
260 $ cd $WORKDIR/aether-pod-configs/production
261 $ git status
262 On branch tools
263 Changes not staged for commit:
264
265 modified: cluster_map.tfvars
266 modified: user_map.tfvars
267 modified: vpn_map.tfvars
268
269 Untracked files:
270 (use "git add <file>..." to include in what will be committed)
271
272 ace-test/
273
274 $ git add .
275 $ git commit -m "Add test ACE"
276 $ git review
277
278Once the review request is accepted and merged,
Hyunsun Moona703edf2021-07-29 15:55:15 -0700279the post-merge job will create VPN tunnels on both GCP and the management node.
Zack Williams794532a2021-03-18 17:38:36 -0700280
281Verify VPN connection
282---------------------
283
284You can verify the VPN connections after successful post-merge job by checking
285the routing table on the management node and trying to ping to one of the
286central cluster VMs.
287
288Make sure two tunnel interfaces, `gcp_tunnel1` and `gcp_tunnel2`, exist
289and three additional routing entries via one of the tunnel interfaces.
290
291.. code-block:: shell
292
293 # Verify routings
294 $ netstat -rn
295 Kernel IP routing table
296 Destination Gateway Genmask Flags MSS Window irtt Iface
Hyunsun Moona703edf2021-07-29 15:55:15 -0700297 0.0.0.0 66.201.42.209 0.0.0.0 UG 0 0 0 eno1
298 10.32.4.0 0.0.0.0 255.255.255.128 U 0 0 0 eno2
299 10.32.4.128 0.0.0.0 255.255.255.128 U 0 0 0 mgmt800
Zack Williams794532a2021-03-18 17:38:36 -0700300 10.45.128.0 169.254.0.9 255.255.128.0 UG 0 0 0 gcp_tunnel1
301 10.52.128.0 169.254.0.9 255.255.128.0 UG 0 0 0 gcp_tunnel1
Hyunsun Moona703edf2021-07-29 15:55:15 -0700302 10.33.128.0 10.32.4.138 255.255.128.0 UG 0 0 0 mgmt800
Zack Williams794532a2021-03-18 17:38:36 -0700303 10.168.0.0 169.254.0.9 255.255.240.0 UG 0 0 0 gcp_tunnel1
Hyunsun Moona703edf2021-07-29 15:55:15 -0700304 66.201.42.208 0.0.0.0 255.255.252.0 U 0 0 0 eno1
Zack Williams794532a2021-03-18 17:38:36 -0700305 169.254.0.8 0.0.0.0 255.255.255.252 U 0 0 0 gcp_tunnel1
306 169.254.1.8 0.0.0.0 255.255.255.252 U 0 0 0 gcp_tunnel2
307
308 # Verify ACC VM access
309 $ ping 10.168.0.6
310
Hyunsun Moona703edf2021-07-29 15:55:15 -0700311 # Verify ACC K8S Service access
Zack Williams794532a2021-03-18 17:38:36 -0700312 $ nslookup kube-dns.kube-system.svc.prd.acc.gcp.aetherproject.net 10.52.128.10
313
314You can further verify whether the ACE routes are propagated well to GCP
315by checking GCP dashboard **VPC Network > Routes > Dynamic**.
316
317
318Post VPN setup
319--------------
320
321Once you verify the VPN connections, please update `ansible` directory name to
322`_ansible` to prevent the ansible playbook from running again. Note that it is
323no harm to re-run the ansible playbook but not recommended.
324
325.. code-block:: shell
326
327 $ cd $WORKDIR/aether-pod-configs/production/$ACE_NAME
328 $ mv ansible _ansible
329 $ git add .
Hyunsun Moona703edf2021-07-29 15:55:15 -0700330 $ git commit -m "Ansible done for test ACE"
Zack Williams794532a2021-03-18 17:38:36 -0700331 $ git review
332
333.. _add_ace_to_vpn:
334
335Add another ACE to an existing VPN connection
336"""""""""""""""""""""""""""""""""""""""""""""
337
338VPN connections can be shared when there are multiple ACE clusters in a site.
339In order to add ACE to an existing VPN connection, you'll have to SSH into the
340management node and manually update BIRD configuration.
341
342.. note::
343
344 This step needs improvements in the future.
345
346.. code-block:: shell
347
348 $ sudo vi /etc/bird/bird.conf
349 protocol static {
Hyunsun Moona703edf2021-07-29 15:55:15 -0700350 # Routings for the existing cluster
Zack Williams794532a2021-03-18 17:38:36 -0700351 ...
Hyunsun Moona703edf2021-07-29 15:55:15 -0700352 route 10.33.128.0/17 via 10.32.4.138;
Zack Williams794532a2021-03-18 17:38:36 -0700353
354 # Add routings for the new ACE's K8S cluster IP range via cluster nodes
355 # TODO: Configure iBGP peering with Calico nodes and dynamically learn these routings
356 route <NEW-ACE-CLUSTER-IP> via <SERVER1>
357 route <NEW-ACE-CLUSTER-IP> via <SERVER2>
358 route <NEW-ACE-CLUSTER-IP> via <SERVER3>
359 }
360
361 filter gcp_tunnel_out {
362 # Add the new ACE's K8S cluster IP range and the management subnet if required to the list
Hyunsun Moona703edf2021-07-29 15:55:15 -0700363 if (net ~ [ 10.32.4.0/24, 10.33.128.0/17, <NEW-ACE-CLUSTER-MGMT-SUBNET>, <NEW-ACE-CLUSTER-IP-RANGE> ]) then accept;
Zack Williams794532a2021-03-18 17:38:36 -0700364 else reject;
365 }
366 # Save and exit
367
368 $ sudo birdc configure
369
370 # Confirm the static routes are added
371 $ sudo birdc show route
372