11package config
22
33import (
4+ corev1 "k8s.io/api/core/v1"
45 "k8s.io/apimachinery/pkg/util/validation/field"
6+ "k8s.io/utils/ptr"
57
68 commonapi "github.com/openmcp-project/openmcp-operator/api/common"
79 corev2alpha1 "github.com/openmcp-project/openmcp-operator/api/core/v2alpha1"
@@ -23,6 +25,21 @@ type ManagedControlPlaneConfig struct {
2325 // A value of 0 disables the periodic reconciliation.
2426 // +optional
2527 ReconcileMCPEveryXDays int `json:"reconcileMCPEveryXDays,omitempty"`
28+
29+ // PlatformService specifies the configuration for the ManagedControlPlane platform service.
30+ PlatformService ManagedControlPlaneConfigPlatformService `json:"platformService,omitempty"`
31+ }
32+ type ManagedControlPlaneConfigPlatformService struct {
33+ // Replicas specifies the default number of replicas for ManagedControlPlane platform service.
34+ // Default is 1.
35+ // +optional
36+ Replicas * int32 `json:"replicas,omitempty"`
37+
38+ // TopologySpreadConstraints specifies the default topology spread constraints for ManagedControlPlane platform service.
39+ // More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/
40+ // The label selector for the topology spread constraints is set to match the labels of the ManagedControlPlane platform service.
41+ // +optional
42+ TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
2643}
2744
2845func (c * ManagedControlPlaneConfig ) Default (_ * field.Path ) error {
@@ -35,6 +52,9 @@ func (c *ManagedControlPlaneConfig) Default(_ *field.Path) error {
3552 if c .MCPClusterPurpose == "" {
3653 c .MCPClusterPurpose = corev2alpha1 .DefaultMCPClusterPurpose
3754 }
55+ if c .PlatformService .Replicas == nil {
56+ c .PlatformService .Replicas = ptr.To [int32 ](1 )
57+ }
3858 return nil
3959}
4060
@@ -56,6 +76,9 @@ func (c *ManagedControlPlaneConfig) Validate(fldPath *field.Path) error {
5676 errs = append (errs , field .Invalid (oidcFldPath .Child ("name" ), c .DefaultOIDCProvider .Name , "'system' is a reserved string and may not be used as name for the default OIDC provider" ))
5777 }
5878 }
79+ if c .PlatformService .Replicas != nil && * c .PlatformService .Replicas < 1 {
80+ errs = append (errs , field .Invalid (fldPath .Child ("replicas" ), c .PlatformService .Replicas , "replicas must be at least 1" ))
81+ }
5982
6083 return errs .ToAggregate ()
6184}
0 commit comments