|
| 1 | + |
| 2 | +# Upstream Services Migrating from OCP3 to OCP4 |
| 3 | + |
| 4 | +## What do I need to do to setup my Service on the new APS Gateway? |
| 5 | + |
| 6 | +### Configure the APS Gateway |
| 7 | + |
| 8 | +As part of migrating your service to OCP4, you will need to prepare the Gateway configuration for your Service. An example of what it would look like: |
| 9 | + |
| 10 | +``` |
| 11 | +services: |
| 12 | +- host: <my_ocp4_service>.<my_ocp4_namespace>.svc |
| 13 | + name: <my_ocp4_service> |
| 14 | + port: 80 |
| 15 | + protocol: http |
| 16 | +``` |
| 17 | + |
| 18 | +The routes will have a minor change by no longer using the `https` protocol as SSL termination will be performed at the `OCP4 Edge` and the traffic to the `APS Gateway` will be unencrypted: |
| 19 | + |
| 20 | +``` |
| 21 | +services: |
| 22 | +- host: <my_ocp4_service>.<my_ocp4_namespace>.svc |
| 23 | + name: <my_ocp4_service> |
| 24 | + port: 80 |
| 25 | + protocol: http |
| 26 | + routes: |
| 27 | + - name: <my_ocp4_service>-route-get |
| 28 | + hosts: |
| 29 | + - kirk.data.gov.bc.ca |
| 30 | + protocols: |
| 31 | + - http |
| 32 | + methods: |
| 33 | + - GET |
| 34 | + paths: |
| 35 | + - "/" |
| 36 | +``` |
| 37 | + |
| 38 | +The appropriate `tags` need to be added and optionally any `plugins` added. |
| 39 | + |
| 40 | +Apply your changes to the `APS Gateway` by running the `gwa pg` command (see the [API Provider Flow](/USER-JOURNEY.md) for detailed instructions). |
| 41 | + |
| 42 | +### Add the NetworkSecurityPolicy (NSP) |
| 43 | + |
| 44 | +The `APS Gateway` needs to be able to route to your service from within the OCP4 cluster. To do this, add the following NSP to your OCP4 namespace (update the destination label matching based on your Pod labels): |
| 45 | + |
| 46 | +``` |
| 47 | +kind: NetworkSecurityPolicy |
| 48 | +apiVersion: security.devops.gov.bc.ca/v1alpha1 |
| 49 | +metadata: |
| 50 | + name: aps-gateway-to-your-upstream-api |
| 51 | +spec: |
| 52 | + description: | |
| 53 | + allow the aps gateway to route traffic to your api |
| 54 | + source: |
| 55 | + - - $namespace=264e6f-test |
| 56 | + - - $namespace=264e6f-prod |
| 57 | + destination: |
| 58 | + - - app.kubernetes.io/name=my-upstream-api |
| 59 | +``` |
| 60 | + |
| 61 | +### Remove all Routes/Ingress |
| 62 | + |
| 63 | +In `OCP3` you most likely had routes for `*.api`, `*.data` or `*.apps`. For `OCP4` your `Pod Service` does not need to have an external route because the `APS Gateway` is acting as the entry point for your service. |
| 64 | + |
| 65 | +You should ensure that you do not have any routes that have the host as `*.api.gov.bc.ca`, `*.data.gov.bc.ca`, or `*.apps.gov.bc.ca`. Having routes with these hosts will conflict with the routes that the `APS Gateway` will create automatically based on your configuration. It is ok to create routes under the `.apps.silver.devops.gov.bc.ca` domain for dev and testing. |
| 66 | + |
| 67 | +### Regression test your Service |
| 68 | + |
| 69 | +Regression testing is being performed in the `APS Gateway` test environment. When you apply your changes in the test environment, your routing URLs are transformed into a custom vanity domain. |
| 70 | + |
| 71 | +For example, a route for `kirk.data.gov.bc.ca` results in a public route: |
| 72 | + |
| 73 | +`https://kirk-data-gov-bc-ca.test.apsgw.xyz` |
| 74 | + |
| 75 | +This is what you will use to peform your regression testing. To find out the exact public route for your services, go to the `Services` tab on the `APS Services Portal`. |
| 76 | + |
| 77 | + |
| 78 | +### Switch production traffic to your OCP4 Service |
| 79 | + |
| 80 | +**APS Gateway Production Setup** |
| 81 | + |
| 82 | +When the Production instance of the `APS Gateway` is ready, communication will go out to API Owners as additional tasks will be required to enable the service on our Production environment: |
| 83 | + |
| 84 | +| Task | Responsibility | |
| 85 | +| -------------------------------------------------------- | -------------- | |
| 86 | +| Create namespace and service account on the `APS Gateway` production instance | API Owner | |
| 87 | +| Apply your dev/test/prod Gateway configuration (either in your CI/CD pipeline or manually) | API Owner | |
| 88 | +| Update `Kong14` Service upstream host from `https://142.34.143.180` to `https://142.34.194.118` | APS Team |
| 89 | +| Decommission your OCP3 projects | API Owner | |
| 90 | + |
| 91 | +### Final big-bang switchover |
| 92 | + |
| 93 | +At the completion of regression testing, a big-bang switchover to the new APS Gateway will be performed by updating the DNS to point to the `OCP4 Edge`. |
| 94 | + |
| 95 | +| Task | Responsibility | |
| 96 | +| -------------------------------------------------------- | -------------- | |
| 97 | +| Ownership of the Gateway configuration transitioned to Service teams | API Owners |
| 98 | +| Regression testing of services complete | API Owners |
| 99 | +| APS Gateway Production Setup completed | API Owners |
| 100 | +| **Switchover** Update DNS for *.api.gov.bc.ca, *.data.gov.bc.ca to point to 142.34.194.118 | APS Team | |
| 101 | + |
| 102 | + |
| 103 | +At the time of switchover, we expect that there will be a mix of upstream services running on OCP3, running on OCP4, running on DataBC Servers and running on external cloud. But the expectation is that all the teams will have ownership of the Gateway configuration for their respective Services, and empowered to do ongoing changes. |
| 104 | + |
| 105 | + |
| 106 | +# Appendix |
| 107 | + |
| 108 | +## Terminology |
| 109 | + |
| 110 | +* `WAM` : Web Application Management |
| 111 | +* `Kong14` : The current Kong 0.14 implementation run on Data BC infrastructure (142.34.140.8, 142.34.5.17) |
| 112 | +* `APS Gateway` : The new Kong 2.1.x implementation run on Openshift Container Platform V4 (OCP4) |
| 113 | +* `OCP3 Edge` : The OCP3 Edge server (142.34.208.209, more known as *.pathfinder.gov.bc.ca, or 142.34.143.180, more known as *.pathfinder.bcgov) |
| 114 | +* `OCP4 Edge` : The OCP4 Edge server (142.34.194.118), more known as *.apps.silver.devops.gov.bc.ca) |
| 115 | +* `Pod Service` : The actual Kubernetes Service that is run within your Pod (`oc get services`) |
| 116 | +* `OCP3 Route` : A Route on the OCP3 Edge that is the relationship between your Pod Service and the OCP3 Edge |
| 117 | + |
| 118 | +## How it works currently |
| 119 | + |
| 120 | +Current (Oct 2020) flow for `*.api.gov.bc.ca` and `*.data.gov.bc.ca` domains where the upstream is on OCP3, is: |
| 121 | + |
| 122 | +`Internet` -> `Kong14` -> `OCP3 Edge` -> `Pod Service` |
| 123 | + |
| 124 | +On `Kong14`, a Service example looks something like this and is administered via email to David or Craig, and they use Konga: |
| 125 | + |
| 126 | +``` |
| 127 | +services: |
| 128 | +- host: 142.34.143.180 |
| 129 | + name: apidata-ocp-https-kirk-jobs |
| 130 | + port: 443 |
| 131 | + protocol: https |
| 132 | +``` |
| 133 | + |
| 134 | +With the route: |
| 135 | + |
| 136 | +``` |
| 137 | + routes: |
| 138 | + - hosts: |
| 139 | + - kirk.data.gov.bc.ca |
| 140 | + protocols: |
| 141 | + - http |
| 142 | + - https |
| 143 | +``` |
| 144 | + |
| 145 | +The `kirk` team is then responsible for creating an `OCP3 Route` and the `Pod Service`. |
| 146 | + |
0 commit comments