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

chore: reconcile to preserve the default service type #8506

Merged
merged 1 commit into from
Nov 22, 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
2 changes: 1 addition & 1 deletion apis/apps/v1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ type ClusterComponentSpec struct {
// +optional
Volumes []corev1.Volume `json:"volumes,omitempty"`

// Overrides services defined in referenced ComponentDefinition and expose endpoints that can be accessed by clients.
// Overrides services defined in referenced ComponentDefinition.
//
// +optional
Services []ClusterComponentService `json:"services,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion apis/apps/v1/component_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ type ComponentSpec struct {
// +optional
Volumes []corev1.Volume `json:"volumes,omitempty"`

// Overrides Services defined in referenced ComponentDefinition and exposes endpoints that can be accessed by clients.
// Overrides Services defined in referenced ComponentDefinition.
//
// +optional
Services []ComponentService `json:"services,omitempty"`
Expand Down
6 changes: 2 additions & 4 deletions config/crd/bases/apps.kubeblocks.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5217,8 +5217,7 @@ spec:
maxLength: 32
type: string
services:
description: Overrides services defined in referenced ComponentDefinition
and expose endpoints that can be accessed by clients.
description: Overrides services defined in referenced ComponentDefinition.
items:
properties:
annotations:
Expand Down Expand Up @@ -13919,8 +13918,7 @@ spec:
maxLength: 32
type: string
services:
description: Overrides services defined in referenced ComponentDefinition
and expose endpoints that can be accessed by clients.
description: Overrides services defined in referenced ComponentDefinition.
items:
properties:
annotations:
Expand Down
3 changes: 1 addition & 2 deletions config/crd/bases/apps.kubeblocks.io_components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4987,8 +4987,7 @@ spec:
maxLength: 32
type: string
services:
description: Overrides Services defined in referenced ComponentDefinition
and exposes endpoints that can be accessed by clients.
description: Overrides Services defined in referenced ComponentDefinition.
items:
description: |-
ComponentService defines a service that would be exposed as an inter-component service within a Cluster.
Expand Down
7 changes: 6 additions & 1 deletion controllers/apps/transformer_component_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ func (t *componentServiceTransformer) buildService(comp *appsv1.Component,
AddSelectorsInMap(t.builtinSelector(comp)).
Optimize4ExternalTraffic()

// explicitly set the service type to ClusterIP if not specified
if service.Spec.Type == "" {
builder.SetType(corev1.ServiceTypeClusterIP)
}

if len(service.RoleSelector) > 0 && (service.PodService == nil || !*service.PodService) {
if err := t.checkRoleSelector(synthesizeComp, service.Name, service.RoleSelector); err != nil {
return nil, err
Expand Down Expand Up @@ -296,7 +301,7 @@ func (t *componentServiceTransformer) createOrUpdateService(ctx graph.TransformC
return err
}

// don't update service not owned by the owner, to keep compatible with existed cluster
// don't update service not owned by the component, to keep compatible with existed cluster
if !model.IsOwnerOf(owner, originSvc) {
return nil
}
Expand Down
6 changes: 2 additions & 4 deletions deploy/helm/crds/apps.kubeblocks.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5217,8 +5217,7 @@ spec:
maxLength: 32
type: string
services:
description: Overrides services defined in referenced ComponentDefinition
and expose endpoints that can be accessed by clients.
description: Overrides services defined in referenced ComponentDefinition.
items:
properties:
annotations:
Expand Down Expand Up @@ -13919,8 +13918,7 @@ spec:
maxLength: 32
type: string
services:
description: Overrides services defined in referenced ComponentDefinition
and expose endpoints that can be accessed by clients.
description: Overrides services defined in referenced ComponentDefinition.
items:
properties:
annotations:
Expand Down
3 changes: 1 addition & 2 deletions deploy/helm/crds/apps.kubeblocks.io_components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4987,8 +4987,7 @@ spec:
maxLength: 32
type: string
services:
description: Overrides Services defined in referenced ComponentDefinition
and exposes endpoints that can be accessed by clients.
description: Overrides Services defined in referenced ComponentDefinition.
items:
description: |-
ComponentService defines a service that would be exposed as an inter-component service within a Cluster.
Expand Down
6 changes: 3 additions & 3 deletions docs/developer_docs/api-reference/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ These templates are used to dynamically provision persistent volumes for the Com
</td>
<td>
<em>(Optional)</em>
<p>Overrides Services defined in referenced ComponentDefinition and exposes endpoints that can be accessed by clients.</p>
<p>Overrides Services defined in referenced ComponentDefinition.</p>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -2883,7 +2883,7 @@ These templates are used to dynamically provision persistent volumes for the Com
</td>
<td>
<em>(Optional)</em>
<p>Overrides services defined in referenced ComponentDefinition and expose endpoints that can be accessed by clients.</p>
<p>Overrides services defined in referenced ComponentDefinition.</p>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -6044,7 +6044,7 @@ These templates are used to dynamically provision persistent volumes for the Com
</td>
<td>
<em>(Optional)</em>
<p>Overrides Services defined in referenced ComponentDefinition and exposes endpoints that can be accessed by clients.</p>
<p>Overrides Services defined in referenced ComponentDefinition.</p>
</td>
</tr>
<tr>
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/component/synthesize_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"

appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
Expand Down Expand Up @@ -376,7 +377,7 @@ func overrideComponentServices(synthesizeComp *SynthesizedComponent, comp *appsv
svc.Annotations = svc1.Annotations
svc.PodService = svc1.PodService
if svc.DisableAutoProvision != nil {
svc.DisableAutoProvision = func() *bool { b := false; return &b }()
svc.DisableAutoProvision = ptr.To(false)
}
}
}
Expand Down
Loading