Skip to content

Commit

Permalink
Configure default values for PlacementPolicy
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Feb 5, 2024
1 parent 70548d5 commit fec61bf
Showing 3 changed files with 31 additions and 11 deletions.
20 changes: 14 additions & 6 deletions apis/apps/v1/placementpolicy_types.go
Original file line number Diff line number Diff line change
@@ -55,23 +55,31 @@ type PlacementPolicySpec struct {
NodeSpreadConstraint *NodeSpreadConstraint `json:"nodeSpreadConstraint,omitempty"`

// +optional
NodeAffinity []NodeAffinityRules `json:"nodeAffinity,omitempty"`
NodeAffinity []NodeAffinityRule `json:"nodeAffinity,omitempty"`
}

type ZoneSpreadConstraint struct {
MaxSkew int32 `json:"maxSkew"`
// +kubebuilder:default=1
MaxSkew int32 `json:"maxSkew"`
// +kubebuilder:default=DoNotSchedule
WhenUnsatisfiable v1.UnsatisfiableConstraintAction `json:"whenUnsatisfiable"`
}

type NodeSpreadConstraint struct {
MaxSkew int32 `json:"maxSkew"`
// +kubebuilder:default=1
MaxSkew int32 `json:"maxSkew"`
// +kubebuilder:default=DoNotSchedule
WhenUnsatisfiable v1.UnsatisfiableConstraintAction `json:"whenUnsatisfiable"`
}

type NodeAffinityRules struct {
TopologyKey string `json:"topologyKey"`
Domains []TopologyDomain `json:"domains"`
type NodeAffinityRule struct {
TopologyKey string `json:"topologyKey"`
Domains []TopologyDomain `json:"domains"`
// +kubebuilder:default=DoNotSchedule
WhenUnsatisfiable v1.UnsatisfiableConstraintAction `json:"whenUnsatisfiable"`
// Weight associated with matching the corresponding nodeSelectorTerm, in the range 1-100.
// +kubebuilder:default=50
Weight int32 `json:"weight"`
}

type TopologyDomain struct {
10 changes: 5 additions & 5 deletions apis/apps/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions crds/apps.k8s.appscode.com_placementpolicies.yaml
Original file line number Diff line number Diff line change
@@ -56,20 +56,30 @@ spec:
type: array
topologyKey:
type: string
weight:
default: 50
description: Weight associated with matching the corresponding
nodeSelectorTerm, in the range 1-100.
format: int32
type: integer
whenUnsatisfiable:
default: DoNotSchedule
type: string
required:
- domains
- topologyKey
- weight
- whenUnsatisfiable
type: object
type: array
nodeSpreadConstraint:
properties:
maxSkew:
default: 1
format: int32
type: integer
whenUnsatisfiable:
default: DoNotSchedule
type: string
required:
- maxSkew
@@ -78,9 +88,11 @@ spec:
zoneSpreadConstraint:
properties:
maxSkew:
default: 1
format: int32
type: integer
whenUnsatisfiable:
default: DoNotSchedule
type: string
required:
- maxSkew

0 comments on commit fec61bf

Please sign in to comment.