Skip to content

Commit 6a7ae45

Browse files
committed
Merge branch 'develop' of https://github.com/oracle/weblogic-kubernetes-operator into feature/java-integration-tests
2 parents 52d54e8 + 521ff6e commit 6a7ae45

File tree

18 files changed

+375
-75
lines changed

18 files changed

+375
-75
lines changed

README.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ In addition, we've provided an open-source Oracle WebLogic Server Kubernetes Ope
2020
* Scale WebLogic domains by starting and stopping Managed Servers on demand, or by integrating with a REST API to initiate scaling based on WLDF, Prometheus, Grafana, or other rules.
2121
* Publish operator and WebLogic Server logs into Elasticsearch and interact with them in Kibana.
2222

23-
The fastest way to experience the operator is to follow the Quick Start Guide, or you can peruse our [documentation](site), read our blogs, try out the [samples](kubernetes/samples/README.md), or check us out on our public Slack channel.
23+
The fastest way to experience the operator is to follow the [Quick start guide](site/quickstart.md), or you can peruse our [documentation](site), read our blogs, or try out the [samples](kubernetes/samples/README.md).
2424

2525

2626
# Important terms
@@ -45,7 +45,7 @@ Before using the operator, you might want to read the [design philosophy](site/d
4545

4646
## Prerequisites
4747

48-
* Kubernetes 1.10+, 1.11+, and 1.12.0+ (check with `kubectl version`).
48+
* Kubernetes 1.10.11+, 1.11.5+, and 1.12.3+ (check with `kubectl version`).
4949
* Flannel networking v0.9.1-amd64 (check with `docker images | grep flannel`)
5050
* Docker 17.03.1.ce (check with `docker version`)
5151
* Oracle WebLogic Server 12.2.1.3.0
@@ -81,7 +81,7 @@ In your Kubernetes cluster you can have one or more operators that manage one or
8181
* Edit the operator input YAML
8282
* Start the operator with a Helm chart
8383

84-
### Modifying the Operator
84+
### Modifying the operator
8585

8686
(images, RBAC roles, ...)
8787

@@ -91,16 +91,17 @@ In your Kubernetes cluster you can have one or more operators that manage one or
9191
## Create and manage WebLogic domains
9292

9393
In this version of the operator, a WebLogic domain can be persisted either to a persistent volume (PV) or in a Docker image.
94-
(We can add a paragraph that describes the pros and cons of both these approaches.)
94+
(Describe the pros and cons of both these approaches.)
9595

96-
You can create the WebLogic domain inside of a Docker image or in a PV using WebLogic Scripting Tool (WLST) or WebLogic Deploy Tooling (WDT).
97-
* Advantages of using WDT. (See samples, Domain in image WDT, Domain in image WLST, Domain in PV WDT, Domain in PV WLST)
98-
99-
(What images do we need before we get started? Operator 2.0 requires you to patch your WebLogic image 12.2.1.3 with patch #.)
10096
* WebLogic binary image when domain is persisted to a PV (as in Operator v1.1)
10197
* WebLogic domain image where the domain is persisted to a Docker image (new for Operator v2.0). The WebLogic domain image will contain the WebLogic binaries, domain configuration, and applications.
10298

103-
### Preparing the Kubernetes cluster to run the WebLogic domain
99+
You create the WebLogic domain inside of a Docker image or in a PV using WebLogic Scripting Tool (WLST) or WebLogic Deploy Tooling (WDT).
100+
* (Describe the advantages of using WDT. See samples, Domain in image WDT, Domain in image WLST, Domain in PV WDT, Domain in PV WLST.)
101+
102+
(What images do we need before we get started? Operator 2.0 requires you to patch your WebLogic image 12.2.1.3 with patch #.)
103+
104+
### Preparing the Kubernetes cluster to run WebLogic domains
104105

105106
Perform these steps to prepare your Kubernetes cluster to run a WebLogic domain:
106107

@@ -110,9 +111,9 @@ Perform these steps to prepare your Kubernetes cluster to run a WebLogic domain:
110111
* Optionally, [create a PV & persistent volume claim (PVC)](kubernetes/samples/scripts/create-weblogic-domain-pv-pvc/README.md) which can hold the domain home, logs, and application binaries.
111112
* [Configure a load balancer](kubernetes/samples/charts/README.md) to manage the domains and ingresses.
112113

113-
### Creating and managing the WebLogic domain
114+
### Creating and managing WebLogic domains
114115

115-
To create and manage a WebLogic domain in Kubernetes we create a deployment type, the domain custom resource. The operator always looks at the custom resource and manages the domain deployment to adjust to the definitions in the custom resource. This custom resource can also be managed using the Kubernetes command-line interface `kubectl`.
116+
To create and manage a WebLogic domain in Kubernetes we create a deployment type, the domain custom resource. The operator introspects the custom resource and manages the domain deployment to adjust to the definitions in the custom resource. This custom resource can also be managed using the Kubernetes command-line interface `kubectl`.
116117
* (Point to documentation how to edit the domain inputs YAML and how to create the domain custom resource.)
117118
* Create Ingress controllers if you are using a load balancer that supports them, such as Traefik or Voyager.
118119

@@ -122,16 +123,16 @@ In Operator 2.0 you can perform lifecycle operations on WebLogic servers, cluste
122123
* Point to the documentation on how to manage lifecycle operations.
123124

124125
### Modifying domain configurations
125-
You can modify the WebLogic domain configuration for both domain in PV and domain in image:
126+
You can modify the WebLogic domain configuration for both the domain in PV and the domain in image:
126127

127128
* When the domain is in a PV, use WLST or WDT to change the configuration.
128-
* Use configuration overrides when using the domain in image. (Point to the documentation.)
129+
* Use configuration overrides when using the domain in image.(Check with Tom B, "The automatic and custom overrides apply to all domains - not just domain-in-image domains." Point to the documentation.)
129130

130131
### Patching WebLogic and performing application updates
131132

132-
### Shutting down the domain
133+
### Shutting down domains
133134

134-
### Deleting the domain
135+
### Deleting domains
135136
(Point to sample)
136137

137138
# Developer guide
@@ -144,7 +145,9 @@ Please take a look at our [wish list](https://github.com/oracle/weblogic-kuberne
144145

145146
Documentation for APIs is provided here:
146147

147-
* The operator provides a REST API that you can use to obtain information about the configuration and to initiate scaling actions. For details about how to use the REST APIs, see [Using the operator's REST services](site/rest.md). Also, see the [Swagger](https://oracle.github.io/weblogic-kubernetes-operator/swagger/index.html) documentation for the operator's REST interface.
148+
* The operator provides a REST API that you can use to obtain information about the configuration and to initiate scaling actions. For details about how to use the REST APIs, see [Using the operator's REST services](site/rest.md).
149+
150+
* See the [Swagger](https://oracle.github.io/weblogic-kubernetes-operator/swagger/index.html) documentation for the operator's REST interface.
148151

149152
* [Javadoc](https://oracle.github.io/weblogic-kubernetes-operator/apidocs/index.html) for the operator.
150153

@@ -154,12 +157,12 @@ We have a public Slack channel where you can get in touch with us to ask questio
154157

155158
## Recent changes
156159

157-
See [Recent changes](site/recent-changes.md) for recent changes to the operator, including any backward incompatible changes.
160+
See [Recent changes](site/recent-changes.md) for changes to the operator, including any backward incompatible changes.
158161

159162

160163
# Contributing to the operator
161164

162-
Oracle welcomes contributions to this project from anyone. Contributions may be reporting an issue with the operator, or submitting a pull request. Before embarking on significant development that may result in a large pull request, it is recommended that you create an issue and discuss the proposed changes with the existing developers first.
165+
Oracle welcomes contributions to this project from anyone. Contributions may be reporting an issue with the operator or submitting a pull request. Before embarking on significant development that may result in a large pull request, it is recommended that you create an issue and discuss the proposed changes with the existing developers first.
163166

164167
If you want to submit a pull request to fix a bug or enhance an existing feature, please first open an issue and link to that issue when you submit your pull request.
165168

integration-tests/src/test/java/oracle/kubernetes/operator/utils/Domain.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public void create() throws Exception {
370370
cmd.append(userProjectsDir)
371371
.append("/weblogic-domains/")
372372
.append(domainUid)
373-
.append("/domain-custom-resource.yaml");
373+
.append("/domain.yaml");
374374
logger.info("Running " + cmd);
375375
ExecResult result = ExecCommand.exec(cmd.toString());
376376
if (result.exitValue() != 0) {
@@ -399,7 +399,7 @@ public void destroy() throws Exception {
399399
cmd.append(userProjectsDir)
400400
.append("/weblogic-domains/")
401401
.append(domainUid)
402-
.append("/domain-custom-resource.yaml");
402+
.append("/domain.yaml");
403403
ExecResult result = ExecCommand.exec(cmd.toString());
404404
if (result.exitValue() != 0) {
405405
throw new RuntimeException(

kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/common/create-domain-job.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
44
#
55

6+
function exitIfError {
7+
if [ "$1" != "0" ]; then
8+
echo "$2"
9+
exit $1
10+
fi
11+
}
12+
613
# Include common utility functions
714
source ${CREATE_DOMAIN_SCRIPT_DIR}/utility.sh
815

@@ -15,9 +22,11 @@ prepareDomainHomeDir
1522

1623
# Execute the script to create the domain
1724
source $script
25+
exitIfError $? "ERROR: $script failed."
1826

1927
# Create the node manager
2028
wlst.sh -skipWLSModuleScanning ${CREATE_DOMAIN_SCRIPT_DIR}/setup-nodemanager.py
29+
exitIfError $? "ERROR: setup node manager failed."
2130

2231
# DON'T REMOVE THIS
2332
# This script has to contain this log message.

kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain.sh

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function initAndValidateOutputDir {
8484
create-domain-inputs.yaml \
8585
create-domain-job.yaml \
8686
delete-domain-job.yaml \
87-
domain-custom-resource.yaml
87+
domain.yaml
8888
}
8989

9090
#
@@ -216,7 +216,7 @@ function initialize {
216216
validationError "The template file ${deleteJobInput} for deleting a WebLogic domain_home folder was not found"
217217
fi
218218

219-
dcrInput="${scriptDir}/domain-custom-resource-template.yaml"
219+
dcrInput="${scriptDir}/domain-template.yaml"
220220
if [ ! -f ${dcrInput} ]; then
221221
validationError "The template file ${dcrInput} for creating the domain custom resource was not found"
222222
fi
@@ -283,7 +283,7 @@ function createYamlFiles {
283283

284284
createJobOutput="${domainOutputDir}/create-domain-job.yaml"
285285
deleteJobOutput="${domainOutputDir}/delete-domain-job.yaml"
286-
dcrOutput="${domainOutputDir}/domain-custom-resource.yaml"
286+
dcrOutput="${domainOutputDir}/domain.yaml"
287287

288288
enabledPrefix="" # uncomment the feature
289289
disabledPrefix="# " # comment out the feature
@@ -469,34 +469,35 @@ function createDomainHome {
469469
while [ "$JOB_STATUS" != "Completed" -a $count -lt $max ] ; do
470470
sleep 30
471471
count=`expr $count + 1`
472-
JOB_STATUS=`kubectl get pods --show-all -n ${namespace} | grep ${JOB_NAME} | awk ' { print $3; } '`
473-
JOB_INFO=`kubectl get pods --show-all -n ${namespace} | grep ${JOB_NAME} | awk ' { print "pod", $1, "status is", $3; } '`
472+
JOBS=`kubectl get pods --show-all -n ${namespace} | grep ${JOB_NAME}`
473+
JOB_ERRORS=`kubectl logs jobs/$JOB_NAME -n ${namespace} | grep "ERROR:" `
474+
JOB_STATUS=`echo $JOBS | awk ' { print $3; } '`
475+
JOB_INFO=`echo $JOBS | awk ' { print "pod", $1, "status is", $3; } '`
474476
echo "status on iteration $count of $max"
475477
echo "$JOB_INFO"
476478

477479
# Terminate the retry loop when a fatal error has already occurred. Search for "ERROR:" in the job log file
478480
if [ "$JOB_STATUS" != "Completed" ]; then
479-
JOB_ERRORS=`kubectl logs jobs/$JOB_NAME -n ${namespace} | grep "ERROR:" `
480481
ERR_COUNT=`echo $JOB_ERRORS | grep "ERROR:" | wc | awk ' {print $1; }'`
481482
if [ "$ERR_COUNT" != "0" ]; then
482-
echo A failure was detected in the log file for job $JOB_NAME
483-
echo $JOB_ERRORS
484-
echo Check the log output for additional information
485-
fail "Exiting due to failure - the job has failed"
483+
echo "A failure was detected in the log file for job $JOB_NAME."
484+
echo "$JOB_ERRORS"
485+
echo "Check the log output for additional information."
486+
fail "Exiting due to failure - the job has failed!"
486487
fi
487488
fi
488489
done
489490

490491
# Confirm the job pod is status completed
491-
JOB_POD=`kubectl get pods --show-all -n ${namespace} | grep ${JOB_NAME} | awk ' { print $1; } '`
492492
if [ "$JOB_STATUS" != "Completed" ]; then
493-
echo The create domain job is not showing status completed after waiting 300 seconds
494-
echo Check the log output for errors
493+
echo "The create domain job is not showing status completed after waiting 300 seconds."
494+
echo "Check the log output for errors."
495495
kubectl logs jobs/$JOB_NAME -n ${namespace}
496496
fail "Exiting due to failure - the job status is not Completed!"
497497
fi
498498

499499
# Check for successful completion in log file
500+
JOB_POD=`kubectl get pods --show-all -n ${namespace} | grep ${JOB_NAME} | awk ' { print $1; } '`
500501
JOB_STS=`kubectl logs $JOB_POD -n ${namespace} | grep "Successfully Completed" | awk ' { print $1; } '`
501502
if [ "${JOB_STS}" != "Successfully" ]; then
502503
echo The log file for the create domain job does not contain a successful completion status

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/DomainSpec.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,17 @@ public class DomainSpec extends BaseConfiguration {
196196
@Description("Configuration for the clusters")
197197
protected Map<String, Cluster> clusters = new HashMap<>();
198198

199+
/**
200+
* Adds a Cluster to the DomainSpec
201+
*
202+
* @param cluster
203+
* @return
204+
*/
205+
public DomainSpec withCluster(Cluster cluster) {
206+
clusters.put(cluster.getClusterName(), cluster);
207+
return this;
208+
}
209+
199210
AdminServer getOrCreateAdminServer(String adminServerName) {
200211
if (adminServer != null) return adminServer;
201212

@@ -676,7 +687,7 @@ private void setAdminServer(AdminServer adminServer) {
676687
this.adminServer = adminServer;
677688
}
678689

679-
Map<String, ManagedServer> getManagedServers() {
690+
public Map<String, ManagedServer> getManagedServers() {
680691
return managedServers;
681692
}
682693

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

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import io.kubernetes.client.util.Watch;
1616
import java.util.ArrayList;
1717
import java.util.List;
18+
import java.util.Map;
1819
import java.util.Objects;
1920
import java.util.concurrent.ConcurrentHashMap;
2021
import java.util.concurrent.ConcurrentMap;
@@ -32,6 +33,8 @@
3233
import oracle.kubernetes.operator.helpers.JobHelper;
3334
import oracle.kubernetes.operator.helpers.PodHelper;
3435
import oracle.kubernetes.operator.helpers.ResponseStep;
36+
import oracle.kubernetes.operator.helpers.Scan;
37+
import oracle.kubernetes.operator.helpers.ScanCache;
3538
import oracle.kubernetes.operator.helpers.ServerKubernetesObjects;
3639
import oracle.kubernetes.operator.helpers.ServiceHelper;
3740
import oracle.kubernetes.operator.helpers.StorageHelper;
@@ -45,6 +48,7 @@
4548
import oracle.kubernetes.operator.steps.ListPersistentVolumeClaimStep;
4649
import oracle.kubernetes.operator.steps.ManagedServersUpStep;
4750
import oracle.kubernetes.operator.steps.WatchPodReadyAdminStep;
51+
import oracle.kubernetes.operator.wlsconfig.WlsDomainConfig;
4852
import oracle.kubernetes.operator.work.Component;
4953
import oracle.kubernetes.operator.work.Fiber;
5054
import oracle.kubernetes.operator.work.Fiber.CompletionCallback;
@@ -645,7 +649,8 @@ public StartPlanStep(DomainPresenceInfo info, Step next) {
645649

646650
@Override
647651
public NextAction apply(Packet packet) {
648-
Step strategy = new RegisterStep(info, getNext());
652+
Step strategy =
653+
Step.chain(readExistingSituConfigMap(info), new RegisterStep(info, getNext()));
649654
if (!info.isPopulated()) {
650655
strategy = Step.chain(readExistingPods(info), readExistingServices(info), strategy);
651656
}
@@ -684,6 +689,14 @@ private static Step readExistingServices(DomainPresenceInfo info) {
684689
.listServiceAsync(info.getNamespace(), new ServiceListStep(info));
685690
}
686691

692+
private static Step readExistingSituConfigMap(DomainPresenceInfo info) {
693+
String situConfigMapName =
694+
ConfigMapHelper.SitConfigMapContext.getConfigMapName(info.getDomainUID());
695+
return new CallBuilder()
696+
.readConfigMapAsync(
697+
situConfigMapName, info.getNamespace(), new ReadSituConfigMapStep(info));
698+
}
699+
687700
private static class PodListStep extends ResponseStep<V1PodList> {
688701
private final DomainPresenceInfo info;
689702

@@ -817,7 +830,7 @@ static Step createDomainUpPlan(DomainPresenceInfo info) {
817830
Domain dom = info.getDomain();
818831
Step managedServerStrategy =
819832
bringManagedServersUp(DomainStatusUpdater.createEndProgressingStep(new TailStep()));
820-
Step adminServerStrategy = bringAdminServerUp(dom, managedServerStrategy);
833+
Step adminServerStrategy = bringAdminServerUp(info, managedServerStrategy);
821834

822835
return new UpHeadStep(
823836
info,
@@ -893,17 +906,53 @@ public NextAction apply(Packet packet) {
893906

894907
// pre-conditions: DomainPresenceInfo SPI
895908
// "principal"
896-
private static Step bringAdminServerUp(Domain dom, Step next) {
897-
return StorageHelper.insertStorageSteps(dom, Step.chain(bringAdminServerUpSteps(dom, next)));
909+
private static Step bringAdminServerUp(DomainPresenceInfo info, Step next) {
910+
return StorageHelper.insertStorageSteps(
911+
info.getDomain(), Step.chain(bringAdminServerUpSteps(info, next)));
898912
}
899913

900-
private static Step[] bringAdminServerUpSteps(Domain dom, Step next) {
914+
private static class ReadSituConfigMapStep extends ResponseStep<V1ConfigMap> {
915+
private final DomainPresenceInfo info;
916+
917+
ReadSituConfigMapStep(DomainPresenceInfo info) {
918+
this.info = info;
919+
}
920+
921+
@Override
922+
public NextAction onFailure(Packet packet, CallResponse<V1ConfigMap> callResponse) {
923+
return callResponse.getStatusCode() == CallBuilder.NOT_FOUND
924+
? onSuccess(packet, callResponse)
925+
: super.onFailure(packet, callResponse);
926+
}
927+
928+
@Override
929+
public NextAction onSuccess(Packet packet, CallResponse<V1ConfigMap> callResponse) {
930+
V1ConfigMap result = callResponse.getResult();
931+
if (result != null) {
932+
Map<String, String> data = result.getData();
933+
String topologyYaml = data.get("topology.yaml");
934+
if (topologyYaml != null) {
935+
ConfigMapHelper.DomainTopology domainTopology =
936+
ConfigMapHelper.parseDomainTopologyYaml(topologyYaml);
937+
WlsDomainConfig wlsDomainConfig = domainTopology.getDomain();
938+
ScanCache.INSTANCE.registerScan(
939+
info.getNamespace(), info.getDomainUID(), new Scan(wlsDomainConfig, new DateTime()));
940+
}
941+
}
942+
943+
return doNext(packet);
944+
}
945+
}
946+
947+
private static Step[] bringAdminServerUpSteps(DomainPresenceInfo info, Step next) {
948+
Domain dom = info.getDomain();
901949
List<Step> resources = new ArrayList<>();
902950
resources.add(new ListPersistentVolumeClaimStep(null));
903951
resources.add(
904952
JobHelper.deleteDomainIntrospectorJobStep(
905953
dom.getDomainUID(), dom.getMetadata().getNamespace(), null));
906-
resources.add(JobHelper.createDomainIntrospectorJobStep(PodHelper.createAdminPodStep(null)));
954+
resources.add(JobHelper.createDomainIntrospectorJobStep(null));
955+
resources.add(PodHelper.createAdminPodStep(null));
907956
resources.add(new BeforeAdminServiceStep(null));
908957
resources.add(ServiceHelper.createForServerStep(null));
909958
resources.add(new WatchPodReadyAdminStep(Main.podWatchers, null));

operator/src/main/java/oracle/kubernetes/operator/helpers/ConfigMapHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ private static String getOperatorNamespace() {
304304
}
305305
}
306306

307-
static class SitConfigMapContext extends ConfigMapContext {
307+
public static class SitConfigMapContext extends ConfigMapContext {
308308
Map<String, String> data;
309309
String cmName;
310310

@@ -513,7 +513,7 @@ static String extractFilename(String line) {
513513
return fname;
514514
}
515515

516-
static DomainTopology parseDomainTopologyYaml(String topologyYaml) {
516+
public static DomainTopology parseDomainTopologyYaml(String topologyYaml) {
517517
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
518518

519519
try {

0 commit comments

Comments
 (0)