Skip to content

Commit d0fa452

Browse files
committed
Add semeru health port flag
1 parent a272ec6 commit d0fa452

File tree

8 files changed

+87
-13
lines changed

8 files changed

+87
-13
lines changed

api/v1/webspherelibertyapplication_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,9 @@ type WebSphereLibertyApplicationSemeruCloudCompiler struct {
520520
// Resource requests and limits for the Semeru Cloud Compiler. The CPU defaults to 100m with a limit of 2000m. The memory defaults to 800Mi, with a limit of 1200Mi.
521521
// +operator-sdk:csv:customresourcedefinitions:order=54,type=spec,displayName="Resource Requirements",xDescriptors="urn:alm:descriptor:com.tectonic.ui:resourceRequirements"
522522
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
523+
// The health port for the Semeru Cloud Compiler. Defaults to 38600.
524+
// +operator-sdk:csv:customresourcedefinitions:order=55,type=spec,displayName="Port",xDescriptors="urn:alm:descriptor:com.tectonic.ui:number"
525+
Port *int32 `json:"port,omitempty"`
523526
}
524527

525528
// Defines SemeruCompiler status
@@ -1287,6 +1290,14 @@ func (scc *WebSphereLibertyApplicationSemeruCloudCompiler) GetReplicas() *int32
12871290
return &one
12881291
}
12891292

