Skip to content

Instantly share code, notes, and snippets.

@karlkfi
Created September 15, 2015 00:39
Show Gist options
  • Save karlkfi/d27e4fac921f3673c76c to your computer and use it in GitHub Desktop.
Save karlkfi/d27e4fac921f3673c76c to your computer and use it in GitHub Desktop.
Aggregate Service Status Proposal

Aggregate Status (w/ Policy)

Status aggregation is complicated, but I guess we have to start with built-in policies.

I'm not sure what "alive" means to an Service tho, when there's "ready"... Does the policy apply to both?

type StatusPolicy string

const (
	// Alive/Ready if all targets are Alive/Ready
	StatusPolicyAll StatusPolicy = "All"
	// Alive/Ready if half + 1 of the targets are Alive/Ready
	StatusPolicyMajority StatusPolicy = "Majority"
	// Alive/Ready if at least 1 target is Alive/Ready
	StatusPolicyOne StatusPolicy = "One"
	// Alive/Ready if at least N targets are Alive/Ready, where N is PolicyQualifier as an int
	StatusPolicyAtLeast StatusPolicy = "AtLeast"
)

type ServiceSpec struct {
	...
	Policy StatusPolicy `json:"policy,omitempty"`
	PolicyQualifier interface{} `json:"policyQualifier,omitempty"`
}

type ServiceStatus struct {
	...
	Conditions []ServiceCondition `json:"conditions,omitempty"`
	LastUpdateTime util.Time `json:"lastUpdateTime,omitempty"`
	LastTransitionTime util.Time `json:"lastTransitionTime,omitempty"`
}

type ServiceConditionType string

const (
	ServiceAlive ServiceConditionType = "Alive"
	ServiceReady ServiceConditionType = "Ready"
)

type ServiceCondition struct {
	Type ServiceTargetConditionType `json:"type"`
	Status ConditionStatus `json:"status"`
	Reason string `json:"reason,omitempty"`
	Message string `json:"message,omitempty"`
}

I guess a load balencer could then just watch Service or ServiceStatus to know what server target addresses should be routable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment