When the Provider primary service initiates the Cluster Service - detailed in this section - current deployments, hostnames, and inventory are gathered.
Perputually the Cluster Service then listens for new orders to place into inventory on bids the Provider acts on and invokes deployments for won bids.
-link to cluster service initiation
-link to cluster NewService section
-etc
1). Cluster Service Initiation
Provider Service Calls/Initiates the Cluster Service
The NewService function within provider/cluster/service.go invokes:
Subscription to RPC Node pubsub bus via the bus.Subscribe method call
The call of the findDeployments function to discover current deployments in the Kubernetes cluster. This function is defined in the same file - service.go - as the cluster NewService function exists in.
The call of the newInventoryService function which will track new/existing orders and create an inventory reservation when the provider bids on a deployment.
3). Cluster Service Listening Bus
The NewService function eventually populates a service struct and passes the variable to the run method which invokes a perpetual listening bus for new deployments. The deployments argument is additionally passed into the run method as an argument.
4). Creating Deployment Managers for Existing Deployments
Within in the run method a for loop creates a deployment manager for pre-existing deployments on the provider.
Further explanation of the deployment manager can be found in a later section of this documentation section.
5). Cluster Service Perpetual Listening Loop
A perpetual for loop is spawned for the Cluster Service which - amongst other cases - monitor for an event type of ManifestReceived.
Following a series of validations - for example ensuring that the deployment pre-exists in which would indicate a deployment update event and assurance that the deployment exist in inventory - when passed thru eventually reaches a call of the newDeploymentManager function.
6). Deployment Managers
The call of the newDeploymentManager function - located in provider/cluster/manager.go - provokes a deployment specific lifecycle manager.
As described in the previous section the invoke of the NewService function spawns a call of the newInventoryService function.
The newInventoryService function is defined in provider/cluster/inventory.go.
When the Provider’s bid engine determines that it should bid on a new deployment the Reserve method is called. Downstream logic places this reservation into inventory.
In summation this Bid Engine logic is the mechanism in which the Provider reserves Kubernetes resources and places the reservation into inventory while the bid is pending.