Skip to content

Commit

Permalink
feat: extends Task with additional PodSpec fields
Browse files Browse the repository at this point in the history
Adds the following fields from the corev1.PodSpec in order to make the
task pod more configurable:

* RestartPolicy
* RestartPolicy
* ActiveDeadlineSeconds
* NodeSelector
* ServiceAccountName
* AutomountServiceAccountToken
* SecurityContext
* ImagePullSecrets
* Affinity
* Tolerations
* TopologySpreadConstraints
  • Loading branch information
rekfuki-f3 authored and miketonks-form3 committed Dec 15, 2023
1 parent 374536a commit d36f9af
Show file tree
Hide file tree
Showing 14 changed files with 21,526 additions and 3,196 deletions.
1 change: 1 addition & 0 deletions .github/.licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ header:
- '**/*.json'
- '**/*.log'
- 'vendor/**'
- 'api/vendor/**'
- '**/go.mod'
- '**/go.sum'
- '**/go.work'
Expand Down
59 changes: 55 additions & 4 deletions api/v1alpha1/workflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,63 @@ type Task struct {
// Container is the main container image to run in the pod
Container *corev1.Container `json:"container,omitempty"`

// Volumes is a list of volumes that can be mounted by containers in a template.
// +patchStrategy=merge
// +optional
// +patchMergeKey=name
Volumes []corev1.Volume `json:"volumes,omitempty" patchStrategy:"merge" patchMergeKey:"name"`
// +patchStrategy=merge,retainKeys
Volumes []corev1.Volume `json:"volumes,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`

// +optional
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`

// +optional
ActiveDeadlineSeconds *int64 `json:"activeDeadlineSeconds,omitempty"`

// +optional
// +mapType=atomic
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// +optional
AutomountServiceAccountToken *bool `json:"automountServiceAccountToken,omitempty"`

// +optional
SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"`

// TODO: maybe we could specify parameters in other ways, like loading context from file
// +optional
// +patchMergeKey=name
// +patchStrategy=merge
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty" patchStrategy:"merge" patchMergeKey:"name"`

// +optional
Affinity *corev1.Affinity `json:"affinity,omitempty"`

// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// +optional
// +patchMergeKey=topologyKey
// +patchStrategy=merge
// +listType=map
// +listMapKey=topologyKey
// +listMapKey=whenUnsatisfiable
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty" patchStrategy:"merge" patchMergeKey:"topologyKey"`
}

func (t *Task) PodSpec() corev1.PodSpec {
return corev1.PodSpec{
Volumes: t.Volumes,
TerminationGracePeriodSeconds: t.TerminationGracePeriodSeconds,
ActiveDeadlineSeconds: t.ActiveDeadlineSeconds,
NodeSelector: t.NodeSelector,
ServiceAccountName: t.ServiceAccountName,
AutomountServiceAccountToken: t.AutomountServiceAccountToken,
SecurityContext: t.SecurityContext,
ImagePullSecrets: t.ImagePullSecrets,
Affinity: t.Affinity,
TopologySpreadConstraints: t.TopologySpreadConstraints,
}
}

// +kubebuilder:object:root=true
Expand Down
51 changes: 51 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

1,451 changes: 1,449 additions & 2 deletions config/crd/bases/chaos-mesh.org_schedules.yaml

Large diffs are not rendered by default.

3,483 changes: 3,168 additions & 315 deletions config/crd/bases/chaos-mesh.org_workflownodes.yaml

Large diffs are not rendered by default.

1,366 changes: 1,364 additions & 2 deletions config/crd/bases/chaos-mesh.org_workflows.yaml

Large diffs are not rendered by default.

1,451 changes: 1,449 additions & 2 deletions helm/chaos-mesh/crds/chaos-mesh.org_schedules.yaml

Large diffs are not rendered by default.

3,483 changes: 3,168 additions & 315 deletions helm/chaos-mesh/crds/chaos-mesh.org_workflownodes.yaml

Large diffs are not rendered by default.

1,366 changes: 1,364 additions & 2 deletions helm/chaos-mesh/crds/chaos-mesh.org_workflows.yaml

Large diffs are not rendered by default.

10,732 changes: 8,197 additions & 2,535 deletions manifests/crd.yaml

Large diffs are not rendered by default.

355 changes: 354 additions & 1 deletion pkg/dashboard/swaggerdocs/docs.go

Large diffs are not rendered by default.

355 changes: 354 additions & 1 deletion pkg/dashboard/swaggerdocs/swagger.json

Large diffs are not rendered by default.

Loading

0 comments on commit d36f9af

Please sign in to comment.