[WIP] Adding Support For Configurable Optimizer Config#83
Draft
shekhar316 wants to merge 17 commits into
Draft
Conversation
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: Shekhar Saxena <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Signed-off-by: SHEKHAR SAXENA <shekhar.saxena@ibm.com>
Reviewer's GuideAdds first-class support for a configurable Kruize Optimizer component (image + config), splits resource generation into core vs optimizer phases, wires it into the reconciler and readiness logic, and updates tests, CRD, types, constants, and sample/e2e configs accordingly. Sequence diagram for phased deployment of core and optimizer resourcessequenceDiagram
participant R as KruizeReconciler
participant G as KruizeResourceGenerator
participant K8s as KubernetesAPI
participant OPTD as kruize-optimizer Deployment
participant INIT as wait-for-kruize init container
participant KR as kruize Service
R->>G: NewKruizeResourceGenerator(namespace, autotuneImage, autotuneUIImage, optimizerImage, clusterType, kruizeSpec, ctx)
activate G
G-->>R: KruizeResourceGenerator instance
deactivate G
R->>G: CoreNamespacedResources() or CoreKubernetesNamespacedResources()
G-->>R: coreResources (DB, kruize, UI)
loop each core resource
R->>K8s: apply core resource
K8s-->>R: core resource created/updated
end
R->>G: OptimizerNamespacedResources() or OptimizerKubernetesNamespacedResources()
G-->>R: optimizerResources (kruize-optimizer Deployment, Service)
loop each optimizer resource
R->>K8s: apply optimizer resource
K8s-->>R: optimizer resource created/updated
end
Note over OPTD,INIT: Pod start for kruize-optimizer
OPTD->>INIT: start init container wait-for-kruize
loop until kruize health ready
INIT->>KR: HTTP GET /health or /
KR-->>INIT: 503 or connection error
end
INIT->>KR: HTTP GET /health
KR-->>INIT: 200 OK
INIT-->>OPTD: init complete, start optimizer container
Sequence diagram for optimizer environment configuration resolutionsequenceDiagram
participant R as KruizeReconciler
participant G as KruizeResourceGenerator
participant Spec as KruizeSpec
participant OCfg as OptimizerConfig
participant D as kruize-optimizer Pod
R->>G: NewKruizeResourceGenerator(..., kruizeSpec, ...)
G-->>R: generator with KruizeSpec reference
R->>G: kruizeOptimizerDeployment()
activate G
G->>G: getOptimizerEnvVars()
alt Optimizer config provided
G->>Spec: read Optimizer
Spec-->>G: OptimizerConfig pointer
G->>OCfg: read fields (KruizeURL, intervals, webhookURL, labels, profiles)
OCfg-->>G: values or empty strings
G->>G: override defaults where non-empty
else No Optimizer config
G->>G: use all default values
end
G-->>R: Deployment with env vars
deactivate G
R->>D: create Pod with resolved env
D-->>R: running with configured optimizer behavior
Class diagram for updated KruizeSpec and OptimizerConfig modelsclassDiagram
class KruizeSpec {
string Autotune_image
string Autotune_ui_image
string Optimizer_image
string Namespace
string Cluster_type
KruizeAppConfig Kruize
OptimizerConfig Optimizer
}
class KruizeAppConfig {
string Autotune_image
string Autotune_ui_image
string Namespace
KubernetesResourceRequirements Resources
}
class OptimizerConfig {
KubernetesResourceRequirements Resources
string KruizeURL
string StateRefreshInterval
string BulkSchedulerInterval
string BulkSchedulerStartupDelay
string BulkMeasurementDuration
string WebhookURL
string TargetLabelLimit
string TargetLabels
string DefaultDatasource
string DefaultMetadataProfile
string DefaultMetricProfile
}
class KubernetesResourceRequirements {
string Requests_cpu
string Requests_memory
string Limits_cpu
string Limits_memory
}
KruizeSpec --> KruizeAppConfig : has optional
KruizeSpec --> OptimizerConfig : has optional
KruizeAppConfig --> KubernetesResourceRequirements : uses optional
OptimizerConfig --> KubernetesResourceRequirements : uses optional
Class diagram for KruizeResourceGenerator and optimizer resource generationclassDiagram
class KruizeResourceGenerator {
string Namespace
string Autotune_image
string Autotune_ui_image
string Optimizer_image
string ClusterType
KruizeSpec KruizeSpec
context.Context Ctx
+NewKruizeResourceGenerator(namespace string, autotuneImage string, autotuneUIImage string, optimizerImage string, clusterType string, kruizeSpec *KruizeSpec, ctx context.Context) KruizeResourceGenerator
+CoreNamespacedResources() []client.Object
+OptimizerNamespacedResources() []client.Object
+CoreKubernetesNamespacedResources() []client.Object
+OptimizerKubernetesNamespacedResources() []client.Object
+getOptimizerEnvVars() []corev1.EnvVar
+kruizeOptimizerDeployment() *appsv1.Deployment
+kruizeOptimizerService() *corev1.Service
}
class KruizeReconciler {
client.Client Client
+deployKruizeComponents(ctx context.Context, namespace string, kruize *Kruize) error
+waitForKruizePods(ctx context.Context, namespace string, timeout time.Duration) error
+checkKruizePodsStatus(ctx context.Context, namespace string) (int, int, map[string]string, error)
}
KruizeReconciler --> KruizeResourceGenerator : creates and uses
KruizeResourceGenerator --> KruizeSpec : reads configuration
KruizeResourceGenerator --> OptimizerConfig : reads optimizer config
KruizeResourceGenerator --> appsv1.Deployment : generates
KruizeResourceGenerator --> corev1.Service : generates
KruizeResourceGenerator --> corev1.EnvVar : populates optimizer env
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
|
@shekhar316 is PR 83 targeted for 0.0.5 or next release? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Introduce a configurable Kruize Optimizer component and integrate it into the operator’s deployment flow alongside existing Kruize services.
New Features:
Enhancements:
Tests: