Service Affinity
Service affinity in gopaddle is similar to Pod Affinity in Kubernetes. Service affinity can be configured for a gopaddle service to schedule it on a cluster based on conditions/constraints. You can also configure Service Affinity for a running Application.
Affinity Rules schedules the service deployment on a set of nodes (within scope based on Topology Key) along with other services that match the constraint.
Anti-Affinity Rules schedules the service deployment on a set of nodes (within scope based on Topology Key) away from other services that match the constraint.
Schedule Constraint is applied when a service is scheduled for deployment on a cluster. If a Soft Schedule Constraint is set, then you can specify a weight to be applied to that constraint.
Execution Constraint is applied through out the lifecycle of a service. You can set both Hard and Soft constraint in a Schedule Constraint. Currently Execution Constraints are ignored and is not supported.
Topology Key defines the scope in which these constraints are to be applied.
Label Expression gives the ability to define sophisticated conditions where a deployment Label Key matches a Label Value. Eg.
Label Value <condition> Label Key
Some of the conditions include :
In
NotIn
Exists
DoesNotExist
Label Key/Value Pair condition matches a Label Key with a Label Value.
Node Affinity
Node Affinity can be configured at the time of deploying the template and after an application is launched. Node Affinity selects the node where the service has to deployed based on the constraints.
The constraints for Node Affinity are similar to Service Affinity.
Node expression matches nodes with a Label Key and Label Value.
Label Value <condition> Label Key
Node Field matches nodes with fields matching a Key and a Value.
Field Value <condition> Field Key
Eg. aws-node1 In metadata.name
Some of the Node Expression and Node Field conditions include :
In
NotIn
Exists
DoesNotExist
Gt
Lt
For more information on Pod and Node Affinity/Anti-Affinity, check the kubernetes documentation here.