julz / cube

a kube backend for cf, because k-why not
21 stars 8 forks source link

LRPs in k8s Spike Option 3 from previous Spike #34

Open andrew-edgar opened 6 years ago

andrew-edgar commented 6 years ago

See previous spike and try out option 3 from story #30

mnitchev commented 6 years ago

Update on the spike

TL; DR

Looks like the changes should be fairly straightforward for the purposes of the spike. [UPDATE] We have made the changes to CC and Eirini locally but need to test them since they probably (most definitely) will break something. We still need an environment where we can deploy CC and Eirini so we can test.

Challenges

LRPs in K8s:

To complete the story k8s/list.go needs to be implemented together with an lrp handler. [UPDATE] It was easier to actually have a List method in Desirer since it already has a kube client set up. For start endpoint Desirer should be used. Listing kube deployments is pretty simple. The following is all we need (excluding mapping kube Deployment to LRP):

client.AppsV1beta1().Deployments(namespace).List(av1.ListOptions{})

Using process (from CC) in our api

Implementing the OPI Client

def stop_index(process_guid, index) #probably safe to ignore this one for now, only used in messenger

* [***UPDATE***] the method `fetch_scheduling_infos` returns `Bbs::Models::DesiredLRPSchedulingInfosResponse` in its body, which contains several other nested objects. Fortunately it does seem like only one field is used — `process_guid` in `::Diego::Bbs::Models::DesiredLRPKey` which should be the name of the K8s Deployment. So our endpoint should return a json similar to the following one: 
```json
{
    "desired_lrp_scheduling_infos": [
        {
            "desired_lrp_key": {
                "process_guid": "deployment_guid_1"
            }
        },
        {
            "desired_lrp_key": {
                "process_guid": "deployment_guid_2"
            }
        }
    ]
}

Changes that need to be discussed for the real implementation

  1. We should keep both Diego and OPI as options in the DependencyLocator, so maybe we should use a FeatureFlag for determening which one to use? The bits service does something similar.
  2. Replacing Diego::Client or each of the BBS Clients are the two options. In the long run maybe a middle ground would be best, since we want to properly abstract scheduling and there are Diego specific dependencies that have to be removed in both approaches. For now though doing a proper implementation of the above OPI Client should be enough to complete the next stories.
  3. Since we control the CC Client we are free to do whatever we need with the Eirini LRP API, so we should decide what it will look like.