github.com/oam-dev/kubevela@v1.9.11/vela-templates/definitions/internal/trait/topologyspreadconstraints.cue (about)

     1  topologyspreadconstraints: {
     2  	type: "trait"
     3  	annotations: {}
     4  	description: "Add topology spread constraints hooks for every container of K8s pod for your workload which follows the pod spec in path 'spec.template'."
     5  	attributes: {
     6  		podDisruptive: true
     7  		appliesToWorkloads: ["deployments.apps", "statefulsets.apps", "daemonsets.apps", "jobs.batch"]
     8  	}
     9  }
    10  template: {
    11  	constraintsArray: [
    12  		for v in parameter.constraints {
    13  			maxSkew:           v.maxSkew
    14  			topologyKey:       v.topologyKey
    15  			whenUnsatisfiable: v.whenUnsatisfiable
    16  			labelSelector:     v.labelSelector
    17  			if v.nodeAffinityPolicy != _|_ {
    18  				nodeAffinityPolicy: v.nodeAffinityPolicy
    19  			}
    20  			if v.nodeTaintsPolicy != _|_ {
    21  				nodeTaintsPolicy: v.nodeTaintsPolicy
    22  			}
    23  			if v.minDomains != _|_ {
    24  				minDomains: v.minDomains
    25  			}
    26  			if v.matchLabelKeys != _|_ {
    27  				matchLabelKeys: v.matchLabelKeys
    28  			}
    29  		},
    30  	]
    31  	patch: spec: template: spec: {
    32  		topologySpreadConstraints: constraintsArray
    33  	}
    34  	#labSelector: {
    35  		matchLabels?: [string]: string
    36  		matchExpressions?: [...{
    37  			key:      string
    38  			operator: *"In" | "NotIn" | "Exists" | "DoesNotExist"
    39  			values?: [...string]
    40  		}]
    41  	}
    42  	parameter: {
    43  		constraints: [...{
    44  			// +usage=Describe the degree to which Pods may be unevenly distributed
    45  			maxSkew: int
    46  			// +usage=Specify the key of node labels
    47  			topologyKey: string
    48  			// +usage=Indicate how to deal with a Pod if it doesn't satisfy the spread constraint
    49  			whenUnsatisfiable: *"DoNotSchedule" | "ScheduleAnyway"
    50  			// +usage=labelSelector to find matching Pods
    51  			labelSelector: #labSelector
    52  			// +usage=Indicate a minimum number of eligible domains
    53  			minDomains?: int
    54  			// +usage=A list of pod label keys to select the pods over which spreading will be calculated
    55  			matchLabelKeys?: [...string]
    56  			// +usage=Indicate how we will treat Pod's nodeAffinity/nodeSelector when calculating pod topology spread skew
    57  			nodeAffinityPolicy?: *"Honor" | "Ignore"
    58  			// +usage=Indicate how we will treat node taints when calculating pod topology spread skew
    59  			nodeTaintsPolicy?: *"Honor" | "Ignore"
    60  		}]
    61  	}
    62  }