1293+
func (scc *WebSphereLibertyApplicationSemeruCloudCompiler) GetPort() *int32 {
1294+
if scc.Port != nil {
1295+
return scc.Port
1296+
}
1297+
defaultPort := int32(38600)
1298+
return &defaultPort
1299+
}
1300+
12901301
// GetTopologySpreadConstraints returns the pod topology spread constraints configuration
12911302
func (cr *WebSphereLibertyApplication) GetTopologySpreadConstraints() common.BaseComponentTopologySpreadConstraints {
12921303
if cr.Spec.TopologySpreadConstraints == nil {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,11 @@ spec:
577577
path: semeruCloudCompiler.resources
578578
x-descriptors:
579579
- urn:alm:descriptor:com.tectonic.ui:resourceRequirements
580+
- description: The health port for the Semeru Cloud Compiler. Defaults to 38600.
581+
displayName: Port
582+
path: semeruCloudCompiler.port
583+
x-descriptors:
584+
- urn:alm:descriptor:com.tectonic.ui:number
580585
- description: 'Product edition. Defaults to IBM WebSphere Application Server.
581586
Other options: IBM WebSphere Application Server Liberty Core, IBM WebSphere
582587
Application Server Network Deployment'

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4173,6 +4173,11 @@ spec:
41734173
enable:
41744174
description: Enable the Semeru Cloud Compiler. Defaults to false.
41754175
type: boolean
4176+
port:
4177+
description: The health port for the Semeru Cloud Compiler. Defaults
4178+
to 38600.
4179+
format: int32
4180+
type: integer
41764181
replicas:
41774182
description: Number of desired pods for the Semeru Cloud Compiler.
41784183
Defaults to 1.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4169,6 +4169,11 @@ spec:
41694169
enable:
41704170
description: Enable the Semeru Cloud Compiler. Defaults to false.
41714171
type: boolean
4172+
port:
4173+
description: The health port for the Semeru Cloud Compiler. Defaults
4174+
to 38600.
4175+
format: int32
4176+
type: integer
41724177
replicas:
41734178
description: Number of desired pods for the Semeru Cloud Compiler.
41744179
Defaults to 1.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,11 @@ spec:
519519
path: semeruCloudCompiler.resources
520520
x-descriptors:
521521
- urn:alm:descriptor:com.tectonic.ui:resourceRequirements
522+
- description: The health port for the Semeru Cloud Compiler. Defaults to 38600.
523+
displayName: Port
524+
path: semeruCloudCompiler.port
525+
x-descriptors:
526+
- urn:alm:descriptor:com.tectonic.ui:number
522527
- description: 'Product edition. Defaults to IBM WebSphere Application Server.
523528
Other options: IBM WebSphere Application Server Liberty Core, IBM WebSphere
524529
Application Server Network Deployment'

internal/controller/semeru_compiler.go

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ func (r *ReconcileWebSphereLiberty) deleteCompletedSemeruInstances(wlva *wlv1.We
255255
}
256256

257257
func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphereLibertyApplication, deploy *appsv1.Deployment) {
258+
var port int32 = 38400
258259
deploy.Labels = getLabels(wlva)
259260
deploy.Spec.Strategy.Type = appsv1.RecreateDeploymentStrategyType
260261

@@ -276,11 +277,18 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe
276277
limitsMemory := getQuantityFromLimitsOrDefault(instanceResources, corev1.ResourceMemory, "1200Mi")
277278
limitsCPU := getQuantityFromLimitsOrDefault(instanceResources, corev1.ResourceCPU, "2000m")
278279

280+
portNumber := *semeruCloudCompiler.GetPort()
281+
var portIntOrStr intstr.IntOrString
282+
if portNumber == port {
283+
portIntOrStr = intstr.FromInt32(port)
284+
} else {
285+
portIntOrStr = intstr.FromString(fmt.Sprintf("%d-tcp", port))
286+
}
279287
// Liveness probe
280288
livenessProbe := corev1.Probe{
281289
ProbeHandler: corev1.ProbeHandler{
282290
TCPSocket: &corev1.TCPSocketAction{
283-
Port: intstr.FromInt(38400),
291+
Port: portIntOrStr,
284292
},
285293
},
286294
InitialDelaySeconds: 10,
@@ -291,7 +299,7 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe
291299
readinessProbe := corev1.Probe{
292300
ProbeHandler: corev1.ProbeHandler{
293301
TCPSocket: &corev1.TCPSocketAction{
294-
Port: intstr.FromInt(38400),
302+
Port: portIntOrStr,
295303
},
296304
},
297305
InitialDelaySeconds: 5,
@@ -301,6 +309,22 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe
301309
semeruPodMatchLabels := map[string]string{
302310
"app.kubernetes.io/instance": getSemeruCompilerNameWithGeneration(wlva),
303311
}
312+
containerPorts := make([]corev1.ContainerPort, 0)
313+
containerPorts = append(containerPorts, corev1.ContainerPort{
314+
ContainerPort: port,
315+
Protocol: corev1.ProtocolTCP,
316+
})
317+
318+
healthProbesFlag := ""
319+
if portNumber != port {
320+
healthProbesFlag = " -XX:+JITServerHealthProbes" + fmt.Sprintf(" -XX:JITServerHealthProbePort=%d", portNumber)
321+
containerPorts[0].Name = fmt.Sprintf("%d-tcp", port)
322+
containerPorts = append(containerPorts, corev1.ContainerPort{
323+
Name: fmt.Sprintf("%d-tcp", portNumber),
324+
ContainerPort: portNumber,
325+
Protocol: corev1.ProtocolTCP,
326+
})
327+
}
304328
deploy.Spec.Template = corev1.PodTemplateSpec{
305329
ObjectMeta: metav1.ObjectMeta{
306330
Labels: getLabels(wlva),
@@ -337,12 +361,7 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe
337361
Image: wlva.Status.GetImageReference(),
338362
ImagePullPolicy: *wlva.GetPullPolicy(),
339363
Command: []string{"jitserver"},
340-
Ports: []corev1.ContainerPort{
341-
{
342-
ContainerPort: 38400,
343-
Protocol: corev1.ProtocolTCP,
344-
},
345-
},
364+
Ports: containerPorts,
346365
Resources: corev1.ResourceRequirements{
347366
Requests: corev1.ResourceList{
348367
corev1.ResourceMemory: requestsMemory,
@@ -356,6 +375,7 @@ func (r *ReconcileWebSphereLiberty) reconcileSemeruDeployment(wlva *wlv1.WebSphe
356375
Env: []corev1.EnvVar{
357376
{Name: "OPENJ9_JAVA_OPTIONS", Value: "-XX:+JITServerLogConnections" +
358377
" -XX:+JITServerShareROMClasses" +
378+
healthProbesFlag +
359379
" -XX:JITServerSSLKey=/etc/x509/certs/tls.key" +
360380
" -XX:JITServerSSLCert=/etc/x509/certs/tls.crt"},
361381
},
@@ -417,12 +437,26 @@ func reconcileSemeruService(svc *corev1.Service, wlva *wlv1.WebSphereLibertyAppl
417437
svc.Labels = getLabels(wlva)
418438
svc.Spec.Selector = getSelectors(wlva)
419439
utils.CustomizeServiceAnnotations(svc)
420-
if len(svc.Spec.Ports) == 0 {
440+
numPorts := len(svc.Spec.Ports)
441+
if numPorts == 0 {
421442
svc.Spec.Ports = append(svc.Spec.Ports, corev1.ServicePort{})
422443
}
423444
svc.Spec.Ports[0].Protocol = corev1.ProtocolTCP
424445
svc.Spec.Ports[0].Port = port
425446
svc.Spec.Ports[0].TargetPort = intstr.FromInt(int(port))
447+
portNumber := *wlva.GetSemeruCloudCompiler().GetPort()
448+
if portNumber != port {
449+
numPorts = len(svc.Spec.Ports)
450+
if numPorts == 1 {
451+
svc.Spec.Ports = append(svc.Spec.Ports, corev1.ServicePort{})
452+
}
453+
svc.Spec.Ports[0].Name = fmt.Sprintf("%d-tcp", port)
454+
svc.Spec.Ports[0].TargetPort = intstr.FromString(fmt.Sprintf("%d-tcp", port))
455+
svc.Spec.Ports[1].Name = fmt.Sprintf("%d-tcp", portNumber)
456+
svc.Spec.Ports[1].Protocol = corev1.ProtocolTCP
457+
svc.Spec.Ports[1].Port = portNumber
458+
svc.Spec.Ports[1].TargetPort = intstr.FromString(fmt.Sprintf("%d-tcp", portNumber))
459+
}
426460
svc.Spec.SessionAffinity = corev1.ServiceAffinityClientIP
427461
svc.Spec.SessionAffinityConfig = &corev1.SessionAffinityConfig{
428462
ClientIP: &corev1.ClientIPConfig{
@@ -585,14 +619,13 @@ func (r *ReconcileWebSphereLiberty) getSemeruJavaOptions(instance *wlv1.WebSpher
585619
certificateLocation = "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt"
586620
}
587621
jitServerAddress := instance.Status.SemeruCompiler.ServiceHostname
588-
jitSeverOptions := fmt.Sprintf("-XX:+UseJITServer -XX:+JITServerLogConnections -XX:JITServerAddress=%v -XX:JITServerSSLRootCerts=%v",
589-
jitServerAddress, certificateLocation)
622+
jitServerOptions := fmt.Sprintf("-XX:+UseJITServer -XX:+JITServerLogConnections -XX:JITServerAddress=%v -XX:JITServerSSLRootCerts=%v", jitServerAddress, certificateLocation)
590623

591624
args := []string{
592625
"/bin/bash",
593626
"-c",
594-
"export OPENJ9_JAVA_OPTIONS=\"$OPENJ9_JAVA_OPTIONS " + jitSeverOptions +
595-
"\" && export OPENJ9_RESTORE_JAVA_OPTIONS=\"$OPENJ9_RESTORE_JAVA_OPTIONS " + jitSeverOptions +
627+
"export OPENJ9_JAVA_OPTIONS=\"$OPENJ9_JAVA_OPTIONS " + jitServerOptions +
628+
"\" && export OPENJ9_RESTORE_JAVA_OPTIONS=\"$OPENJ9_RESTORE_JAVA_OPTIONS " + jitServerOptions +
596629
"\" && server run",
597630
}
598631
return args

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4172,6 +4172,11 @@ spec:
41724172
enable:
41734173
description: Enable the Semeru Cloud Compiler. Defaults to false.
41744174
type: boolean
4175+
port:
4176+
description: The health port for the Semeru Cloud Compiler. Defaults
4177+
to 38600.
4178+
format: int32
4179+
type: integer
41754180
replicas:
41764181
description: Number of desired pods for the Semeru Cloud Compiler.
41774182
Defaults to 1.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4172,6 +4172,11 @@ spec:
41724172
enable:
41734173
description: Enable the Semeru Cloud Compiler. Defaults to false.
41744174
type: boolean
4175+
port:
4176+
description: The health port for the Semeru Cloud Compiler. Defaults
4177+
to 38600.
4178+
format: int32
4179+
type: integer
41754180
replicas:
41764181
description: Number of desired pods for the Semeru Cloud Compiler.
41774182
Defaults to 1.

0 commit comments

Comments
 (0)