support config karmada components resources
Signed-off-by: wawa0210 <xiaozhang0210@hotmail.com>
This commit is contained in:
parent
244c73c4e9
commit
ab1900f249
|
@ -88,6 +88,7 @@ func (p *Planner) Execute() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := p.job.Run(); err != nil {
|
if err := p.job.Run(); err != nil {
|
||||||
|
klog.ErrorS(err, "failed to executed the workflow", "workflow", p.action, "karmada", klog.KObj(p.karmada))
|
||||||
return p.runJobErr(err)
|
return p.runJobErr(err)
|
||||||
}
|
}
|
||||||
if err := p.afterRunJob(); err != nil {
|
if err := p.afterRunJob(); err != nil {
|
||||||
|
|
|
@ -59,7 +59,7 @@ func installKarmadaAPIServer(client clientset.Interface, cfg *operatorv1alpha1.K
|
||||||
return fmt.Errorf("error when decoding karmadaApiserver deployment: %w", err)
|
return fmt.Errorf("error when decoding karmadaApiserver deployment: %w", err)
|
||||||
}
|
}
|
||||||
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
||||||
WithExtraArgs(cfg.ExtraArgs).ForDeployment(apiserverDeployment)
|
WithExtraArgs(cfg.ExtraArgs).WithResources(cfg.Resources).ForDeployment(apiserverDeployment)
|
||||||
|
|
||||||
if err := apiclient.CreateOrUpdateDeployment(client, apiserverDeployment); err != nil {
|
if err := apiclient.CreateOrUpdateDeployment(client, apiserverDeployment); err != nil {
|
||||||
return fmt.Errorf("error when creating deployment for %s, err: %w", apiserverDeployment.Name, err)
|
return fmt.Errorf("error when creating deployment for %s, err: %w", apiserverDeployment.Name, err)
|
||||||
|
@ -117,7 +117,7 @@ func installKarmadaAggregatedAPIServer(client clientset.Interface, cfg *operator
|
||||||
}
|
}
|
||||||
|
|
||||||
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
||||||
WithExtraArgs(cfg.ExtraArgs).WithFeatureGates(featureGates).ForDeployment(aggregatedAPIServerDeployment)
|
WithExtraArgs(cfg.ExtraArgs).WithFeatureGates(featureGates).WithResources(cfg.Resources).ForDeployment(aggregatedAPIServerDeployment)
|
||||||
|
|
||||||
if err := apiclient.CreateOrUpdateDeployment(client, aggregatedAPIServerDeployment); err != nil {
|
if err := apiclient.CreateOrUpdateDeployment(client, aggregatedAPIServerDeployment); err != nil {
|
||||||
return fmt.Errorf("error when creating deployment for %s, err: %w", aggregatedAPIServerDeployment.Name, err)
|
return fmt.Errorf("error when creating deployment for %s, err: %w", aggregatedAPIServerDeployment.Name, err)
|
||||||
|
|
|
@ -89,7 +89,7 @@ func getKubeControllerManagerManifest(name, namespace string, cfg *operatorv1alp
|
||||||
}
|
}
|
||||||
|
|
||||||
patcher.NewPatcher().WithAnnotations(cfg.Annotations).
|
patcher.NewPatcher().WithAnnotations(cfg.Annotations).
|
||||||
WithLabels(cfg.Labels).WithExtraArgs(cfg.ExtraArgs).ForDeployment(kcm)
|
WithLabels(cfg.Labels).WithExtraArgs(cfg.ExtraArgs).WithResources(cfg.Resources).ForDeployment(kcm)
|
||||||
return kcm, nil
|
return kcm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ func getKarmadaControllerManagerManifest(name, namespace string, featureGates ma
|
||||||
}
|
}
|
||||||
|
|
||||||
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
||||||
WithExtraArgs(cfg.ExtraArgs).WithFeatureGates(featureGates).ForDeployment(kcm)
|
WithExtraArgs(cfg.ExtraArgs).WithFeatureGates(featureGates).WithResources(cfg.Resources).ForDeployment(kcm)
|
||||||
return kcm, nil
|
return kcm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ func getKarmadaSchedulerManifest(name, namespace string, featureGates map[string
|
||||||
}
|
}
|
||||||
|
|
||||||
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
||||||
WithExtraArgs(cfg.ExtraArgs).WithFeatureGates(featureGates).ForDeployment(scheduler)
|
WithExtraArgs(cfg.ExtraArgs).WithFeatureGates(featureGates).WithResources(cfg.Resources).ForDeployment(scheduler)
|
||||||
return scheduler, nil
|
return scheduler, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ func getKarmadaDeschedulerManifest(name, namespace string, featureGates map[stri
|
||||||
}
|
}
|
||||||
|
|
||||||
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
||||||
WithExtraArgs(cfg.ExtraArgs).WithFeatureGates(featureGates).ForDeployment(descheduler)
|
WithExtraArgs(cfg.ExtraArgs).WithFeatureGates(featureGates).WithResources(cfg.Resources).ForDeployment(descheduler)
|
||||||
|
|
||||||
return descheduler, nil
|
return descheduler, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ func installKarmadaEtcd(client clientset.Interface, name, namespace string, cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
||||||
WithVolumeData(cfg.VolumeData).ForStatefulSet(etcdStatefulSet)
|
WithVolumeData(cfg.VolumeData).WithResources(cfg.Resources).ForStatefulSet(etcdStatefulSet)
|
||||||
|
|
||||||
if err := apiclient.CreateOrUpdateStatefulSet(client, etcdStatefulSet); err != nil {
|
if err := apiclient.CreateOrUpdateStatefulSet(client, etcdStatefulSet); err != nil {
|
||||||
return fmt.Errorf("error when creating Etcd statefulset, err: %w", err)
|
return fmt.Errorf("error when creating Etcd statefulset, err: %w", err)
|
||||||
|
|
|
@ -46,7 +46,7 @@ func installKarmadaMetricAdapter(client clientset.Interface, cfg *operatorv1alph
|
||||||
return fmt.Errorf("err when decoding KarmadaMetricAdapter Deployment: %w", err)
|
return fmt.Errorf("err when decoding KarmadaMetricAdapter Deployment: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).ForDeployment(metricAdapter)
|
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).WithResources(cfg.Resources).ForDeployment(metricAdapter)
|
||||||
|
|
||||||
if err := apiclient.CreateOrUpdateDeployment(client, metricAdapter); err != nil {
|
if err := apiclient.CreateOrUpdateDeployment(client, metricAdapter); err != nil {
|
||||||
return fmt.Errorf("error when creating deployment for %s, err: %w", metricAdapter.Name, err)
|
return fmt.Errorf("error when creating deployment for %s, err: %w", metricAdapter.Name, err)
|
||||||
|
|
|
@ -47,7 +47,7 @@ func installKarmadaWebhook(client clientset.Interface, cfg *operatorv1alpha1.Kar
|
||||||
}
|
}
|
||||||
|
|
||||||
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
patcher.NewPatcher().WithAnnotations(cfg.Annotations).WithLabels(cfg.Labels).
|
||||||
WithExtraArgs(cfg.ExtraArgs).ForDeployment(webhookDeployment)
|
WithExtraArgs(cfg.ExtraArgs).WithResources(cfg.Resources).ForDeployment(webhookDeployment)
|
||||||
|
|
||||||
if err := apiclient.CreateOrUpdateDeployment(client, webhookDeployment); err != nil {
|
if err := apiclient.CreateOrUpdateDeployment(client, webhookDeployment); err != nil {
|
||||||
return fmt.Errorf("error when creating deployment for %s, err: %w", webhookDeployment.Name, err)
|
return fmt.Errorf("error when creating deployment for %s, err: %w", webhookDeployment.Name, err)
|
||||||
|
|
|
@ -24,6 +24,7 @@ type Patcher struct {
|
||||||
extraArgs map[string]string
|
extraArgs map[string]string
|
||||||
featureGates map[string]bool
|
featureGates map[string]bool
|
||||||
volume *operatorv1alpha1.VolumeData
|
volume *operatorv1alpha1.VolumeData
|
||||||
|
resources corev1.ResourceRequirements
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPatcher returns a patcher.
|
// NewPatcher returns a patcher.
|
||||||
|
@ -61,6 +62,12 @@ func (p *Patcher) WithVolumeData(volume *operatorv1alpha1.VolumeData) *Patcher {
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithResources sets resources to the patcher.
|
||||||
|
func (p *Patcher) WithResources(resources corev1.ResourceRequirements) *Patcher {
|
||||||
|
p.resources = resources
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
// ForDeployment patches the deployment manifest.
|
// ForDeployment patches the deployment manifest.
|
||||||
func (p *Patcher) ForDeployment(deployment *appsv1.Deployment) {
|
func (p *Patcher) ForDeployment(deployment *appsv1.Deployment) {
|
||||||
deployment.Labels = labels.Merge(deployment.Labels, p.labels)
|
deployment.Labels = labels.Merge(deployment.Labels, p.labels)
|
||||||
|
@ -69,6 +76,10 @@ func (p *Patcher) ForDeployment(deployment *appsv1.Deployment) {
|
||||||
deployment.Annotations = labels.Merge(deployment.Annotations, p.annotations)
|
deployment.Annotations = labels.Merge(deployment.Annotations, p.annotations)
|
||||||
deployment.Spec.Template.Annotations = labels.Merge(deployment.Spec.Template.Annotations, p.annotations)
|
deployment.Spec.Template.Annotations = labels.Merge(deployment.Spec.Template.Annotations, p.annotations)
|
||||||
|
|
||||||
|
if p.resources.Size() > 0 {
|
||||||
|
// It's considered the first container is the karmada component by default.
|
||||||
|
deployment.Spec.Template.Spec.Containers[0].Resources = p.resources
|
||||||
|
}
|
||||||
if len(p.extraArgs) != 0 || len(p.featureGates) != 0 {
|
if len(p.extraArgs) != 0 || len(p.featureGates) != 0 {
|
||||||
// It's considered the first container is the karmada component by default.
|
// It's considered the first container is the karmada component by default.
|
||||||
baseArguments := deployment.Spec.Template.Spec.Containers[0].Command
|
baseArguments := deployment.Spec.Template.Spec.Containers[0].Command
|
||||||
|
@ -109,6 +120,10 @@ func (p *Patcher) ForStatefulSet(sts *appsv1.StatefulSet) {
|
||||||
patchVolumeForStatefulSet(sts, p.volume)
|
patchVolumeForStatefulSet(sts, p.volume)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.resources.Size() > 0 {
|
||||||
|
// It's considered the first container is the karmada component by default.
|
||||||
|
sts.Spec.Template.Spec.Containers[0].Resources = p.resources
|
||||||
|
}
|
||||||
if len(p.extraArgs) != 0 {
|
if len(p.extraArgs) != 0 {
|
||||||
// It's considered the first container is the karmada component by default.
|
// It's considered the first container is the karmada component by default.
|
||||||
baseArguments := sts.Spec.Template.Spec.Containers[0].Command
|
baseArguments := sts.Spec.Template.Spec.Containers[0].Command
|
||||||
|
|
Loading…
Reference in New Issue