Skip to content

Commit c6a5b60

Browse files
committed
Add option to precreate server services
1 parent 446b3ad commit c6a5b60

26 files changed

+502
-107
lines changed

docs/domains/Domain.json

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"serverService": {
1919
"description": "Customization affecting ClusterIP Kubernetes services for WebLogic server instances.",
20-
"$ref": "#/definitions/KubernetesResource"
20+
"$ref": "#/definitions/ServerService"
2121
},
2222
"serverPod": {
2323
"description": "Configuration affecting server pods",
@@ -93,7 +93,7 @@
9393
},
9494
"serverService": {
9595
"description": "Customization affecting ClusterIP Kubernetes services for WebLogic server instances.",
96-
"$ref": "#/definitions/KubernetesResource"
96+
"$ref": "#/definitions/ServerService"
9797
},
9898
"maxUnavailable": {
9999
"description": "The maximum number of cluster members that can be temporarily unavailable. Defaults to 1.",
@@ -244,7 +244,7 @@
244244
},
245245
"serverService": {
246246
"description": "Customization affecting ClusterIP Kubernetes services for WebLogic server instances.",
247-
"$ref": "#/definitions/KubernetesResource"
247+
"$ref": "#/definitions/ServerService"
248248
},
249249
"domainHome": {
250250
"description": "The folder for the WebLogic Domain. Not required. Defaults to /shared/domains/domains/domainUID if domainHomeInImage is false Defaults to /u01/oracle/user_projects/domains/ if domainHomeInImage is true",
@@ -354,7 +354,7 @@
354354
},
355355
"serverService": {
356356
"description": "Customization affecting ClusterIP Kubernetes services for WebLogic server instances.",
357-
"$ref": "#/definitions/KubernetesResource"
357+
"$ref": "#/definitions/ServerService"
358358
},
359359
"serverName": {
360360
"description": "The name of the server. Required",
@@ -500,6 +500,23 @@
500500
}
501501
}
502502
},
503+
"ServerService": {
504+
"type": "object",
505+
"properties": {
506+
"precreateService": {
507+
"description": "If true, operator will create server services even for server instances without running pods.",
508+
"type": "boolean"
509+
},
510+
"annotations": {
511+
"description": "The annotations to be attached to generated resources.",
512+
"$ref": "#/definitions/Map"
513+
},
514+
"labels": {
515+
"description": "The labels to be attached to generated resources. The label names must not start with \u0027weblogic.\u0027.",
516+
"$ref": "#/definitions/Map"
517+
}
518+
}
519+
},
503520
"ServerStatus": {
504521
"type": "object",
505522
"properties": {

docs/domains/Domain.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ DomainSpec is a description of a domain.
3333
| `replicas` | number | The number of managed servers to run in any cluster that does not specify a replica count. |
3434
| `restartVersion` | string | If present, every time this value is updated the operator will restart the required servers. |
3535
| `serverPod` | [Server Pod](#server-pod) | Configuration affecting server pods |
36-
| `serverService` | [Kubernetes Resource](#kubernetes-resource) | Customization affecting ClusterIP Kubernetes services for WebLogic server instances. |
36+
| `serverService` | [Server Service](#server-service) | Customization affecting ClusterIP Kubernetes services for WebLogic server instances. |
3737
| `serverStartPolicy` | string | The strategy for deciding whether to start a server. Legal values are ADMIN_ONLY, NEVER, or IF_NEEDED. |
3838
| `serverStartState` | string | The state in which the server is to be started. Use ADMIN if server should start in the admin state. Defaults to RUNNING. |
3939
| `webLogicCredentialsSecret` | [Secret Reference](k8s1.13.5.md#secret-reference) | The name of a pre-created Kubernetes secret, in the domain's namepace, that holds the username and password needed to boot WebLogic Server under the 'username' and 'password' fields. |
@@ -60,7 +60,7 @@ AdminServer represents the operator configuration for the admin server.
6060
| `adminService` | [Admin Service](#admin-service) | Configures which of the admin server's WebLogic admin channels should be exposed outside the Kubernetes cluster via a node port service. |
6161
| `restartVersion` | string | If present, every time this value is updated the operator will restart the required servers. |
6262
| `serverPod` | [Server Pod](#server-pod) | Configuration affecting server pods |
63-
| `serverService` | [Kubernetes Resource](#kubernetes-resource) | Customization affecting ClusterIP Kubernetes services for WebLogic server instances. |
63+
| `serverService` | [Server Service](#server-service) | Customization affecting ClusterIP Kubernetes services for WebLogic server instances. |
6464
| `serverStartPolicy` | string | The strategy for deciding whether to start a server. Legal values are ALWAYS, NEVER, or IF_NEEDED. |
6565
| `serverStartState` | string | The state in which the server is to be started. Use ADMIN if server should start in the admin state. Defaults to RUNNING. |
6666

@@ -76,7 +76,7 @@ An element representing a cluster in the domain configuration.
7676
| `replicas` | number | The number of managed servers to run in this cluster. |
7777
| `restartVersion` | string | If present, every time this value is updated the operator will restart the required servers. |
7878
| `serverPod` | [Server Pod](#server-pod) | Configuration affecting server pods |
79-
| `serverService` | [Kubernetes Resource](#kubernetes-resource) | Customization affecting ClusterIP Kubernetes services for WebLogic server instances. |
79+
| `serverService` | [Server Service](#server-service) | Customization affecting ClusterIP Kubernetes services for WebLogic server instances. |
8080
| `serverStartPolicy` | string | The strategy for deciding whether to start a server. Legal values are NEVER, or IF_NEEDED. |
8181
| `serverStartState` | string | The state in which the server is to be started. Use ADMIN if server should start in the admin state. Defaults to RUNNING. |
8282

@@ -89,7 +89,7 @@ ManagedServer represents the operator configuration for a single managed server.
8989
| `restartVersion` | string | If present, every time this value is updated the operator will restart the required servers. |
9090
| `serverName` | string | The name of the server. Required |
9191
| `serverPod` | [Server Pod](#server-pod) | Configuration affecting server pods |
92-
| `serverService` | [Kubernetes Resource](#kubernetes-resource) | Customization affecting ClusterIP Kubernetes services for WebLogic server instances. |
92+
| `serverService` | [Server Service](#server-service) | Customization affecting ClusterIP Kubernetes services for WebLogic server instances. |
9393
| `serverStartPolicy` | string | The strategy for deciding whether to start a server. Legal values are ALWAYS, NEVER, or IF_NEEDED. |
9494
| `serverStartState` | string | The state in which the server is to be started. Use ADMIN if server should start in the admin state. Defaults to RUNNING. |
9595

@@ -114,12 +114,13 @@ ServerPod describes the configuration for a Kubernetes pod for a server.
114114
| `volumeMounts` | array of [Volume Mount](k8s1.13.5.md#volume-mount) | Additional volume mounts for the server pod. |
115115
| `volumes` | array of [Volume](k8s1.13.5.md#volume) | Additional volumes to be created in the server pod. |
116116

117-
### Kubernetes Resource
117+
### Server Service
118118

119119
| Name | Type | Description |
120120
| --- | --- | --- |
121121
| `annotations` | Map | The annotations to be attached to generated resources. |
122122
| `labels` | Map | The labels to be attached to generated resources. The label names must not start with 'weblogic.'. |
123+
| `precreateService` | Boolean | If true, operator will create server services even for server instances without running pods. |
123124

124125
### Domain Condition
125126

@@ -150,6 +151,13 @@ ServerPod describes the configuration for a Kubernetes pod for a server.
150151
| `channels` | array of [Channel](#channel) | Specifies which of the admin server's WebLogic channels should be exposed outside the Kubernetes cluster via a node port service, along with the node port for each channel. If not specified, the admin server's node port service will not be created. |
151152
| `labels` | Map | Labels to associate with the external channel service |
152153

154+
### Kubernetes Resource
155+
156+
| Name | Type | Description |
157+
| --- | --- | --- |
158+
| `annotations` | Map | The annotations to be attached to generated resources. |
159+
| `labels` | Map | The labels to be attached to generated resources. The label names must not start with 'weblogic.'. |
160+
153161
### Probe Tuning
154162

155163
| Name | Type | Description |

docs/domains/index.html

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@
937937
},
938938
"serverService": {
939939
"description": "Customization affecting ClusterIP Kubernetes services for WebLogic server instances.",
940-
"$ref": "#/definitions/KubernetesResource"
940+
"$ref": "#/definitions/ServerService"
941941
},
942942
"serverPod": {
943943
"description": "Configuration affecting server pods",
@@ -1013,7 +1013,7 @@
10131013
},
10141014
"serverService": {
10151015
"description": "Customization affecting ClusterIP Kubernetes services for WebLogic server instances.",
1016-
"$ref": "#/definitions/KubernetesResource"
1016+
"$ref": "#/definitions/ServerService"
10171017
},
10181018
"maxUnavailable": {
10191019
"description": "The maximum number of cluster members that can be temporarily unavailable. Defaults to 1.",
@@ -1164,7 +1164,7 @@
11641164
},
11651165
"serverService": {
11661166
"description": "Customization affecting ClusterIP Kubernetes services for WebLogic server instances.",
1167-
"$ref": "#/definitions/KubernetesResource"
1167+
"$ref": "#/definitions/ServerService"
11681168
},
11691169
"domainHome": {
11701170
"description": "The folder for the WebLogic Domain. Not required. Defaults to /shared/domains/domains/domainUID if domainHomeInImage is false Defaults to /u01/oracle/user_projects/domains/ if domainHomeInImage is true",
@@ -1274,7 +1274,7 @@
12741274
},
12751275
"serverService": {
12761276
"description": "Customization affecting ClusterIP Kubernetes services for WebLogic server instances.",
1277-
"$ref": "#/definitions/KubernetesResource"
1277+
"$ref": "#/definitions/ServerService"
12781278
},
12791279
"serverName": {
12801280
"description": "The name of the server. Required",
@@ -1420,6 +1420,23 @@
14201420
}
14211421
}
14221422
},
1423+
"ServerService": {
1424+
"type": "object",
1425+
"properties": {
1426+
"precreateService": {
1427+
"description": "If true, operator will create server services even for server instances without running pods.",
1428+
"type": "boolean"
1429+
},
1430+
"annotations": {
1431+
"description": "The annotations to be attached to generated resources.",
1432+
"$ref": "#/definitions/Map"
1433+
},
1434+
"labels": {
1435+
"description": "The labels to be attached to generated resources. The label names must not start with \u0027weblogic.\u0027.",
1436+
"$ref": "#/definitions/Map"
1437+
}
1438+
}
1439+
},
14231440
"ServerStatus": {
14241441
"type": "object",
14251442
"properties": {

model/src/main/java/oracle/kubernetes/weblogic/domain/model/BaseConfiguration.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public abstract class BaseConfiguration {
3939
"Customization affecting ClusterIP Kubernetes services for WebLogic server instances.")
4040
@SerializedName("serverService")
4141
@Expose
42-
private KubernetesResource serverService = new KubernetesResource();
42+
private ServerService serverService = new ServerService();
4343

4444
/** Desired startup state. Legal values are RUNNING or ADMIN. */
4545
@EnumClass(ServerStartState.class)
@@ -229,12 +229,8 @@ void addPodAnnotation(String name, String value) {
229229
serverPod.addAnnotations(name, value);
230230
}
231231

232-
public void setServerService(KubernetesResource serverService) {
233-
this.serverService = serverService;
234-
}
235-
236-
public KubernetesResource getServerService() {
237-
return serverService;
232+
public Boolean isPrecreateServerService() {
233+
return serverService.isPrecreateService();
238234
}
239235

240236
public Map<String, String> getServiceLabels() {

model/src/main/java/oracle/kubernetes/weblogic/domain/model/ClusterSpec.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
import javax.annotation.Nonnull;
1212

1313
public abstract class ClusterSpec {
14+
/**
15+
* Returns true if per-server instance services should be created for cluster member services even
16+
* if pods are not running for these instances.
17+
*
18+
* @return true, if per-server instances services should be pre-created.
19+
*/
20+
public abstract Boolean isPrecreateServerService();
21+
1422
/**
1523
* Returns the labels applied to server instance services.
1624
*

model/src/main/java/oracle/kubernetes/weblogic/domain/model/ClusterSpecCommonImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ private Cluster getBaseConfiguration(Cluster cluster) {
2020
return cluster != null ? cluster.getConfiguration() : new Cluster();
2121
}
2222

23+
@Override
24+
public Boolean isPrecreateServerService() {
25+
return cluster.isPrecreateServerService();
26+
}
27+
2328
@Override
2429
public Map<String, String> getServiceLabels() {
2530
return cluster.getServiceLabels();
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at
3+
// http://oss.oracle.com/licenses/upl.
4+
5+
package oracle.kubernetes.weblogic.domain.model;
6+
7+
import com.google.gson.annotations.SerializedName;
8+
import java.util.Optional;
9+
import oracle.kubernetes.json.Description;
10+
import org.apache.commons.lang3.builder.EqualsBuilder;
11+
import org.apache.commons.lang3.builder.HashCodeBuilder;
12+
import org.apache.commons.lang3.builder.ToStringBuilder;
13+
14+
public class ServerService extends KubernetesResource {
15+
16+
@SerializedName("precreateService")
17+
@Description(
18+
"If true, operator will create server services even for server instances without running pods.")
19+
private Boolean isPrecreateService;
20+
21+
void fillInFrom(ServerService serverService1) {
22+
super.fillInFrom(serverService1);
23+
this.isPrecreateService =
24+
Optional.ofNullable(isPrecreateService).orElse(serverService1.isPrecreateService);
25+
}
26+
27+
public Boolean isPrecreateService() {
28+
return Optional.ofNullable(isPrecreateService).orElse(Boolean.FALSE);
29+
}
30+
31+
public void setIsPrecreateService(Boolean isPrecreateService) {
32+
this.isPrecreateService = isPrecreateService;
33+
}
34+
35+
public ServerService withIsPrecreateService(Boolean isPrecreateService) {
36+
this.isPrecreateService = isPrecreateService;
37+
return this;
38+
}
39+
40+
@Override
41+
public String toString() {
42+
return new ToStringBuilder(this)
43+
.appendSuper(super.toString())
44+
.append("isPrecreateService", isPrecreateService)
45+
.toString();
46+
}
47+
48+
@Override
49+
public boolean equals(Object o) {
50+
if (this == o) {
51+
return true;
52+
}
53+
54+
if (o == null || getClass() != o.getClass()) {
55+
return false;
56+
}
57+
58+
ServerService that = (ServerService) o;
59+
60+
return new EqualsBuilder()
61+
.appendSuper(super.equals(o))
62+
.append(isPrecreateService, that.isPrecreateService)
63+
.isEquals();
64+
}
65+
66+
@Override
67+
public int hashCode() {
68+
return new HashCodeBuilder(17, 37)
69+
.appendSuper(super.hashCode())
70+
.append(isPrecreateService)
71+
.toHashCode();
72+
}
73+
}

model/src/main/java/oracle/kubernetes/weblogic/domain/model/ServerSpec.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ public interface ServerSpec {
103103
@Nonnull
104104
Map<String, String> getPodAnnotations();
105105

106+
/**
107+
* Returns true if the per-server instance service should be created for this server instance even
108+
* if the pod for this server instance is not running.
109+
*
110+
* @return true, if the per-server instance service should be pre-created
111+
*/
112+
Boolean isPrecreateServerService();
113+
106114
/**
107115
* Returns the labels applied to the service.
108116
*

model/src/main/java/oracle/kubernetes/weblogic/domain/model/ServerSpecCommonImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ public Map<String, String> getPodAnnotations() {
7575
return server.getPodAnnotations();
7676
}
7777

78+
public Boolean isPrecreateServerService() {
79+
return server.isPrecreateServerService();
80+
}
81+
7882
@Override
7983
@Nonnull
8084
public Map<String, String> getServiceLabels() {

operator/src/main/java/oracle/kubernetes/operator/DomainStatusUpdater.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private Stream<ServerStartupInfo> getServerStartupInfos() {
181181
}
182182

183183
private boolean shouldBeRunning(ServerStartupInfo startupInfo) {
184-
return RUNNING_STATE.equals(startupInfo.getDesiredState());
184+
return !startupInfo.isServiceOnly() && RUNNING_STATE.equals(startupInfo.getDesiredState());
185185
}
186186

187187
private boolean isNotRunning(@Nonnull String serverName) {

0 commit comments

Comments
 (0)