Skip to content

Commit

Permalink
Update docs and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
thegridman committed Nov 21, 2023
1 parent 7423215 commit 92ec2a1
Show file tree
Hide file tree
Showing 33 changed files with 867 additions and 274 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2110,6 +2110,9 @@ install-istio: get-istio ## Install the latest version of Istio into k8s (or ove
kubectl apply -f ./hack/istio-strict.yaml
kubectl -n $(OPERATOR_NAMESPACE) apply -f ./hack/istio-operator.yaml
kubectl label namespace $(OPERATOR_NAMESPACE) istio-injection=enabled --overwrite=true
kubectl label namespace $(OPERATOR_NAMESPACE_CLIENT) istio-injection=enabled --overwrite=true
kubectl label namespace $(CLUSTER_NAMESPACE) istio-injection=enabled --overwrite=true
kubectl apply -f $(ISTIO_HOME)/samples/addons

# ----------------------------------------------------------------------------------------------------------------------
# Uninstall Istio
Expand Down
54 changes: 34 additions & 20 deletions api/v1/coherence_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,14 @@ type NamedPortSpec struct {
// port.
// +optional
ServiceMonitor *ServiceMonitorSpec `json:"serviceMonitor,omitempty"`
// ExposeOnSTS is a flag to indicate that this port should also be exposed on
// the StatefulSetHeadless service. This is useful in cases where a service mesh
// such as Istio is being used and ports such as the Extend or gRPC ports are
// accessed via the StatefulSet service.
// The default is `true` so all additional ports are exposed on the StatefulSet
// headless service.
// +optional
ExposeOnSTS *bool `json:"exposeOnSts,omitempty"`
}

// GetServiceName returns the name of the Service used to expose this port, or returns
Expand All @@ -1090,13 +1098,6 @@ func (in *NamedPortSpec) CreateService(deployment CoherenceResource) *corev1.Ser

name, _ := in.GetServiceName(deployment)

var portName string
if in.Service != nil && in.Service.PortName != nil {
portName = *in.Service.PortName
} else {
portName = in.Name
}

// The labels for the service
svcLabels := deployment.CreateCommonLabels()
svcLabels[LabelComponent] = LabelComponentPortService
Expand All @@ -1118,19 +1119,7 @@ func (in *NamedPortSpec) CreateService(deployment CoherenceResource) *corev1.Ser

// Add the port
serviceSpec.Ports = []corev1.ServicePort{
{
Name: portName,
Protocol: in.GetProtocol(),
Port: in.GetServicePort(deployment),
TargetPort: intstr.FromInt32(in.GetPort(deployment)),
NodePort: in.GetNodePort(),
},
}

if in.AppProtocol != nil {
serviceSpec.Ports[0].AppProtocol = in.AppProtocol
} else {
serviceSpec.Ports[0].AppProtocol = in.GetDefaultAppProtocol()
in.createServicePort(deployment),
}

// Add the service selector
Expand All @@ -1150,6 +1139,31 @@ func (in *NamedPortSpec) CreateService(deployment CoherenceResource) *corev1.Ser
return &svc
}

func (in *NamedPortSpec) createServicePort(deployment CoherenceResource) corev1.ServicePort {
var portName string
if in.Service != nil && in.Service.PortName != nil {
portName = *in.Service.PortName
} else {
portName = in.Name
}

sp := corev1.ServicePort{
Name: portName,
Protocol: in.GetProtocol(),
Port: in.GetServicePort(deployment),
TargetPort: intstr.FromInt32(in.GetPort(deployment)),
NodePort: in.GetNodePort(),
}

if in.AppProtocol != nil {
sp.AppProtocol = in.AppProtocol
} else {
sp.AppProtocol = in.GetDefaultAppProtocol()
}

return sp
}

