11/*
2- * Copyright (c) 2022, Oracle and/or its affiliates.
2+ * Copyright (c) 2020, 2022, Oracle and/or its affiliates.
33 * Licensed under the Universal Permissive License v 1.0 as shown at
44 * http://oss.oracle.com/licenses/upl.
55 */
@@ -11,10 +11,10 @@ import (
1111 "context"
1212 "encoding/json"
1313 "fmt"
14- monitoringv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
1514 "github.com/go-logr/logr"
1615 "github.com/go-test/deep"
1716 "github.com/pkg/errors"
17+ monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
1818 appsv1 "k8s.io/api/apps/v1"
1919 corev1 "k8s.io/api/core/v1"
2020 "k8s.io/apimachinery/pkg/api/resource"
@@ -286,6 +286,17 @@ type CoherenceSpec struct {
286286 // Enables the Coherence IP Monitor feature.
287287 // The Operator disables the IP Monitor by default.
288288 EnableIPMonitor * bool `json:"enableIpMonitor,omitempty"`
289+ // LocalPort sets the Coherence unicast port.
290+ // When manually configuring unicast ports, a single port is specified and the second port is automatically selected.
291+ // If either of the ports are not available, then the default behavior is to select the next available port.
292+ // For example, if port 9000 is configured for the first port (port1) and it is not available, then the next
293+ // available port is automatically selected. The second port (port2) is automatically opened and defaults to
294+ // the next available port after port1 (port1 + 1 if available).
295+ LocalPort * int32 `json:"localPort,omitempty"`
296+ // LocalPortAdjust sets the Coherence unicast port adjust value.
297+ // To specify a range of unicast ports from which ports are selected, include a port value that represents the
298+ // upper limit of the port range.
299+ LocalPortAdjust * intstr.IntOrString `json:"localPortAdjust,omitempty"`
289300}
290301
291302// IsWKAMember returns true if this deployment is a WKA list member.
@@ -371,6 +382,16 @@ func (in *CoherenceSpec) UpdateStatefulSet(deployment *Coherence, sts *appsv1.St
371382 c .Env = append (c .Env , corev1.EnvVar {Name : EnvVarCohOverride , Value : * in .OverrideConfig })
372383 }
373384
385+ // Always set the unicast ports, as we default them if not specifically set
386+ if in .LocalPort != nil {
387+ c .Env = append (c .Env , corev1.EnvVar {Name : EnvVarCoherenceLocalPort , Value : Int32PtrToString (in .LocalPort )})
388+ }
389+
390+ if in .LocalPortAdjust != nil {
391+ lpa := in .LocalPortAdjust
392+ c .Env = append (c .Env , corev1.EnvVar {Name : EnvVarCoherenceLocalPortAdjust , Value : lpa .String ()})
393+ }
394+
374395 if in .LogLevel != nil {
375396 c .Env = append (c .Env , corev1.EnvVar {Name : EnvVarCohLogLevel , Value : Int32PtrToString (in .LogLevel )})
376397 }
@@ -1171,11 +1192,11 @@ type ServiceMonitorSpec struct {
11711192 // Interval at which metrics should be scraped
11721193 // See https://coreos.com/operators/prometheus/docs/latest/api.html#endpoint
11731194 // +optional
1174- Interval string `json:"interval,omitempty"`
1195+ Interval monitoringv1. Duration `json:"interval,omitempty"`
11751196 // Timeout after which the scrape is ended
11761197 // See https://coreos.com/operators/prometheus/docs/latest/api.html#endpoint
11771198 // +optional
1178- ScrapeTimeout string `json:"scrapeTimeout,omitempty"`
1199+ ScrapeTimeout monitoringv1. Duration `json:"scrapeTimeout,omitempty"`
11791200 // TLS configuration to use when scraping the endpoint
11801201 // See https://coreos.com/operators/prometheus/docs/latest/api.html#endpoint
11811202 // +optional
0 commit comments