Skip to content

Commit

Permalink
chore: obtain pods for specific roles (#7985)
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-inf committed Aug 20, 2024
1 parent 979b27f commit 7650afa
Show file tree
Hide file tree
Showing 7 changed files with 352 additions and 60 deletions.
27 changes: 23 additions & 4 deletions apis/apps/v1alpha1/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ const (
ConditionTypeApplyResources = "ApplyResources" // ConditionTypeApplyResources the operator start to apply resources to create or change the cluster
ConditionTypeReplicasReady = "ReplicasReady" // ConditionTypeReplicasReady all pods of components are ready
ConditionTypeReady = "Ready" // ConditionTypeReady all components are running
ConditionTypeSwitchoverPrefix = "Switchover-" // ConditionTypeSwitchoverPrefix component status condition of switchover
)

// Phase represents the current status of the ClusterDefinition CR.
Expand Down Expand Up @@ -914,6 +913,14 @@ type NamedVar struct {
Option *VarOption `json:"option,omitempty"`
}

type RoledVar struct {
// +optional
Role string `json:"role,omitempty"`

// +optional
Option *VarOption `json:"option,omitempty"`
}

// ContainerVars defines the vars that can be referenced from a Container.
type ContainerVars struct {
// The name of the container.
Expand Down Expand Up @@ -1035,17 +1042,29 @@ type ComponentVars struct {
// +optional
Replicas *VarOption `json:"replicas,omitempty"`

// Reference to the instanceName list of the component.
// and the value will be presented in the following format: instanceName1,instanceName2,...
// Reference to the pod name list of the component.
// and the value will be presented in the following format: name1,name2,...
//
// +optional
InstanceNames *VarOption `json:"instanceNames,omitempty"`
PodNames *VarOption `json:"podNames,omitempty"`

// Reference to the pod FQDN list of the component.
// The value will be presented in the following format: FQDN1,FQDN2,...
//
// +optional
PodFQDNs *VarOption `json:"podFQDNs,omitempty"`

// Reference to the pod name list of the component that have a specific role.
// The value will be presented in the following format: name1,name2,...
//
// +optional
PodNamesForRole *RoledVar `json:"podNamesForRole,omitempty"`

// Reference to the pod FQDN list of the component that have a specific role.
// The value will be presented in the following format: FQDN1,FQDN2,...
//
// +optional
PodFQDNsForRole *RoledVar `json:"podFQDNsForRole,omitempty"`
}

// ClusterVarSelector selects a var from a Cluster.
Expand Down
34 changes: 32 additions & 2 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.

46 changes: 38 additions & 8 deletions config/crd/bases/apps.kubeblocks.io_componentdefinitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12549,14 +12549,6 @@ spec:
- Required
- Optional
type: string
instanceNames:
description: |-
Reference to the instanceName list of the component.
and the value will be presented in the following format: instanceName1,instanceName2,...
enum:
- Required
- Optional
type: string
multipleClusterObjectOption:
description: |-
This option defines the behavior when multiple component objects match the specified @CompDef.
Expand Down Expand Up @@ -12621,6 +12613,44 @@ spec:
- Required
- Optional
type: string
podFQDNsForRole:
description: |-
Reference to the pod FQDN list of the component that have a specific role.
The value will be presented in the following format: FQDN1,FQDN2,...
properties:
option:
description: VarOption defines whether a variable
is required or optional.
enum:
- Required
- Optional
type: string
role:
type: string
type: object
podNames:
description: |-
Reference to the pod name list of the component.
and the value will be presented in the following format: name1,name2,...
enum:
- Required
- Optional
type: string
podNamesForRole:
description: |-
Reference to the pod name list of the component that have a specific role.
The value will be presented in the following format: name1,name2,...
properties:
option:
description: VarOption defines whether a variable
is required or optional.
enum:
- Required
- Optional
type: string
role:
type: string
type: object
replicas:
description: Reference to the replicas of the component.
enum:
Expand Down
46 changes: 38 additions & 8 deletions deploy/helm/crds/apps.kubeblocks.io_componentdefinitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12549,14 +12549,6 @@ spec:
- Required
- Optional
type: string
instanceNames:
description: |-
Reference to the instanceName list of the component.
and the value will be presented in the following format: instanceName1,instanceName2,...
enum:
- Required
- Optional
type: string
multipleClusterObjectOption:
description: |-
This option defines the behavior when multiple component objects match the specified @CompDef.
Expand Down Expand Up @@ -12621,6 +12613,44 @@ spec:
- Required
- Optional
type: string
podFQDNsForRole:
description: |-
Reference to the pod FQDN list of the component that have a specific role.
The value will be presented in the following format: FQDN1,FQDN2,...
properties:
option:
description: VarOption defines whether a variable
is required or optional.
enum:
- Required
- Optional
type: string
role:
type: string
type: object
podNames:
description: |-
Reference to the pod name list of the component.
and the value will be presented in the following format: name1,name2,...
enum:
- Required
- Optional
type: string
podNamesForRole:
description: |-
Reference to the pod name list of the component that have a specific role.
The value will be presented in the following format: name1,name2,...
properties:
option:
description: VarOption defines whether a variable
is required or optional.
enum:
- Required
- Optional
type: string
role:
type: string
type: object
replicas:
description: Reference to the replicas of the component.
enum:
Expand Down
79 changes: 75 additions & 4 deletions docs/developer_docs/api-reference/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -8115,7 +8115,7 @@ VarOption
</tr>
<tr>
<td>
<code>instanceNames</code><br/>
<code>podNames</code><br/>
<em>
<a href="#apps.kubeblocks.io/v1alpha1.VarOption">
VarOption
Expand All @@ -8124,8 +8124,8 @@ VarOption
</td>
<td>
<em>(Optional)</em>
<p>Reference to the instanceName list of the component.
and the value will be presented in the following format: instanceName1,instanceName2,&hellip;</p>
<p>Reference to the pod name list of the component.
and the value will be presented in the following format: name1,name2,&hellip;</p>
</td>
</tr>
<tr>
Expand All @@ -8143,6 +8143,36 @@ VarOption
The value will be presented in the following format: FQDN1,FQDN2,&hellip;</p>
</td>
</tr>
<tr>
<td>
<code>podNamesForRole</code><br/>
<em>
<a href="#apps.kubeblocks.io/v1alpha1.RoledVar">
RoledVar
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Reference to the pod name list of the component that have a specific role.
The value will be presented in the following format: name1,name2,&hellip;</p>
</td>
</tr>
<tr>
<td>
<code>podFQDNsForRole</code><br/>
<em>
<a href="#apps.kubeblocks.io/v1alpha1.RoledVar">
RoledVar
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Reference to the pod FQDN list of the component that have a specific role.
The value will be presented in the following format: FQDN1,FQDN2,&hellip;</p>
</td>
</tr>
</tbody>
</table>
<h3 id="apps.kubeblocks.io/v1alpha1.ComponentVersionCompatibilityRule">ComponentVersionCompatibilityRule
Expand Down Expand Up @@ -14927,6 +14957,47 @@ This value is set to 0 by default, indicating that there will be no delay betwee
</tr>
</tbody>
</table>
<h3 id="apps.kubeblocks.io/v1alpha1.RoledVar">RoledVar
</h3>
<p>
(<em>Appears on:</em><a href="#apps.kubeblocks.io/v1alpha1.ComponentVars">ComponentVars</a>)
</p>
<div>
</div>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>role</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
</td>
</tr>
<tr>
<td>
<code>option</code><br/>
<em>
<a href="#apps.kubeblocks.io/v1alpha1.VarOption">
VarOption
</a>
</em>
</td>
<td>
<em>(Optional)</em>
</td>
</tr>
</tbody>
</table>
<h3 id="apps.kubeblocks.io/v1alpha1.Rule">Rule
</h3>
<p>
Expand Down Expand Up @@ -17813,7 +17884,7 @@ string
<h3 id="apps.kubeblocks.io/v1alpha1.VarOption">VarOption
(<code>string</code> alias)</h3>
<p>
(<em>Appears on:</em><a href="#apps.kubeblocks.io/v1alpha1.ClusterVars">ClusterVars</a>, <a href="#apps.kubeblocks.io/v1alpha1.ComponentVars">ComponentVars</a>, <a href="#apps.kubeblocks.io/v1alpha1.CredentialVars">CredentialVars</a>, <a href="#apps.kubeblocks.io/v1alpha1.NamedVar">NamedVar</a>, <a href="#apps.kubeblocks.io/v1alpha1.ServiceRefVars">ServiceRefVars</a>, <a href="#apps.kubeblocks.io/v1alpha1.ServiceVars">ServiceVars</a>)
(<em>Appears on:</em><a href="#apps.kubeblocks.io/v1alpha1.ClusterVars">ClusterVars</a>, <a href="#apps.kubeblocks.io/v1alpha1.ComponentVars">ComponentVars</a>, <a href="#apps.kubeblocks.io/v1alpha1.CredentialVars">CredentialVars</a>, <a href="#apps.kubeblocks.io/v1alpha1.NamedVar">NamedVar</a>, <a href="#apps.kubeblocks.io/v1alpha1.RoledVar">RoledVar</a>, <a href="#apps.kubeblocks.io/v1alpha1.ServiceRefVars">ServiceRefVars</a>, <a href="#apps.kubeblocks.io/v1alpha1.ServiceVars">ServiceVars</a>)
</p>
<div>
<p>VarOption defines whether a variable is required or optional.</p>
Expand Down
Loading

0 comments on commit 7650afa

Please sign in to comment.