Skip to content
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: 2 additions & 0 deletions api/v1alpha1/typesensecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ type TypesenseClusterSpec struct {

Ingress *IngressSpec `json:"ingress,omitempty"`

Service *ServiceSpec `json:"service,omitempty"`

HttpRoutes []HttpRouteSpec `json:"httpRoutes,omitempty"`

Scrapers []DocSearchScraperSpec `json:"scrapers,omitempty"`
Expand Down
17 changes: 17 additions & 0 deletions api/v1alpha1/typesensecluster_types_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
)

type ServiceSpec struct {
// +optional
// +kubebuilder:default:="ClusterIP"
// +kubebuilder:validation:Enum=ClusterIP;LoadBalancer
Type corev1.ServiceType `json:"type"`

// +optional
// +kubebuilder:default:="Cluster"
// +kubebuilder:validation:Enum=Cluster;Local
ExternalTrafficPolicy corev1.ServiceExternalTrafficPolicy `json:"externalTrafficPolicy,omitempty"`
}
6 changes: 6 additions & 0 deletions internal/controller/typesensecluster_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ func (r *TypesenseClusterReconciler) createService(ctx context.Context, key clie
},
}

svcSpec := ts.Spec.Service
if svcSpec != nil {
svc.Spec.Type = svcSpec.Type
svc.Spec.ExternalTrafficPolicy = svcSpec.ExternalTrafficPolicy
}

err := ctrl.SetControllerReference(ts, svc, r.Scheme)
if err != nil {
return nil, err
Expand Down