Skip to content

Commit ad840e7

Browse files
authored
Support Service session affinity configuration (#761)
* Pull RCO@session-affinity dependency * Pull RCO@session-affinity and OLO@session-affinity * Nest session affinity settings in service spec * Update go.sum
1 parent fee5a93 commit ad840e7

9 files changed

+161
-7
lines changed

api/v1/webspherelibertyapplication_types.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
prometheusv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
2525
appsv1 "k8s.io/api/apps/v1"
2626
corev1 "k8s.io/api/core/v1"
27+
v1 "k8s.io/api/core/v1"
2728
networkingv1 "k8s.io/api/networking/v1"
2829
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2930
"k8s.io/apimachinery/pkg/util/intstr"
@@ -383,6 +384,21 @@ type WebSphereLibertyApplicationService struct {
383384
// Expose the application as a bindable service. Defaults to false.
384385
// +operator-sdk:csv:customresourcedefinitions:order=18,type=spec,displayName="Bindable",xDescriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch"
385386
Bindable *bool `json:"bindable,omitempty"`
387+
388+
// Configure service session affinity.
389+
// +operator-sdk:csv:customresourcedefinitions:order=19,type=spec
390+
SessionAffinity *WebSphereLibertyApplicationServiceSessionAffinity `json:"sessionAffinity,omitempty"`
391+
}
392+
393+
// Configure service session affinity
394+
type WebSphereLibertyApplicationServiceSessionAffinity struct {
395+
// Setting to maintain session affinity. Must be ClientIP or None. Defaults to None.
396+
// +operator-sdk:csv:customresourcedefinitions:order=20,type=spec,displayName="Session Affinity Type",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
397+
Type v1.ServiceAffinity `json:"type,omitempty"`
398+
399+
// Configurations of session affinity.
400+
// +operator-sdk:csv:customresourcedefinitions:order=21,type=spec
401+
Config *corev1.SessionAffinityConfig `json:"config,omitempty"`
386402
}
387403

388404
// Configure service certificate.
@@ -1177,6 +1193,24 @@ func (s *WebSphereLibertyApplicationService) GetBindable() *bool {
11771193
return s.Bindable
11781194
}
11791195

1196+
// GetSessionAffinity returns the session affinity settings for the service
1197+
func (s *WebSphereLibertyApplicationService) GetSessionAffinity() common.BaseComponentServiceSessionAffinity {
1198+
if s.SessionAffinity == nil {
1199+
return nil
1200+
}
1201+
return s.SessionAffinity
1202+
}
1203+
1204+
// GetType returns the session affinity type for the service
1205+
func (ssa *WebSphereLibertyApplicationServiceSessionAffinity) GetType() v1.ServiceAffinity {
1206+
return ssa.Type
1207+
}
1208+
1209+
// GetConfig returns the session affinity configuration for the service
1210+
func (ssa *WebSphereLibertyApplicationServiceSessionAffinity) GetConfig() *corev1.SessionAffinityConfig {
1211+
return ssa.Config
1212+
}
1213+
11801214
// GetNamespaceLabels returns the namespace selector labels that should be used for the ingress rule
11811215
func (np *WebSphereLibertyApplicationNetworkPolicy) GetNamespaceLabels() map[string]string {
11821216
if np.NamespaceLabels != nil {

bundle/manifests/ibm-websphere-liberty.clusterserviceversion.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ metadata:
6161
capabilities: Auto Pilot
6262
categories: Application Runtime
6363
containerImage: icr.io/cpopen/websphere-liberty-operator:daily
64-
createdAt: "2025-06-17T18:31:12Z"
64+
createdAt: "2025-06-23T20:03:24Z"
6565
description: Deploy and manage containerized Liberty applications
6666
features.operators.openshift.io/disconnected: "true"
6767
olm.skipRange: '>=1.0.0 <1.4.3'
@@ -361,10 +361,19 @@ spec:
361361
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
362362
- displayName: Route
363363
path: route
364+
- description: Configure service session affinity.
365+
displayName: Session Affinity
366+
path: service.sessionAffinity
364367
- description: Configures the Semeru Cloud Compiler to handle Just-In-Time (JIT)
365368
compilation requests from the application.
366369
displayName: Semeru Cloud Compiler
367370
path: semeruCloudCompiler
371+
- description: Setting to maintain session affinity. Must be ClientIP or None.
372+
Defaults to None.
373+
displayName: Session Affinity Type
374+
path: service.sessionAffinity.type
375+
x-descriptors:
376+
- urn:alm:descriptor:com.tectonic.ui:text
368377
- description: Specifies the strategy to replace old deployment pods with new
369378
pods.
370379
displayName: Deployment Update Strategy
@@ -373,6 +382,9 @@ spec:
373382
- urn:alm:descriptor:com.tectonic.ui:updateStrategy
374383
- displayName: Network Policy
375384
path: networkPolicy
385+
- description: Configurations of session affinity.
386+
displayName: Config
387+
path: service.sessionAffinity.config
376388
- displayName: Serviceability
377389
path: serviceability
378390
- displayName: Single Sign-On

bundle/manifests/liberty.websphere.ibm.com_webspherelibertyapplications.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4861,6 +4861,30 @@ spec:
48614861
- port
48624862
type: object
48634863
type: array
4864+
sessionAffinity:
4865+
description: Configure service session affinity.
4866+
properties:
4867+
config:
4868+
description: Configurations of session affinity.
4869+
properties:
4870+
clientIP:
4871+
description: clientIP contains the configurations of Client
4872+
IP based session affinity.
4873+
properties:
4874+
timeoutSeconds:
4875+
description: |-
4876+
timeoutSeconds specifies the seconds of ClientIP type session sticky time.
4877+
The value must be >0 && <=86400(for 1 day) if ServiceAffinity == "ClientIP".
4878+
Default value is 10800(for 3 hours).
4879+
format: int32
4880+
type: integer
4881+
type: object
4882+
type: object
4883+
type:
4884+
description: Setting to maintain session affinity. Must be
4885+
ClientIP or None. Defaults to None.
4886+
type: string
4887+
type: object
48644888
targetPort:
48654889
description: The port that the operator assigns to containers
48664890
inside pods. Defaults to the value of .spec.service.port.

config/crd/bases/liberty.websphere.ibm.com_webspherelibertyapplications.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4857,6 +4857,30 @@ spec:
48574857
- port
48584858
type: object
48594859
type: array
4860+
sessionAffinity:
4861+
description: Configure service session affinity.
4862+
properties:
4863+
config:
4864+
description: Configurations of session affinity.
4865+
properties:
4866+
clientIP:
4867+
description: clientIP contains the configurations of Client
4868+
IP based session affinity.
4869+
properties:
4870+
timeoutSeconds:
4871+
description: |-
4872+
timeoutSeconds specifies the seconds of ClientIP type session sticky time.
4873+
The value must be >0 && <=86400(for 1 day) if ServiceAffinity == "ClientIP".
4874+
Default value is 10800(for 3 hours).
4875+
format: int32
4876+
type: integer
4877+
type: object
4878+
type: object
4879+
type:
4880+
description: Setting to maintain session affinity. Must be
4881+
ClientIP or None. Defaults to None.
4882+
type: string
4883+
type: object
48604884
targetPort:
48614885
description: The port that the operator assigns to containers
48624886
inside pods. Defaults to the value of .spec.service.port.

config/manifests/bases/ibm-websphere-liberty.clusterserviceversion.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,19 @@ spec:
303303
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
304304
- displayName: Route
305305
path: route
306+
- description: Configure service session affinity.
307+
displayName: Session Affinity
308+
path: service.sessionAffinity
306309
- description: Configures the Semeru Cloud Compiler to handle Just-In-Time (JIT)
307310
compilation requests from the application.
308311
displayName: Semeru Cloud Compiler
309312
path: semeruCloudCompiler
313+
- description: Setting to maintain session affinity. Must be ClientIP or None.
314+
Defaults to None.
315+
displayName: Session Affinity Type
316+
path: service.sessionAffinity.type
317+
x-descriptors:
318+
- urn:alm:descriptor:com.tectonic.ui:text
310319
- description: Specifies the strategy to replace old deployment pods with new
311320
pods.
312321
displayName: Deployment Update Strategy
@@ -315,6 +324,9 @@ spec:
315324
- urn:alm:descriptor:com.tectonic.ui:updateStrategy
316325
- displayName: Network Policy
317326
path: networkPolicy
327+
- description: Configurations of session affinity.
328+
displayName: Config
329+
path: service.sessionAffinity.config
318330
- displayName: Serviceability
319331
path: serviceability
320332
- displayName: Single Sign-On

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/WASdev/websphere-liberty-operator
33
go 1.24
44

55
require (
6-
github.com/OpenLiberty/open-liberty-operator v0.8.1-0.20250514135921-ad2e87dab892
7-
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20250617180439-ceaa4823386f
6+
github.com/OpenLiberty/open-liberty-operator v0.8.1-0.20250623195055-e479f9f3de50
7+
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20250623192823-bac4a89040d9
88
github.com/cert-manager/cert-manager v1.15.5
99
github.com/go-logr/logr v1.4.2
1010
github.com/openshift/api v0.0.0-20230928134114-673ed0cfc7f1

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d h
22
contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d/go.mod h1:IshRmMJBhDfFj5Y67nVhMYTTIze91RUeT73ipWKs/GY=
33
contrib.go.opencensus.io/exporter/prometheus v0.4.2 h1:sqfsYl5GIY/L570iT+l93ehxaWJs2/OwXtiWwew3oAg=
44
contrib.go.opencensus.io/exporter/prometheus v0.4.2/go.mod h1:dvEHbiKmgvbr5pjaF9fpw1KeYcjrnC1J8B+JKjsZyRQ=
5-
github.com/OpenLiberty/open-liberty-operator v0.8.1-0.20250514135921-ad2e87dab892 h1:rFlmehnejj1lgNtfbnalOrKezqsmA72wfnrbMsJ9v5Y=
6-
github.com/OpenLiberty/open-liberty-operator v0.8.1-0.20250514135921-ad2e87dab892/go.mod h1:aZ6kbfmHPvnmVrNHujX/bMuLLGQLLaATIFbb2jbs+uc=
7-
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20250617180439-ceaa4823386f h1:PKmSDGxKol8odz+mEfBcUEu6T3/v8JyExVwOWHxw1r4=
8-
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20250617180439-ceaa4823386f/go.mod h1:IWb2bp8hVEbKNUDRkfa5Pty3bSdOalGRDds/VMckYCA=
5+
github.com/OpenLiberty/open-liberty-operator v0.8.1-0.20250623195055-e479f9f3de50 h1:zvTbVjewCN8pHDRKgXMFVaQd4CvUODC50/BdI61lKps=
6+
github.com/OpenLiberty/open-liberty-operator v0.8.1-0.20250623195055-e479f9f3de50/go.mod h1:d5Yr/CrcLuRaEZV+PCsbQtxTE1gCAz6uFO0zA7Cj3C8=
7+
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20250623192823-bac4a89040d9 h1:kFQQjqmfPcbEuCPFWNtZliSsZAvT/uwVo2DkhfZQe34=
8+
github.com/application-stacks/runtime-component-operator v1.0.0-20220602-0850.0.20250623192823-bac4a89040d9/go.mod h1:IWb2bp8hVEbKNUDRkfa5Pty3bSdOalGRDds/VMckYCA=
99
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
1010
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
1111
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=

internal/deploy/kubectl/websphereliberty-app-crd.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4860,6 +4860,30 @@ spec:
48604860
- port
48614861
type: object
48624862
type: array
4863+
sessionAffinity:
4864+
description: Configure service session affinity.
4865+
properties:
4866+
config:
4867+
description: Configurations of session affinity.
4868+
properties:
4869+
clientIP:
4870+
description: clientIP contains the configurations of Client
4871+
IP based session affinity.
4872+
properties:
4873+
timeoutSeconds:
4874+
description: |-
4875+
timeoutSeconds specifies the seconds of ClientIP type session sticky time.
4876+
The value must be >0 && <=86400(for 1 day) if ServiceAffinity == "ClientIP".
4877+
Default value is 10800(for 3 hours).
4878+
format: int32
4879+
type: integer
4880+
type: object
4881+
type: object
4882+
type:
4883+
description: Setting to maintain session affinity. Must be
4884+
ClientIP or None. Defaults to None.
4885+
type: string
4886+
type: object
48634887
targetPort:
48644888
description: The port that the operator assigns to containers
48654889
inside pods. Defaults to the value of .spec.service.port.

internal/deploy/kustomize/daily/base/websphere-liberty-crd.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4860,6 +4860,30 @@ spec:
48604860
- port
48614861
type: object
48624862
type: array
4863+
sessionAffinity:
4864+
description: Configure service session affinity.
4865+
properties:
4866+
config:
4867+
description: Configurations of session affinity.
4868+
properties:
4869+
clientIP:
4870+
description: clientIP contains the configurations of Client
4871+
IP based session affinity.
4872+
properties:
4873+
timeoutSeconds:
4874+
description: |-
4875+
timeoutSeconds specifies the seconds of ClientIP type session sticky time.
4876+
The value must be >0 && <=86400(for 1 day) if ServiceAffinity == "ClientIP".
4877+
Default value is 10800(for 3 hours).
4878+
format: int32
4879+
type: integer
4880+
type: object
4881+
type: object
4882+
type:
4883+
description: Setting to maintain session affinity. Must be
4884+
ClientIP or None. Defaults to None.
4885+
type: string
4886+
type: object
48634887
targetPort:
48644888
description: The port that the operator assigns to containers
48654889
inside pods. Defaults to the value of .spec.service.port.

0 commit comments

Comments
 (0)