// CreateServiceMonitor creates the Prometheus ServiceMonitor to expose this port if enabled.
func (in *NamedPortSpec) CreateServiceMonitor(deployment CoherenceResource) *monitoringv1.ServiceMonitor {
if in == nil || !in.IsEnabled() {
Expand Down
1 change: 0 additions & 1 deletion api/v1/coherencejobresource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func (in *CoherenceJob) GetCoherenceClusterName() string {
if in == nil {
return ""
}

if in.Spec.Cluster == "" {
return in.Name
}
Expand Down
96 changes: 58 additions & 38 deletions api/v1/coherenceresourcespec_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,42 @@ func (in *CoherenceResourceSpec) CreateHeadlessService(deployment CoherenceResou
// The selector for the service
selector := in.CreatePodSelectorLabels(deployment)

ports := []corev1.ServicePort{
{
Name: "tcp-" + PortNameCoherence,
Protocol: corev1.ProtocolTCP,
Port: 7,
TargetPort: intstr.FromInt32(7),
},
{
Name: "tcp-" + PortNameCoherenceLocal,
Protocol: corev1.ProtocolTCP,
AppProtocol: pointer.String(AppProtocolTcp),
Port: lp,
TargetPort: intstr.FromString(PortNameCoherenceLocal),
},
{
Name: "tcp-" + PortNameCoherenceCluster,
Protocol: corev1.ProtocolTCP,
AppProtocol: pointer.String(AppProtocolTcp),
Port: DefaultClusterPort,
TargetPort: intstr.FromString(PortNameCoherenceCluster),
},
{
Name: "http-" + PortNameHealth,
Protocol: corev1.ProtocolTCP,
AppProtocol: pointer.String(AppProtocolHttp),
Port: hp,
TargetPort: intstr.FromString(PortNameHealth),
},
}

for _, p := range in.Ports {
if p.ExposeOnSTS == nil || *p.ExposeOnSTS {
ports = append(ports, p.createServicePort(deployment))
}
}

// Create the Service
svc := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -596,35 +632,7 @@ func (in *CoherenceResourceSpec) CreateHeadlessService(deployment CoherenceResou
ClusterIP: "None",
PublishNotReadyAddresses: true,
Selector: selector,
Ports: []corev1.ServicePort{
{
Name: "tcp-" + PortNameCoherence,
Protocol: corev1.ProtocolTCP,
Port: 7,
TargetPort: intstr.FromInt32(7),
},
{
Name: "tcp-" + PortNameCoherenceLocal,
Protocol: corev1.ProtocolTCP,
AppProtocol: pointer.String(AppProtocolTcp),
Port: lp,
TargetPort: intstr.FromString(PortNameCoherenceLocal),
},
{
Name: "tcp-" + PortNameCoherenceCluster,
Protocol: corev1.ProtocolTCP,
AppProtocol: pointer.String(AppProtocolTcp),
Port: DefaultClusterPort,
TargetPort: intstr.FromString(PortNameCoherenceCluster),
},
{
Name: "http-" + PortNameHealth,
Protocol: corev1.ProtocolTCP,
AppProtocol: pointer.String(AppProtocolHttp),
Port: hp,
TargetPort: intstr.FromString(PortNameHealth),
},
},
Ports: ports,
},
}

Expand Down Expand Up @@ -838,7 +846,7 @@ func (in *CoherenceResourceSpec) CreateCommonVolumeMounts() []corev1.VolumeMount

// CreateCommonEnv creates the common environment variables added all.
func (in *CoherenceResourceSpec) CreateCommonEnv(deployment CoherenceResource) []corev1.EnvVar {
return []corev1.EnvVar{
env := []corev1.EnvVar{
{
Name: EnvVarCohMachineName, ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
Expand All @@ -860,9 +868,15 @@ func (in *CoherenceResourceSpec) CreateCommonEnv(deployment CoherenceResource) [
},
},
},
{Name: EnvVarCohClusterName, Value: deployment.GetCoherenceClusterName()},
{Name: EnvVarCohRole, Value: deployment.GetRoleName()},
}

clusterName := deployment.GetCoherenceClusterName()
if clusterName != "" {
env = append(env, corev1.EnvVar{Name: EnvVarCohClusterName, Value: clusterName})
}

return env
}

// AddEnvVarIfAbsent adds the specified EnvVar if one with the same name does not already exist.
Expand Down Expand Up @@ -999,14 +1013,20 @@ func (in *CoherenceResourceSpec) CreateOperatorInitContainer(deployment Coherenc

vm := in.CreateCommonVolumeMounts()

env := []corev1.EnvVar{
{Name: EnvVarCohUtilDir, Value: VolumeMountPathUtils},
}

clusterName := deployment.GetCoherenceClusterName()
if clusterName != "" {
env = append(env, corev1.EnvVar{Name: EnvVarCohClusterName, Value: clusterName})
}

c := corev1.Container{
Name: ContainerNameOperatorInit,
Image: image,
Command: []string{RunnerInitCommand, RunnerInit},
Env: []corev1.EnvVar{
{Name: EnvVarCohUtilDir, Value: VolumeMountPathUtils},
{Name: EnvVarCohClusterName, Value: deployment.GetCoherenceClusterName()},
},
Name: ContainerNameOperatorInit,
Image: image,
Command: []string{RunnerInitCommand, RunnerInit},
Env: env,
SecurityContext: in.ContainerSecurityContext,
VolumeMounts: vm,
}
Expand Down
5 changes: 5 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/about/04_coherence_spec.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ m| hostPort | Number of port to expose on the host. If specified, this must be a
m| hostIP | What host IP to bind the external port to. m| *string | false
m| service | Service configures the Kubernetes Service used to expose the port. m| &#42;<<ServiceSpec,ServiceSpec>> | false
m| serviceMonitor | The specification of a Prometheus ServiceMonitor resource that will be created for the Service being exposed for this port. m| &#42;<<ServiceMonitorSpec,ServiceMonitorSpec>> | false
m| exposeOnSts | ExposeOnSTS is a flag to indicate that this port should also be exposed on the StatefulSetHeadless service. This is useful in cases where a service mesh such as Istio is being used and ports such as the Extend or gRPC ports are accessed via the StatefulSet service. The default is `true` so all additional ports are exposed on the StatefulSet headless service. m| &#42;bool | false
|===
<<Table of Contents,Back to TOC>>
Expand Down
4 changes: 2 additions & 2 deletions examples/015_simple_image/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ In the `build.gradle` file we add the bom as a platform dependency.
.build.gradle
----
dependencies {
implementation platform("com.oracle.coherence.ce:coherence-bom:22.06.4")
implementation platform("com.oracle.coherence.ce:coherence-bom:22.06.6")
----
We can then add the `coherence` and `coherence-json` modules as dependencies
Expand All @@ -77,7 +77,7 @@ In the `build.gradle` file we add the bom as a platform dependency.
.build.gradle
----
dependencies {
implementation platform("com.oracle.coherence.ce:coherence-bom:22.06.4")
implementation platform("com.oracle.coherence.ce:coherence-bom:22.06.6")
implementation "com.oracle.coherence.ce:coherence"
implementation "com.oracle.coherence.ce:coherence-json"
Expand Down
2 changes: 1 addition & 1 deletion examples/015_simple_image/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repositories {
}

dependencies {
implementation platform("com.oracle.coherence.ce:coherence-bom:22.06.4")
implementation platform("com.oracle.coherence.ce:coherence-bom:22.06.6")

implementation "com.oracle.coherence.ce:coherence"
implementation "com.oracle.coherence.ce:coherence-json"
Expand Down
2 changes: 1 addition & 1 deletion examples/015_simple_image/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

<coherence.version>22.06.4</coherence.version>
<coherence.version>22.06.6</coherence.version>

<version.plugin.jib>3.3.2</version.plugin.jib>
</properties>
Expand Down
4 changes: 2 additions & 2 deletions examples/016_simple_docker_image/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ The `image-assembly.xml` descriptor file is shown below, and configures the foll
* There are two `<fileSets>` configured:
** The first copies any class files in `target/classes` to `app/classes` (which will actually be `target/docker/app/classes`)
** The second copies all files under `src/docker` (i.e. the `Dockerfile`) into `target/docker`
* The `<dependencySets>` configuration copies all the project dependencies (including transitive dependencies) to the `app/libs` directory (actually the `target/docker/app/libs` directory). Any version information will be stripped from the files, so `coherence-22.06.4.jar` would become `coherence.jar`.
* The `<dependencySets>` configuration copies all the project dependencies (including transitive dependencies) to the `app/libs` directory (actually the `target/docker/app/libs` directory). Any version information will be stripped from the files, so `coherence-22.06.6.jar` would become `coherence.jar`.
[source,xml]
.src/assembly/image-assembly.xml
Expand Down Expand Up @@ -274,7 +274,7 @@ In the `build.gradle` file we add the bom as a platform dependency and then add
.build.gradle
----
dependencies {
implementation platform("com.oracle.coherence.ce:coherence-bom:22.06.4")
implementation platform("com.oracle.coherence.ce:coherence-bom:22.06.6")
implementation "com.oracle.coherence.ce:coherence"
implementation "com.oracle.coherence.ce:coherence-json"
Expand Down
2 changes: 1 addition & 1 deletion examples/016_simple_docker_image/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repositories {
}

dependencies {
implementation platform("com.oracle.coherence.ce:coherence-bom:22.06.4")
implementation platform("com.oracle.coherence.ce:coherence-bom:22.06.6")

implementation "com.oracle.coherence.ce:coherence"
implementation "com.oracle.coherence.ce:coherence-json"
Expand Down
2 changes: 1 addition & 1 deletion examples/016_simple_docker_image/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

<coherence.version>22.06.4</coherence.version>
<coherence.version>22.06.6</coherence.version>

<version.plugin.jib>3.3.2</version.plugin.jib>
</properties>
Expand Down
2 changes: 1 addition & 1 deletion examples/021_deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<properties>
<coherence.group.id>com.oracle.coherence.ce</coherence.group.id>
<coherence.version>22.06.4</coherence.version>
<coherence.version>22.06.6</coherence.version>

<helidon.version>1.3.1</helidon.version>

Expand Down
2 changes: 1 addition & 1 deletion examples/025_extend_client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repositories {
}

dependencies {
implementation platform("com.oracle.coherence.ce:coherence-bom:22.06.4")
implementation platform("com.oracle.coherence.ce:coherence-bom:22.06.6")

implementation "com.oracle.coherence.ce:coherence"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/025_extend_client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

<coherence.version>22.06.4</coherence.version>
<coherence.version>22.06.6</coherence.version>

<version.plugin.jib>3.3.2</version.plugin.jib>
<version.plugin.exec>3.0.0</version.plugin.exec>
Expand Down
2 changes: 1 addition & 1 deletion examples/090_tls/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<maven.compiler.target>11</maven.compiler.target>

<coherence.group.id>com.oracle.coherence.ce</coherence.group.id>
<coherence.version>22.06.4</coherence.version>
<coherence.version>22.06.6</coherence.version>

<jib.version>3.3.2</jib.version>

Expand Down
2 changes: 1 addition & 1 deletion examples/200_autoscaler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<maven.compiler.target>11</maven.compiler.target>

<coherence.group.id>com.oracle.coherence.ce</coherence.group.id>
<coherence.version>22.06.4</coherence.version>
<coherence.version>22.06.6</coherence.version>

<jib.version>3.3.2</jib.version>

Expand Down
Loading

0 comments on commit 92ec2a1

Please sign in to comment.