-
Notifications
You must be signed in to change notification settings - Fork 262
adding scale subresource so that HPA can be used with the cluster #394
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -412,6 +412,18 @@ type JobSpec struct { | |
| SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"` | ||
| } | ||
|
|
||
| // HPASpec defines properties of a HPA for the cluster. | ||
| type HPASpec struct { | ||
| // Taskmanager lower limit for the number of pods. | ||
| MinReplicas *int32 `json:"minReplicas,omitempty"` | ||
|
|
||
| // Taskmanager upper limit for the number of pods. | ||
| MaxReplicas int32 `json:"maxReplicas"` | ||
|
|
||
| // Taskmanager target average CPU utilization | ||
| TargetCPUUtilizationPercentage *int32 `json:"targetCPUUtilizationPercentage,omitempty"` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: "Percentage" seems to be unnecessary, can we remove it here and below?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mostly agree, but it does disambiguate whether is a percentage, proportion or even absolute value. It also matches the |
||
| } | ||
|
|
||
| // FlinkClusterSpec defines the desired state of FlinkCluster | ||
| type FlinkClusterSpec struct { | ||
| // Flink image spec for the cluster's components. | ||
|
|
@@ -452,6 +464,9 @@ type FlinkClusterSpec struct { | |
| // Config for GCP. | ||
| GCPConfig *GCPConfig `json:"gcpConfig,omitempty"` | ||
|
|
||
| // Config for HPA | ||
| HPA *HPASpec `json:"hpa,omitempty"` | ||
|
|
||
| // The logging configuration, which should have keys 'log4j-console.properties' and 'logback-console.xml'. | ||
| // These will end up in the 'flink-config-volume' ConfigMap, which gets mounted at /opt/flink/conf. | ||
| // If not provided, defaults that log to console only will be used. | ||
|
|
@@ -519,7 +534,10 @@ type FlinkClusterComponentsStatus struct { | |
| JobManagerIngress *JobManagerIngressStatus `json:"jobManagerIngress,omitempty"` | ||
|
|
||
| // The state of TaskManager StatefulSet. | ||
| TaskManagerStatefulSet FlinkClusterComponentState `json:"taskManagerStatefulSet"` | ||
| TaskManagerStatefulSet TaskManagerStatefulSetStatus `json:"taskManagerStatefulSet"` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for fixing this! |
||
|
|
||
| // The state of the HPA | ||
| HPA *HPAStatus `json:"hpa,omitempty"` | ||
|
|
||
| // The status of the job, available only when JobSpec is provided. | ||
| Job *JobStatus `json:"job,omitempty"` | ||
|
|
@@ -577,6 +595,23 @@ type JobStatus struct { | |
| RestartCount int32 `json:"restartCount,omitempty"` | ||
| } | ||
|
|
||
| type HPAStatus struct { | ||
| // The name of the Kubernetes HPS resource. | ||
| Name string `json:"name,omitempty"` | ||
|
|
||
| // The state of the Kubernetes hpa. | ||
| State string `json:"state"` | ||
|
|
||
| // The current number of replicas in the cluster seen by the hpa. | ||
| CurrentReplicas int32 `json:"currentReplicas"` | ||
|
|
||
| // The desired number of replicas in the cluster seen by the hpa. | ||
| DesiredReplicas int32 `json:"desiredReplicas"` | ||
|
|
||
| // The current average CPU utilization over all pods in the taskmanager statefulset | ||
| CurrentCPUUtilizationPercentage *int32 `json:"currentCPUUtilizationPercentage,omitempty"` | ||
| } | ||
|
|
||
| // SavepointStatus defines the status of savepoint progress | ||
| type SavepointStatus struct { | ||
| // The ID of the Flink job. | ||
|
|
@@ -625,6 +660,21 @@ type JobManagerServiceStatus struct { | |
| NodePort int32 `json:"nodePort,omitempty"` | ||
| } | ||
|
|
||
| // TaskManagerStatefulSetStatus | ||
| type TaskManagerStatefulSetStatus struct { | ||
| // The name of the Kubernetes jobManager service. | ||
| Name string `json:"name"` | ||
|
|
||
| // The state of the component. | ||
| State string `json:"state"` | ||
|
|
||
| // The number of replicas in the tasks manager. | ||
| Replicas int32 `json:"replicas"` | ||
|
|
||
| // The label for the tasks manager pods. | ||
| Selector string `json:"selector"` | ||
| } | ||
|
|
||
| // FlinkClusterStatus defines the observed state of FlinkCluster | ||
| type FlinkClusterStatus struct { | ||
| // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
|
|
@@ -667,6 +717,7 @@ type FlinkClusterStatus struct { | |
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
| // +kubebuilder:subresource:scale:specpath=.spec.taskManager.replicas,statuspath=.status.components.taskManagerStatefulSet.replicas,selectorpath=.status.components.taskManagerStatefulSet.selector | ||
|
|
||
| // FlinkCluster is the Schema for the flinkclusters API | ||
| type FlinkCluster struct { | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to define the default value for optional fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D you mean a default value for the
HPASpecor for the struct fields?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the fields, e.g., if the user doesn't specify the value, what is the default value / behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌 got it