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

Add Solr ops for vertical scaling and volume expansion #1261

Merged
merged 12 commits into from
Aug 2, 2024
13 changes: 13 additions & 0 deletions apis/kubedb/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,10 @@ const (
DatabaseWriteAccess = "DatabaseWriteAccess"
// check dependencies are ready
DatabaseDependencyReady = "DatabaseDependencyReady"
// update config secret for backup in solr
PatchConfigSecretUpdateForBackup = "PatchConfigSecretUpdatesForBackup"
// sync db to update configuration
SyncDatabaseForConfigurationUpdate = "SyncDatabaseForConfigurationUpdate"

// Condition reasons
DataRestoreStartedByExternalInitializer = "DataRestoreStartedByExternalInitializer"
Expand Down Expand Up @@ -923,6 +927,15 @@ const (
SolrConfAllowPathsValue = ""
SolrConfSolrCloudKey = "solrcloud"
SolrConfShardHandlerFactoryKey = "shardHandlerFactory"

ProxyDeploymentName = "s3proxy"
ProxyServiceName = "proxy-svc"
ProxySecretName = "proxy-env"
ProxyImage = "andrewgaul/s3proxy"
ArnobKumarSaha marked this conversation as resolved.
Show resolved Hide resolved
ProxyPortName = "http"
ProxyPortNumber = 80
ProxyContainerName = "proxy"
ProxyLabelsApp = "app"
)

// =========================== Druid Constants ============================
Expand Down
22 changes: 17 additions & 5 deletions apis/kubedb/v1alpha2/solr_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1alpha2

import (
"context"
"fmt"
"strings"

Expand All @@ -30,6 +31,8 @@ import (
v1 "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"
"kmodules.xyz/client-go/apiextensions"
coreutil "kmodules.xyz/client-go/core/v1"
meta_util "kmodules.xyz/client-go/meta"
Expand Down Expand Up @@ -230,7 +233,7 @@ func (s *Solr) PVCName(alias string) string {
return meta_util.NameWithSuffix(s.Name, alias)
}

func (s *Solr) SetDefaults(slVersion *catalog.SolrVersion) {
func (s *Solr) SetDefaults() {
if s.Spec.DeletionPolicy == "" {
s.Spec.DeletionPolicy = TerminationPolicyDelete
}
Expand Down Expand Up @@ -263,6 +266,15 @@ func (s *Solr) SetDefaults(slVersion *catalog.SolrVersion) {
}
}

var slVersion catalog.SolrVersion
err := DefaultClient.Get(context.TODO(), types.NamespacedName{
Name: s.Spec.Version,
}, &slVersion)
if err != nil {
klog.Errorf("can't get the solr version object %s for %s \n", err.Error(), s.Spec.Version)
return
}

if s.Spec.Topology != nil {
if s.Spec.Topology.Data != nil {
if s.Spec.Topology.Data.Suffix == "" {
Expand All @@ -275,7 +287,7 @@ func (s *Solr) SetDefaults(slVersion *catalog.SolrVersion) {
s.Spec.Topology.Data.PodTemplate.Spec.SecurityContext = &v1.PodSecurityContext{}
}
s.Spec.Topology.Data.PodTemplate.Spec.SecurityContext.FSGroup = slVersion.Spec.SecurityContext.RunAsUser
s.setDefaultContainerSecurityContext(slVersion, &s.Spec.Topology.Data.PodTemplate)
s.setDefaultContainerSecurityContext(&slVersion, &s.Spec.Topology.Data.PodTemplate)
s.setDefaultContainerResourceLimits(&s.Spec.Topology.Data.PodTemplate)

}
Expand All @@ -291,7 +303,7 @@ func (s *Solr) SetDefaults(slVersion *catalog.SolrVersion) {
s.Spec.Topology.Overseer.PodTemplate.Spec.SecurityContext = &v1.PodSecurityContext{}
}
s.Spec.Topology.Overseer.PodTemplate.Spec.SecurityContext.FSGroup = slVersion.Spec.SecurityContext.RunAsUser
s.setDefaultContainerSecurityContext(slVersion, &s.Spec.Topology.Overseer.PodTemplate)
s.setDefaultContainerSecurityContext(&slVersion, &s.Spec.Topology.Overseer.PodTemplate)
s.setDefaultContainerResourceLimits(&s.Spec.Topology.Overseer.PodTemplate)
}

Expand All @@ -306,7 +318,7 @@ func (s *Solr) SetDefaults(slVersion *catalog.SolrVersion) {
s.Spec.Topology.Coordinator.PodTemplate.Spec.SecurityContext = &v1.PodSecurityContext{}
}
s.Spec.Topology.Coordinator.PodTemplate.Spec.SecurityContext.FSGroup = slVersion.Spec.SecurityContext.RunAsUser
s.setDefaultContainerSecurityContext(slVersion, &s.Spec.Topology.Coordinator.PodTemplate)
s.setDefaultContainerSecurityContext(&slVersion, &s.Spec.Topology.Coordinator.PodTemplate)
s.setDefaultContainerResourceLimits(&s.Spec.Topology.Coordinator.PodTemplate)
}
} else {
Expand All @@ -317,7 +329,7 @@ func (s *Solr) SetDefaults(slVersion *catalog.SolrVersion) {
s.Spec.PodTemplate.Spec.SecurityContext = &v1.PodSecurityContext{}
}
s.Spec.PodTemplate.Spec.SecurityContext.FSGroup = slVersion.Spec.SecurityContext.RunAsUser
s.setDefaultContainerSecurityContext(slVersion, &s.Spec.PodTemplate)
s.setDefaultContainerSecurityContext(&slVersion, &s.Spec.PodTemplate)
s.setDefaultContainerResourceLimits(&s.Spec.PodTemplate)
}

Expand Down
10 changes: 1 addition & 9 deletions apis/kubedb/v1alpha2/solr_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/klog/v2"
ofst "kmodules.xyz/offshoot-api/api/v2"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
Expand All @@ -49,14 +48,7 @@ func (s *Solr) Default() {
}
solrlog.Info("default", "name", s.Name)

slVersion := catalog.SolrVersion{}
err := DefaultClient.Get(context.TODO(), types.NamespacedName{Name: s.Spec.Version}, &slVersion)
if err != nil {
klog.Errorf("Version does not exist.")
return
}

s.SetDefaults(&slVersion)
s.SetDefaults()
}

var _ webhook.Validator = &Solr{}
Expand Down
2 changes: 2 additions & 0 deletions apis/ops/v1alpha1/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ const (
VolumeExpansionMLNode = "VolumeExpansionMLNode"
VolumeExpansionTransformNode = "VolumeExpansionTransformNode"
VolumeExpansionCoordinatingNode = "VolumeExpansionCoordinatingNode"
VolumeExpansionOverseerNode = "VolumeExpansionOverseerNode"
VolumeExpansionCoordinatorNode = "VolumeExpansionCoordinatorNode"
)

// Kafka Constants
Expand Down
177 changes: 176 additions & 1 deletion apis/ops/v1alpha1/openapi_generated.go

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

Loading
Loading