Giter Club home page Giter Club logo

Comments (2)

NomadXD avatar NomadXD commented on May 18, 2024

Overview

Dataplane CRs like APIs, HttpRoutes and Policies are stored in the etcd key value storage in the Kubernetes API server. The main goal of this APK Agent is to reconcile the Dataplane CRs, validate and configure the corresponding Choreo connect router instance through xDS.

Design

adapter-apk-agent-final drawio

Controller go routine contains the controllers for the CRs like API, HttpRoute, Policy and runs reconcile loops based on the state of the cache and Kubernetes API server state.

APIController is the parent controller and watches for any changes happening to APIs and HttpRoutes.
HttpRouteController watches for HttpRoutes, Backends (Services) and Policies.
PolicyController watches for Policies.

Reconciliation sequence propagates upwards from the child controller. For example if a policy gets changed it will trigger the HttpRouteController and reconcile the related HttpRoute. This change to the HttpRoute will trigger the APIController and it will process the API reconciliation based on the data stored in the intermediate data store and Kubernetes operator cache.

APIController is the parent controller and it should be made intelligent to detect the related API events and pass the event through the channel to the synchronizer go routine.

Events passed from the APIController to the synchronizer will be of the following types.

  • CREATE
    API CR CREATE

  • UPDATE
    API CR UPDATE
    HttpRoute CR CREATE
    HttpRoute CR UPDATE
    HttpRoute CR DELETE
    Policy CR CREATE
    Policy CR UPDATE
    Policy CR DELETE

  • DELETE
    API CR DELETE

Intermediate storage

To save the intermediate representation we need to have thread safe hashmaps. For that we can use,
Locks / Mutex (Pessimistic concurrency control)
CAS - Compare and Swap (Optimistic concurrency control)

type API struct {
	APIDefinition *v1alpha1.API
	HttpRoutes    []*gwapiv1b1.HTTPRoute
	APIPolicies   []*v1alpha1.Policy
}

Channel / Buffered channel

We can use a channel or a buffered channel depending on the frequency of message passing. In this case consumer (synchronizer) may take more time to process so a buffered channel is preferred to prevent the producer (controller) getting blocked.

Reconcile Loop

Reconcile loop breaks depending on the state of the intermediate storage and the K8s controller cache.

from apk.

AmaliMatharaarachchi avatar AmaliMatharaarachchi commented on May 18, 2024

closing as the operator has been implemented according to the above design

from apk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.