Skip to content

Commit

Permalink
Set Arbiter defaults
Browse files Browse the repository at this point in the history
Signed-off-by: Neaj Morshad <[email protected]>
  • Loading branch information
Neaj-Morshad-101 committed Dec 10, 2024
1 parent c04771c commit cd32783
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apis/kubedb/v1alpha2/mssqlserver_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"
"k8s.io/utils/ptr"
kmapi "kmodules.xyz/client-go/api/v1"
"kmodules.xyz/client-go/apiextensions"
coreutil "kmodules.xyz/client-go/core/v1"
Expand Down Expand Up @@ -380,6 +381,8 @@ func (m *MSSQLServer) SetDefaults() {
return
}

m.SetArbiterDefault()

m.setDefaultContainerSecurityContext(&mssqlVersion, m.Spec.PodTemplate)

m.SetTLSDefaults()
Expand Down Expand Up @@ -506,6 +509,15 @@ func (m *MSSQLServer) setDefaultContainerResourceLimits(podTemplate *ofst.PodTem
}
}

func (m *MSSQLServer) SetArbiterDefault() {
if m.IsAvailabilityGroup() && ptr.Deref(m.Spec.Replicas, 0)%2 == 0 && m.Spec.Arbiter == nil {
m.Spec.Arbiter = &ArbiterSpec{
Resources: core.ResourceRequirements{},
}
apis.SetDefaultResourceLimits(&m.Spec.Arbiter.Resources, kubedb.DefaultArbiter(false))
}
}

func (m *MSSQLServer) SetTLSDefaults() {
if m.Spec.TLS == nil || m.Spec.TLS.IssuerRef == nil {
return
Expand Down

0 comments on commit cd32783

Please sign in to comment.