Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for dataclass annotations on routes created with kube api #118

Closed
ikethecoder opened this issue Aug 8, 2024 · 9 comments
Closed
Labels

Comments

@ikethecoder
Copy link
Member

The kube-api is responsible for any custom provisioning based on the infrastructure that Kong data planes are deployed to. For BC Government Emerald Openshift cluster, there is a requirement to annotation the DataClass based on the sensitivity of the data being passed through the endpoint.

This ticket is the work on the kube-api to provide a way of specifying a DataClass on a Kong Route and then have the appropriate annotation be applied on the Route resource in Openshift.

@ikethecoder
Copy link
Member Author

Similar to how #112 worked, have a custom annotation that will specify the desired DataClass:

services:
- name: my-service
  routes:
  - name: my-route
    tags: [ ns.NS, aps.route.dataclass.medium ]

With valid values: aps.route.dataclass=low aps.route.dataclass=medium and aps.route.dataclass=high

The kube-api will then use the information to add the appropriate annotation on the Route.

@rustyjux
Copy link
Contributor

Requirements

  • k8s route needs this annotation with this format:
    aviinfrasetting.ako.vmware.com/name: dataclass-medium
    

Implementation

Tests

  • adding a data class / removing a dataclass
  • changing between data classes

@rustyjux
Copy link
Contributor

rustyjux commented Nov 4, 2024

There is actually no need for dataclass=low since that is the default for all routes in Emerald. Users can add it, but we need not apply anything.

This is potentially a need for dataclass=public however - see https://digital.gov.bc.ca/cloud/services/private/internal-resources/emerald/#:~:text=How%20to%20assign%20security%20classifications%20to%20routes:

...For routes, you use “aviinfrasetting.ako.vmware.com/name” and assign it a value from one of the following: “dataclass-medium”, “dataclass-high” or “dataclass-public”.

For the route Security Classification, all settings result in a private IP address that cannot be accessed from the Internet. If internet access is required, then add the annotation with a value of “dataclass-public”.

The default “apps.emerald.devops.gov.bc.ca” subdomain cannot be resolved by DNS from the public internet, so public routes will need to use a vanity domain and dedicated TLS certificates to be accessible from the internet.

@ikethecoder, we'll be able to support this?

@ikethecoder
Copy link
Member Author

ikethecoder commented Nov 4, 2024

I would say we still allow dataclass=low as it helps with the validation on the gateway API to enforce a dataclass selection for gateways on Emerald. Not sure about dataclass=public - maybe exclude it for now, and wait for a need so we understand why this type of need is there. But even if we add it, it shouldn't be an issue to support it.

If low and public are equivalent, then in this case, we can include dataclass=public together with dataclass=medium and dataclass=high as valid values.

@rustyjux
Copy link
Contributor

rustyjux commented Nov 4, 2024

Docs read to me like public is not equivalent to low:

  • low is the default and results in a private IP. No need to specify on routes in Emerald (unlike pods). We can ask for it but don't need to do anything with it.
  • public is a valid value to annotate on a route (alongside medium and `high) and results in a public IP which could be accessed from the public internet given a vanity domain (we already do that?) and TLS certs (do we do that?)

@ikethecoder
Copy link
Member Author

Ok.. yes we support vanity domain and TLS certs for all the data classes so no issue there.

@rustyjux
Copy link
Contributor

rustyjux commented Nov 5, 2024

Manual validation in dev:

  • create a new service w/o data class
    • add data class tag on service ✅
    • add another route to the service - it gets annotated too ✅
    • remove tag - annotations removed ✅
  • create a new service w/ data class tag on only one route ✅
    • add a different data class tag on another route in same service - each route has its own data class ✅
    • put a conflicting data class tag on service - tags with later alphabetical order take precedence (ie medium overrides low, public overrides medium) 🤷‍♀️ - does this matter? not really an expected use
    • remove route-level tags - service-level tag is applied ✅

To fix:

  • gwa scheduler (key error on dataClass)

To validate:

  • Emerald

@rustyjux
Copy link
Contributor

rustyjux commented Nov 5, 2024

@ikethecoder hit a roadblock here -
When routes are synced with gwa-scheduler, they do not include the data class because the source_routes from Kong Admin API (get_routes()) don't include data class in the tags included with each route. Why not? gatewayApi does not add this tag to the Kong route, only the service.
Only when making the PUT call to the gatewayApi do we have get_route_overrides() and eval_services() which this is passed to kubeApi.

Possible solutions I can imagine:

  1. Add another enrichment to apply the tags down onto routes in Kong? https://github.com/bcgov/gwa-api/blob/feature/dataclass-annotation/microservices/gatewayApi/v2/routes/gateway.py#L235 (and have the aps.route.dataclass tag on services override any route tags in the config)
  2. Add a step to gwa-scheduler to get info on services from Kong Admin API
  3. Require Gold/DR users to tag on the route level

Or can you think of a simpler solution to support syncing data classes in gwa-scheduler?
I think I am going to implement the first solution.

@rustyjux
Copy link
Contributor

rustyjux commented Nov 5, 2024

lol after adding this I realized it doesn't even matter... gold wont be using data class so as long as there aren't errors really it's fine.
Added in 863ba9c

@rustyjux rustyjux closed this as completed Nov 7, 2024
@rustyjux rustyjux changed the title support for custom annotations on routes creates with kube api support for dataclass annotations on routes creates with kube api Nov 14, 2024
@rustyjux rustyjux changed the title support for dataclass annotations on routes creates with kube api support for dataclass annotations on routes created with kube api Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants