@@ -11,30 +11,33 @@ import (
1111
1212// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
1313
14+ // TemporalConnectionReference contains the name of a TemporalConnection resource
15+ // in the same namespace as the TemporalWorkerDeployment.
16+ type TemporalConnectionReference struct {
17+ // Name of the TemporalConnection resource.
18+ // +kubebuilder:validation:Required
19+ // +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
20+ Name string `json:"name"`
21+ }
22+
1423type WorkerOptions struct {
1524 // The name of a TemporalConnection in the same namespace as the TemporalWorkerDeployment.
16- TemporalConnection string `json:"connection "`
25+ TemporalConnectionRef TemporalConnectionReference `json:"connectionRef "`
1726 // The Temporal namespace for the worker to connect to.
27+ // +kubebuilder:validation:MinLength=1
1828 TemporalNamespace string `json:"temporalNamespace"`
1929}
2030
2131// TemporalWorkerDeploymentSpec defines the desired state of TemporalWorkerDeployment
2232type TemporalWorkerDeploymentSpec struct {
23- // Important: Run "make" to regenerate code after modifying this file
2433
2534 // Number of desired pods. This is a pointer to distinguish between explicit
2635 // zero and not specified. Defaults to 1.
2736 // This field makes TemporalWorkerDeploymentSpec implement the scale subresource, which is compatible with auto-scalers.
28- // TODO(jlegrone): Configure min replicas per thousand workflow/activity tasks?
2937 // +optional
38+ // +kubebuilder:default=1
3039 Replicas * int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
3140
32- // Label selector for pods. Existing ReplicaSets whose pods are
33- // selected by this will be the ones affected by this deployment.
34- // It must match the pod template's labels.
35- // +optional
36- Selector * metav1.LabelSelector `json:"selector" protobuf:"bytes,2,opt,name=selector"`
37-
3841 // Template describes the pods that will be created.
3942 // The only allowed template.spec.restartPolicy value is "Always".
4043 Template corev1.PodTemplateSpec `json:"template"`
@@ -43,13 +46,15 @@ type TemporalWorkerDeploymentSpec struct {
4346 // without any of its container crashing, for it to be considered available.
4447 // Defaults to 0 (pod will be considered available as soon as it is ready)
4548 // +optional
49+ // +kubebuilder:default=0
4650 MinReadySeconds int32 `json:"minReadySeconds,omitempty"`
4751
4852 // The maximum time in seconds for a deployment to make progress before it
4953 // is considered to be failed. The deployment controller will continue to
5054 // process failed deployments and a condition with a ProgressDeadlineExceeded
5155 // reason will be surfaced in the deployment status. Note that progress will
5256 // not be estimated during the time a deployment is paused. Defaults to 600s.
57+ // +kubebuilder:default=600
5358 ProgressDeadlineSeconds * int32 `json:"progressDeadlineSeconds,omitempty" protobuf:"varint,9,opt,name=progressDeadlineSeconds"`
5459
5560 // How to rollout new workflow executions to the target version.
@@ -58,7 +63,7 @@ type TemporalWorkerDeploymentSpec struct {
5863 // How to manage sunsetting drained versions.
5964 SunsetStrategy SunsetStrategy `json:"sunset"`
6065
61- // TODO(jlegrone): add godoc
66+ // WorkerOptions configures the worker's connection to Temporal.
6267 WorkerOptions WorkerOptions `json:"workerOptions"`
6368}
6469
@@ -128,7 +133,11 @@ type TemporalWorkerDeploymentStatus struct {
128133 // VersionCount is the total number of versions currently known by the worker deployment.
129134 // This includes current, target, ramping, and deprecated versions.
130135 // +optional
136+ // +kubebuilder:validation:Minimum=0
131137 VersionCount int32 `json:"versionCount,omitempty"`
138+
139+ // TODO(jlegrone): Add additional status fields following Kubernetes API conventions
140+ // https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
132141}
133142
134143// WorkflowExecutionStatus describes the current state of a workflow.
@@ -173,11 +182,11 @@ type BaseWorkerDeploymentVersion struct {
173182
174183 // Healthy indicates whether the deployment version is healthy.
175184 // +optional
176- HealthySince * metav1.Time `json:"healthySince"`
185+ HealthySince * metav1.Time `json:"healthySince,omitempty "`
177186
178187 // A pointer to the version's managed k8s deployment.
179188 // +optional
180- Deployment * corev1.ObjectReference `json:"deployment"`
189+ Deployment * corev1.ObjectReference `json:"deployment,omitempty "`
181190
182191 // TaskQueues is a list of task queues that are associated with this version.
183192 TaskQueues []TaskQueue `json:"taskQueues,omitempty"`
@@ -204,15 +213,18 @@ type TargetWorkerDeploymentVersion struct {
204213 TestWorkflows []WorkflowExecution `json:"testWorkflows,omitempty"`
205214
206215 // RampPercentage is the percentage of new workflow executions that are
207- // configured to start on this version. Only set when Status is VersionStatusRamping.
216+ // configured to start on this version. For example, 1.5 means 1.5%.
217+ // Only set when Status is VersionStatusRamping.
208218 //
209- // Acceptable range is [0,100].
219+ // Acceptable range is [0.0,100.0] (0% to 100%).
220+ // +kubebuilder:validation:Minimum=0.0
221+ // +kubebuilder:validation:Maximum=100.0
210222 RampPercentage * float32 `json:"rampPercentage,omitempty"`
211223
212224 // RampingSince is time when the version first started ramping.
213225 // Only set when Status is VersionStatusRamping.
214226 // +optional
215- RampingSince * metav1.Time `json:"rampingSince"`
227+ RampingSince * metav1.Time `json:"rampingSince,omitempty "`
216228
217229 // RampLastModifiedAt is the time when the ramp percentage was last changed for the target version.
218230 // +optional
@@ -227,7 +239,7 @@ type DeprecatedWorkerDeploymentVersion struct {
227239 // DrainedSince is the time at which the version became drained.
228240 // Only set when Status is VersionStatusDrained.
229241 // +optional
230- DrainedSince * metav1.Time `json:"drainedSince"`
242+ DrainedSince * metav1.Time `json:"drainedSince,omitempty "`
231243
232244 // A Version is eligible for deletion if it is drained and has no pollers on any task queue.
233245 // After pollers stop polling, the server will still consider them present until `matching.PollerHistoryTTL`
@@ -286,11 +298,13 @@ type SunsetStrategy struct {
286298 // ScaledownDelay specifies how long to wait after a version is drained before scaling its Deployment to zero.
287299 // Defaults to 1 hour.
288300 // +optional
301+ // +kubebuilder:default="1h"
289302 ScaledownDelay * metav1.Duration `json:"scaledownDelay"`
290303
291304 // DeleteDelay specifies how long to wait after a version is drained before deleting its Deployment.
292305 // Defaults to 24 hours.
293306 // +optional
307+ // +kubebuilder:default="24h"
294308 DeleteDelay * metav1.Duration `json:"deleteDelay"`
295309}
296310
@@ -299,37 +313,26 @@ type AllAtOnceRolloutStrategy struct{}
299313type RolloutStep struct {
300314 // RampPercentage indicates what percentage of new workflow executions should be
301315 // routed to the new worker deployment version while this step is active.
316+ // For example, 15 means 15%.
302317 //
303- // Acceptable range is [0,100].
304- RampPercentage float32 `json:"rampPercentage"`
318+ // Acceptable range is [1,99] (1% to 99%).
319+ // +kubebuilder:validation:Minimum=1
320+ // +kubebuilder:validation:Maximum=99
321+ RampPercentage int `json:"rampPercentage"`
305322
306323 // PauseDuration indicates how long to pause before progressing to the next step.
307324 PauseDuration metav1.Duration `json:"pauseDuration"`
308325}
309326
310327type ManualRolloutStrategy struct {}
311328
312- type QueueStatistics struct {
313- // The approximate number of tasks backlogged in this task queue. May count expired tasks but eventually converges
314- // to the right value.
315- ApproximateBacklogCount int64 `json:"approximateBacklogCount,omitempty"`
316- // Approximate age of the oldest task in the backlog based on the creation timestamp of the task at the head of the queue.
317- ApproximateBacklogAge metav1.Duration `json:"approximateBacklogAge,omitempty"`
318- // Approximate tasks per second added to the task queue based on activity within a fixed window. This includes both backlogged and
319- // sync-matched tasks.
320- TasksAddRate float32 `json:"tasksAddRate,omitempty"`
321- // Approximate tasks per second dispatched to workers based on activity within a fixed window. This includes both backlogged and
322- // sync-matched tasks.
323- TasksDispatchRate float32 `json:"tasksDispatchRate,omitempty"`
324- }
325-
326329//+kubebuilder:object:root=true
327330//+kubebuilder:subresource:status
328331// +kubebuilder:resource:shortName=twd;twdeployment;tworkerdeployment
329- //+kubebuilder:printcolumn:name="Current",type="string",JSONPath=".status.currentVersion.buildID",description="Current Version Build ID"
330- //+kubebuilder:printcolumn:name="Target",type="string",JSONPath=".status.targetVersion.buildID",description="Build ID of the target worker (based on the pod template) "
331- //+kubebuilder:printcolumn:name="Target- Ramp",type="number",JSONPath=".status.targetVersion.rampPercentage",description="Percentage of new workflows starting on Target Version "
332- //+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
332+ //+kubebuilder:printcolumn:name="Current",type="string",JSONPath=".status.currentVersion.buildID",description="Current build ID"
333+ //+kubebuilder:printcolumn:name="Target",type="string",JSONPath=".status.targetVersion.buildID",description="Target build ID "
334+ //+kubebuilder:printcolumn:name="Ramp % ",type="number",JSONPath=".status.targetVersion.rampPercentage",description="Ramp percentage "
335+ //+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Age"
333336
334337// TemporalWorkerDeployment is the Schema for the temporalworkerdeployments API
335338type TemporalWorkerDeployment struct {
0 commit comments