diff --git a/crds/sme.sap.com_capapplicationversions.yaml b/crds/sme.sap.com_capapplicationversions.yaml index 504c977..94e1894 100644 --- a/crds/sme.sap.com_capapplicationversions.yaml +++ b/crds/sme.sap.com_capapplicationversions.yaml @@ -45,6 +45,31 @@ spec: items: type: string type: array + serviceExposures: + items: + properties: + routes: + items: + properties: + path: + type: string + port: + format: int32 + type: integer + workloadName: + type: string + required: + - port + - workloadName + type: object + type: array + subDomain: + type: string + required: + - routes + - subDomain + type: object + type: array tenantOperations: properties: deprovisioning: diff --git a/pkg/apis/sme.sap.com/v1alpha1/types.go b/pkg/apis/sme.sap.com/v1alpha1/types.go index 7a9e036..9126af1 100644 --- a/pkg/apis/sme.sap.com/v1alpha1/types.go +++ b/pkg/apis/sme.sap.com/v1alpha1/types.go @@ -223,6 +223,8 @@ type CAPApplicationVersionSpec struct { TenantOperations *TenantOperations `json:"tenantOperations,omitempty"` // Content Jobs may be used to specify the sequence of content jobs when several jobs exist ContentJobs []string `json:"contentJobs,omitempty"` + // Configuration for the service(s) to be exposed (relevant only for 'Service' type deployment workloads) + ServiceExposures []ServiceExposure `json:"serviceExposures,omitempty"` } // WorkloadDetails specifies the details of the Workload @@ -258,6 +260,24 @@ type DeploymentDetails struct { Monitoring *WorkloadMonitoring `json:"monitoring,omitempty"` } +// ServiceExposure specifies the details of the VirtualService to be exposed for `Service` type workload(s) +type ServiceExposure struct { + // Subdomain under which the service is exposed (used as the Key for identifying the VirtualService) + SubDomain string `json:"subDomain"` + // Routes specifies the routing configuration (http match) for the exposed service + Routes []Route `json:"routes"` +} + +// Routing configuration (http match) for the exposed service +type Route struct { + // Name of the workload (eventually a service to route requests to); must be a valid workload name (Deployment) + WorkloadName string `json:"workloadName"` + // Port number used for the service (must be present in the workload/service) + Port int32 `json:"port"` + // A unique routing path used (as a match/prefix) to route requests to the workload (when omitted, "/" would be used) + Path string `json:"path,omitempty"` +} + // WorkloadMonitoring specifies the metrics related to the workload type WorkloadMonitoring struct { // DeletionRules specify the metrics conditions that need to be satisfied for the version to be deleted automatically. @@ -334,6 +354,8 @@ const ( DeploymentRouter DeploymentType = "Router" // Additional deployment type DeploymentAdditional DeploymentType = "Additional" + // Service deployment type + DeploymentService DeploymentType = "Service" ) // JobDetails specifies the details of the Job diff --git a/pkg/apis/sme.sap.com/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/sme.sap.com/v1alpha1/zz_generated.deepcopy.go index 883566e..5bc4029 100644 --- a/pkg/apis/sme.sap.com/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/sme.sap.com/v1alpha1/zz_generated.deepcopy.go @@ -263,6 +263,13 @@ func (in *CAPApplicationVersionSpec) DeepCopyInto(out *CAPApplicationVersionSpec *out = make([]string, len(*in)) copy(*out, *in) } + if in.ServiceExposures != nil { + in, out := &in.ServiceExposures, &out.ServiceExposures + *out = make([]ServiceExposure, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } @@ -881,6 +888,43 @@ func (in *Ports) DeepCopy() *Ports { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Route) DeepCopyInto(out *Route) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Route. +func (in *Route) DeepCopy() *Route { + if in == nil { + return nil + } + out := new(Route) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceExposure) DeepCopyInto(out *ServiceExposure) { + *out = *in + if in.Routes != nil { + in, out := &in.Routes, &out.Routes + *out = make([]Route, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceExposure. +func (in *ServiceExposure) DeepCopy() *ServiceExposure { + if in == nil { + return nil + } + out := new(ServiceExposure) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServiceInfo) DeepCopyInto(out *ServiceInfo) { *out = *in diff --git a/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/capapplicationversionspec.go b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/capapplicationversionspec.go index dc44795..6f8df36 100644 --- a/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/capapplicationversionspec.go +++ b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/capapplicationversionspec.go @@ -16,6 +16,7 @@ type CAPApplicationVersionSpecApplyConfiguration struct { Workloads []WorkloadDetailsApplyConfiguration `json:"workloads,omitempty"` TenantOperations *TenantOperationsApplyConfiguration `json:"tenantOperations,omitempty"` ContentJobs []string `json:"contentJobs,omitempty"` + ServiceExposures []ServiceExposureApplyConfiguration `json:"serviceExposures,omitempty"` } // CAPApplicationVersionSpecApplyConfiguration constructs a declarative configuration of the CAPApplicationVersionSpec type for use with @@ -80,3 +81,16 @@ func (b *CAPApplicationVersionSpecApplyConfiguration) WithContentJobs(values ... } return b } + +// WithServiceExposures adds the given value to the ServiceExposures field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the ServiceExposures field. +func (b *CAPApplicationVersionSpecApplyConfiguration) WithServiceExposures(values ...*ServiceExposureApplyConfiguration) *CAPApplicationVersionSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithServiceExposures") + } + b.ServiceExposures = append(b.ServiceExposures, *values[i]) + } + return b +} diff --git a/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/route.go b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/route.go new file mode 100644 index 0000000..6124b07 --- /dev/null +++ b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/route.go @@ -0,0 +1,46 @@ +/* +SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// RouteApplyConfiguration represents a declarative configuration of the Route type for use +// with apply. +type RouteApplyConfiguration struct { + WorkloadName *string `json:"workloadName,omitempty"` + Port *int32 `json:"port,omitempty"` + Path *string `json:"path,omitempty"` +} + +// RouteApplyConfiguration constructs a declarative configuration of the Route type for use with +// apply. +func Route() *RouteApplyConfiguration { + return &RouteApplyConfiguration{} +} + +// WithWorkloadName sets the WorkloadName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the WorkloadName field is set to the value of the last call. +func (b *RouteApplyConfiguration) WithWorkloadName(value string) *RouteApplyConfiguration { + b.WorkloadName = &value + return b +} + +// WithPort sets the Port field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Port field is set to the value of the last call. +func (b *RouteApplyConfiguration) WithPort(value int32) *RouteApplyConfiguration { + b.Port = &value + return b +} + +// WithPath sets the Path field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Path field is set to the value of the last call. +func (b *RouteApplyConfiguration) WithPath(value string) *RouteApplyConfiguration { + b.Path = &value + return b +} diff --git a/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/serviceexposure.go b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/serviceexposure.go new file mode 100644 index 0000000..4bba909 --- /dev/null +++ b/pkg/client/applyconfiguration/sme.sap.com/v1alpha1/serviceexposure.go @@ -0,0 +1,42 @@ +/* +SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and cap-operator contributors +SPDX-License-Identifier: Apache-2.0 +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// ServiceExposureApplyConfiguration represents a declarative configuration of the ServiceExposure type for use +// with apply. +type ServiceExposureApplyConfiguration struct { + SubDomain *string `json:"subDomain,omitempty"` + Routes []RouteApplyConfiguration `json:"routes,omitempty"` +} + +// ServiceExposureApplyConfiguration constructs a declarative configuration of the ServiceExposure type for use with +// apply. +func ServiceExposure() *ServiceExposureApplyConfiguration { + return &ServiceExposureApplyConfiguration{} +} + +// WithSubDomain sets the SubDomain field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the SubDomain field is set to the value of the last call. +func (b *ServiceExposureApplyConfiguration) WithSubDomain(value string) *ServiceExposureApplyConfiguration { + b.SubDomain = &value + return b +} + +// WithRoutes adds the given value to the Routes field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Routes field. +func (b *ServiceExposureApplyConfiguration) WithRoutes(values ...*RouteApplyConfiguration) *ServiceExposureApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithRoutes") + } + b.Routes = append(b.Routes, *values[i]) + } + return b +} diff --git a/pkg/client/applyconfiguration/utils.go b/pkg/client/applyconfiguration/utils.go index daee057..be4bc17 100644 --- a/pkg/client/applyconfiguration/utils.go +++ b/pkg/client/applyconfiguration/utils.go @@ -75,6 +75,10 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &smesapcomv1alpha1.NameValueApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("Ports"): return &smesapcomv1alpha1.PortsApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Route"): + return &smesapcomv1alpha1.RouteApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ServiceExposure"): + return &smesapcomv1alpha1.ServiceExposureApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("ServiceInfo"): return &smesapcomv1alpha1.ServiceInfoApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("TenantOperations"):