Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support PodManagementPolicy for the instanceSet controller #7540

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apis/apps/v1alpha1/componentdefinition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1alpha1
import (
"time"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -443,6 +444,16 @@ type ComponentDefinitionSpec struct {
// +optional
UpdateStrategy *UpdateStrategy `json:"updateStrategy,omitempty"`

// InstanceSet controls the creation of pods during initial scale up, replacement of pods on nodes, and scaling down.
//
// - `OrderedReady`: Creates pods in increasing order (pod-0, then pod-1, etc). The controller waits until each pod
// is ready before continuing. Pods are removed in reverse order when scaling down.
// - `Parallel`: Creates pods in parallel to match the desired scale without waiting. All pods are deleted at once
// when scaling down.
//
// +optional
PodManagementPolicy *appsv1.PodManagementPolicyType `json:"podManagementPolicy,omitempty"`
nayutah marked this conversation as resolved.
Show resolved Hide resolved

// Enumerate all possible roles assigned to each replica of the Component, influencing its behavior.
//
// A replica can have zero to multiple roles.
Expand Down
5 changes: 5 additions & 0 deletions apis/apps/v1alpha1/zz_generated.deepcopy.go

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

10 changes: 10 additions & 0 deletions config/crd/bases/apps.kubeblocks.io_componentdefinitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5777,6 +5777,16 @@ spec:
- scrapePort
type: object
type: object
podManagementPolicy:
description: |-
InstanceSet controls the creation of pods during initial scale up, replacement of pods on nodes, and scaling down.


- `OrderedReady`: Creates pods in increasing order (pod-0, then pod-1, etc). The controller waits until each pod
is ready before continuing. Pods are removed in reverse order when scaling down.
- `Parallel`: Creates pods in parallel to match the desired scale without waiting. All pods are deleted at once
when scaling down.
type: string
policyRules:
description: |-
Defines the namespaced policy rules required by the Component.
Expand Down
10 changes: 10 additions & 0 deletions deploy/helm/crds/apps.kubeblocks.io_componentdefinitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5777,6 +5777,16 @@ spec:
- scrapePort
type: object
type: object
podManagementPolicy:
description: |-
InstanceSet controls the creation of pods during initial scale up, replacement of pods on nodes, and scaling down.


- `OrderedReady`: Creates pods in increasing order (pod-0, then pod-1, etc). The controller waits until each pod
is ready before continuing. Pods are removed in reverse order when scaling down.
- `Parallel`: Creates pods in parallel to match the desired scale without waiting. All pods are deleted at once
when scaling down.
type: string
policyRules:
description: |-
Defines the namespaced policy rules required by the Component.
Expand Down
40 changes: 40 additions & 0 deletions docs/developer_docs/api-reference/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,26 @@ at least 3 operational for quorum.</li>
</tr>
<tr>
<td>
<code>podManagementPolicy</code><br/>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#podmanagementpolicytype-v1-apps">
Kubernetes apps/v1.PodManagementPolicyType
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>InstanceSet controls the creation of pods during initial scale up, replacement of pods on nodes, and scaling down.</p>
<ul>
<li><code>OrderedReady</code>: Creates pods in increasing order (pod-0, then pod-1, etc). The controller waits until each pod
is ready before continuing. Pods are removed in reverse order when scaling down.</li>
<li><code>Parallel</code>: Creates pods in parallel to match the desired scale without waiting. All pods are deleted at once
when scaling down.</li>
</ul>
</td>
</tr>
<tr>
<td>
<code>roles</code><br/>
<em>
<a href="#apps.kubeblocks.io/v1alpha1.ReplicaRole">
Expand Down Expand Up @@ -7696,6 +7716,26 @@ at least 3 operational for quorum.</li>
</tr>
<tr>
<td>
<code>podManagementPolicy</code><br/>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#podmanagementpolicytype-v1-apps">
Kubernetes apps/v1.PodManagementPolicyType
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>InstanceSet controls the creation of pods during initial scale up, replacement of pods on nodes, and scaling down.</p>
<ul>
<li><code>OrderedReady</code>: Creates pods in increasing order (pod-0, then pod-1, etc). The controller waits until each pod
is ready before continuing. Pods are removed in reverse order when scaling down.</li>
<li><code>Parallel</code>: Creates pods in parallel to match the desired scale without waiting. All pods are deleted at once
when scaling down.</li>
</ul>
</td>
</tr>
<tr>
<td>
<code>roles</code><br/>
<em>
<a href="#apps.kubeblocks.io/v1alpha1.ReplicaRole">
Expand Down
57 changes: 29 additions & 28 deletions pkg/controller/component/synthesize_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,34 +147,35 @@ func buildSynthesizedComponent(reqCtx intctrlutil.RequestCtx,
}
compDefObj := compDef.DeepCopy()
synthesizeComp := &SynthesizedComponent{
Namespace: comp.Namespace,
ClusterName: clusterName,
ClusterUID: clusterUID,
Comp2CompDefs: comp2CompDef,
Name: compName,
FullCompName: comp.Name,
CompDefName: compDef.Name,
ServiceVersion: comp.Spec.ServiceVersion,
ClusterGeneration: clusterGeneration(cluster, comp),
PodSpec: &compDef.Spec.Runtime,
HostNetwork: compDefObj.Spec.HostNetwork,
ComponentServices: compDefObj.Spec.Services,
LogConfigs: compDefObj.Spec.LogConfigs,
ConfigTemplates: compDefObj.Spec.Configs,
ScriptTemplates: compDefObj.Spec.Scripts,
Roles: compDefObj.Spec.Roles,
UpdateStrategy: compDefObj.Spec.UpdateStrategy,
MinReadySeconds: compDefObj.Spec.MinReadySeconds,
PolicyRules: compDefObj.Spec.PolicyRules,
LifecycleActions: compDefObj.Spec.LifecycleActions,
SystemAccounts: mergeSystemAccounts(compDefObj.Spec.SystemAccounts, comp.Spec.SystemAccounts),
Replicas: comp.Spec.Replicas,
Resources: comp.Spec.Resources,
TLSConfig: comp.Spec.TLSConfig,
ServiceAccountName: comp.Spec.ServiceAccountName,
Instances: comp.Spec.Instances,
OfflineInstances: comp.Spec.OfflineInstances,
DisableExporter: comp.Spec.DisableExporter,
Namespace: comp.Namespace,
ClusterName: clusterName,
ClusterUID: clusterUID,
Comp2CompDefs: comp2CompDef,
Name: compName,
FullCompName: comp.Name,
CompDefName: compDef.Name,
ServiceVersion: comp.Spec.ServiceVersion,
ClusterGeneration: clusterGeneration(cluster, comp),
PodSpec: &compDef.Spec.Runtime,
HostNetwork: compDefObj.Spec.HostNetwork,
ComponentServices: compDefObj.Spec.Services,
LogConfigs: compDefObj.Spec.LogConfigs,
ConfigTemplates: compDefObj.Spec.Configs,
ScriptTemplates: compDefObj.Spec.Scripts,
Roles: compDefObj.Spec.Roles,
UpdateStrategy: compDefObj.Spec.UpdateStrategy,
MinReadySeconds: compDefObj.Spec.MinReadySeconds,
PolicyRules: compDefObj.Spec.PolicyRules,
LifecycleActions: compDefObj.Spec.LifecycleActions,
SystemAccounts: mergeSystemAccounts(compDefObj.Spec.SystemAccounts, comp.Spec.SystemAccounts),
Replicas: comp.Spec.Replicas,
Resources: comp.Spec.Resources,
TLSConfig: comp.Spec.TLSConfig,
ServiceAccountName: comp.Spec.ServiceAccountName,
Instances: comp.Spec.Instances,
OfflineInstances: comp.Spec.OfflineInstances,
DisableExporter: comp.Spec.DisableExporter,
PodManagementPolicy: compDef.Spec.PodManagementPolicy,
}

// build backward compatible fields, including workload, services, componentRefEnvs, clusterDefName, clusterCompDefName, and clusterCompVer, etc.
Expand Down
Loading