github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/k8s-update-strategy.yaml (about)

     1  # Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
     2  # Definition source cue file: vela-templates/definitions/internal/k8s-update-strategy.cue
     3  apiVersion: core.oam.dev/v1beta1
     4  kind: TraitDefinition
     5  metadata:
     6    annotations:
     7      definition.oam.dev/alias: ""
     8      definition.oam.dev/description: Set k8s update strategy for Deployment/DaemonSet/StatefulSet
     9    name: k8s-update-strategy
    10    namespace: {{ include "systemDefinitionNamespace" . }}
    11  spec:
    12    appliesToWorkloads:
    13      - deployments.apps
    14      - statefulsets.apps
    15      - daemonsets.apps
    16    conflictsWith: []
    17    podDisruptive: false
    18    schematic:
    19      cue:
    20        template: |
    21          patch: spec: {
    22          	if parameter.targetKind == "Deployment" && parameter.strategy.type != "OnDelete" {
    23          		// +patchStrategy=retainKeys
    24          		strategy: {
    25          			type: parameter.strategy.type
    26          			if parameter.strategy.type == "RollingUpdate" {
    27          				rollingUpdate: {
    28          					maxSurge:       parameter.strategy.rollingStrategy.maxSurge
    29          					maxUnavailable: parameter.strategy.rollingStrategy.maxUnavailable
    30          				}
    31          			}
    32          		}
    33          	}
    34  
    35          	if parameter.targetKind == "StatefulSet" && parameter.strategy.type != "Recreate" {
    36          		// +patchStrategy=retainKeys
    37          		updateStrategy: {
    38          			type: parameter.strategy.type
    39          			if parameter.strategy.type == "RollingUpdate" {
    40          				rollingUpdate: partition: parameter.strategy.rollingStrategy.partition
    41          			}
    42          		}
    43          	}
    44  
    45          	if parameter.targetKind == "DaemonSet" && parameter.strategy.type != "Recreate" {
    46          		// +patchStrategy=retainKeys
    47          		updateStrategy: {
    48          			type: parameter.strategy.type
    49          			if parameter.strategy.type == "RollingUpdate" {
    50          				rollingUpdate: {
    51          					maxSurge:       parameter.strategy.rollingStrategy.maxSurge
    52          					maxUnavailable: parameter.strategy.rollingStrategy.maxUnavailable
    53          				}
    54          			}
    55          		}
    56          	}
    57  
    58          }
    59          parameter: {
    60          	// +usage=Specify the apiVersion of target
    61          	targetAPIVersion: *"apps/v1" | string
    62          	// +usage=Specify the kind of target
    63          	targetKind: *"Deployment" | "StatefulSet" | "DaemonSet"
    64          	// +usage=Specify the strategy of update
    65          	strategy: {
    66          		// +usage=Specify the strategy type
    67          		type: *"RollingUpdate" | "Recreate" | "OnDelete"
    68          		// +usage=Specify the parameters of rollong update strategy
    69          		rollingStrategy?: {
    70          			maxSurge:       *"25%" | string
    71          			maxUnavailable: *"25%" | string
    72          			partition:      *0 | int
    73          		}
    74          	}
    75          }
    76    workloadRefPath: ""
    77