Skip to content

Commit 9ab006b

Browse files
committed
Merge branch 'develop' of https://github.com/oracle/weblogic-kubernetes-operator into chshi-OWLS-67963-upd-del-sh
2 parents f7a42e0 + e6995e5 commit 9ab006b

File tree

66 files changed

+2649
-1767
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2649
-1767
lines changed

integration-tests/src/test/java/oracle/kubernetes/operator/BaseTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ public static void initialize(String appPropsFile) throws Exception {
148148
*/
149149
public void testAdminServerExternalService(Domain domain) throws Exception {
150150
logger.info("Inside testAdminServerExternalService");
151+
TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId());
151152
domain.verifyAdminServerExternalService(getUsername(), getPassword());
152153
logger.info("Done - testAdminServerExternalService");
153154
}
@@ -159,6 +160,7 @@ public void testAdminServerExternalService(Domain domain) throws Exception {
159160
*/
160161
public void testAdminT3Channel(Domain domain) throws Exception {
161162
logger.info("Inside testAdminT3Channel");
163+
TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId());
162164
Map<String, Object> domainMap = domain.getDomainMap();
163165
// check if the property is set to true
164166
Boolean exposeAdmint3Channel = (Boolean) domainMap.get("exposeAdminT3Channel");
@@ -203,6 +205,7 @@ public void testDomainLifecyle(Operator operator, Domain domain) throws Exceptio
203205
*/
204206
public void testClusterScaling(Operator operator, Domain domain) throws Exception {
205207
logger.info("Inside testClusterScaling");
208+
TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId());
206209
Map<String, Object> domainMap = domain.getDomainMap();
207210
String domainUid = domain.getDomainUid();
208211
String domainNS = domainMap.get("namespace").toString();
@@ -263,6 +266,7 @@ public void testClusterScaling(Operator operator, Domain domain) throws Exceptio
263266
*/
264267
public void testWLDFScaling(Operator operator, Domain domain) throws Exception {
265268
logger.info("Inside testWLDFScaling");
269+
TestUtils.renewK8sClusterLease(getProjectRoot(), getLeaseId());
266270

267271
Map<String, Object> domainMap = domain.getDomainMap();
268272
String domainUid = domain.getDomainUid();

integration-tests/src/test/java/oracle/kubernetes/operator/ITOperator.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ public void test3CreateDomainInTest1NS() throws Exception {
135135
}
136136
// create domain3
137137
Domain domain3 = testDomainCreation(domain3YamlFile);
138-
139138
testWLDFScaling(operator1, domain3);
140139
logger.info("SUCCESS - test3CreateDomainInTest1NS");
141140
}
@@ -227,8 +226,6 @@ public void test7CreateDomainPVReclaimPolicyRecycle() throws Exception {
227226

228227
@Test
229228
public void test8WlsLivenessProbe() throws Exception {
230-
Assume.assumeFalse(
231-
System.getenv("QUICKTEST") != null && System.getenv("QUICKTEST").equalsIgnoreCase("true"));
232229

233230
logTestBegin("test8WlsLivenessProbe");
234231
logger.info("Checking if operator1 is running, if not creating");
@@ -402,8 +399,8 @@ private Domain testAllUseCasesForADomain(Operator operator, String domainYamlFil
402399
// create domain1
403400
Domain domain = testDomainCreation(domainYamlFile);
404401
testDomainLifecyle(operator, domain);
405-
testClusterScaling(operator, domain);
406402
testOperatorLifecycle(operator, domain);
403+
testClusterScaling(operator, domain);
407404
return domain;
408405
}
409406

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ public static void testWlsLivenessProbe(String domainUid, String serverName, Str
230230

231231
// kill server process 3 times
232232
for (int i = 0; i < 3; i++) {
233-
kubectlexecNoCheck(podName, namespace, "/shared/killserver.sh");
233+
ExecResult result = kubectlexecNoCheck(podName, namespace, "/shared/killserver.sh");
234+
logger.info("kill server process command exitValue " + result.exitValue());
235+
logger.info(
236+
"kill server process command result " + result.stdout() + " stderr " + result.stderr());
234237
Thread.sleep(2 * 1000);
235238
}
236239
// one more time so that liveness probe restarts
@@ -241,6 +244,7 @@ public static void testWlsLivenessProbe(String domainUid, String serverName, Str
241244
while (true) {
242245
long currentTime = System.currentTimeMillis();
243246
int finalRestartCnt = getPodRestartCount(podName, namespace);
247+
logger.info("initialRestartCnt " + initialRestartCnt + " finalRestartCnt " + finalRestartCnt);
244248
if ((finalRestartCnt - initialRestartCnt) == 1) {
245249
logger.info("WLS liveness probe test is successful.");
246250
break;
@@ -301,6 +305,8 @@ public static ExecResult kubectlexecNoCheck(String podName, String namespace, St
301305
.append(" ")
302306
.append(scriptPath);
303307

308+
ExecResult result = ExecCommand.exec("kubectl get pods -n " + namespace);
309+
logger.info("get pods before killing the server " + result.stdout() + "\n " + result.stderr());
304310
logger.info("Command to call kubectl sh file " + cmdKubectlSh);
305311
return ExecCommand.exec(cmdKubectlSh.toString());
306312
}
@@ -526,11 +532,11 @@ public static void renewK8sClusterLease(String projectRoot, String leaseId) thro
526532
+ " to try renew the lease. "
527533
+ "Some of the potential reasons for this failure are that another run"
528534
+ "may have obtained the lease, the lease may have been externally "
529-
+ "deleted, or the caller of run.sh may have forgotten to obtain the"
530-
+ "lease before calling run.sh (using 'lease.sh -o \"$LEASE_ID\"'). "
535+
+ "deleted, or the caller of the test may have forgotten to obtain the "
536+
+ "lease before calling the test (using 'lease.sh -o \"$LEASE_ID\"'). "
531537
+ "To force delete a lease no matter who owns the lease,"
532538
+ "call 'lease.sh -f' or 'kubernetes delete cm acceptance-test-lease'"
533-
+ "(this should only be done when sure there's no current run.sh "
539+
+ "(this should only be done when sure there's no current java tests "
534540
+ "that owns the lease). To view the current lease holder,"
535541
+ "use 'lease.sh -s'. To disable this lease check, do not set"
536542
+ "the LEASE_ID environment variable.");

kubernetes/samples/charts/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Weblogic operator supports three types load balancers: TRAEFIK, VOYAGER, APACHE. We provide samples for each type to demostrate how to install and configure load balancer. Samples are located in following folders:
2+
traefik
3+
voyager
4+
ingress-per-domain
5+
apache-samples
6+
Note: apache-webtier is helm chart. It is used in apache-samples.
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# Apache Load Balancer custom sample
2+
In this sample, we will configure Apache webtier as a load balancer for multiple WebLogic domains using custom configuration. We will demonstrate how to use Apache webtier to handle traffic to the multiple backend WebLogic domains.
3+
4+
## 1. Create Namespace
5+
In this sample, both Apache webtier and WebLogic domain instances are located in the namespace `apache-sample`.
6+
```
7+
$ kubectl create namespace apache-sample
8+
```
9+
10+
## 2. Create WebLogic Domains
11+
Now we need to prepare some backends for Apache webtier to do load balancing. Please refer the sample https://github.com/oracle/weblogic-kubernetes-operator/tree/develop/kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv to create two WebLogic domains under the namespace `apache-sample`.
12+
13+
The first domain uses the following custom configuration parameters:
14+
- namespace: apache-sample
15+
- domainUID: domain1
16+
- clusterName: cluster-1
17+
- adminServerName: admin-server
18+
- adminPort: 7001
19+
- adminNodePort: 30701
20+
- managedServerPort: 8001
21+
22+
The second domain uses the following custom configuration parameters:
23+
- namespace: apache-sample
24+
- domainUID: domain2
25+
- clusterName: cluster-1
26+
- adminServerName: admin-server
27+
- adminPort: 7011
28+
- adminNodePort: 30702
29+
- managedServerPort: 8021
30+
31+
After the domains are successfully created, deploy the sample web application testwebapp.war on each domain cluster through the admin console. The sample web application is located in the kubernetes/samples/charts/application directory.
32+
33+
## 3. Build Apache Webtier Docker Image
34+
Please refer the sample https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/12213-webtier-apache to build Apache webtier docker image.
35+
36+
## 4. Provide Custom Apache Plugin Configuration
37+
In this sample we will provide custom Apache plugin configuration to fine tune the behavior of Apache.
38+
- Create a custom Apache plugin configuration file named `custom_mod_wl_apache.conf`. The file content is similar as below.
39+
```
40+
# Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
41+
#
42+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
43+
#
44+
45+
<IfModule mod_weblogic.c>
46+
WebLogicHost ${WEBLOGIC_HOST}
47+
WebLogicPort ${WEBLOGIC_PORT}
48+
</IfModule>
49+
50+
# Directive for weblogic admin Console deployed on Weblogic Admin Server
51+
<Location /console>
52+
SetHandler weblogic-handler
53+
WebLogicHost domain1-admin-server
54+
WebLogicPort ${WEBLOGIC_PORT}
55+
</Location>
56+
57+
# Directive for all application deployed on weblogic cluster with a prepath defined by LOCATION variable
58+
# For example, if the LOCAITON is set to '/weblogic', all applications deployed on the cluster can be accessed via
59+
# http://myhost:myport/weblogic/application_end_url
60+
# where 'myhost' is the IP of the machine that runs the Apache web tier, and
61+
# 'myport' is the port that the Apache web tier is publicly exposed to.
62+
# Note that LOCATION cannot be set to '/' unless this is the only Location module configured.
63+
<Location /weblogic1>
64+
WLSRequest On
65+
WebLogicCluster domain1-cluster-cluster-1:8001
66+
PathTrim /weblogic1
67+
</Location>
68+
69+
# Directive for all application deployed on weblogic cluster with a prepath defined by LOCATION2 variable
70+
# For example, if the LOCAITON2 is set to '/weblogic2', all applications deployed on the cluster can be accessed via
71+
# http://myhost:myport/weblogic2/application_end_url
72+
# where 'myhost' is the IP of the machine that runs the Apache web tier, and
73+
# 'myport' is the port that the Apache webt ier is publicly exposed to.
74+
<Location /weblogic2>
75+
WLSRequest On
76+
WebLogicCluster domain2-cluster-cluster-1:8021
77+
PathTrim /weblogic2
78+
</Location>
79+
```
80+
- Place the `custom_mod_wl_apache.conf` file in a local directory `<host-config-dir>` on the host machine.
81+
82+
## 5. Prepare Your Own Certificate and Private Key
83+
In production, Oracle strongly recommends that you provide your own certificates. Run following commands to to generate your own certificate and private key using openssl.
84+
```
85+
$ cd kubernetes/samples/charts/apache-samples/custom-sample
86+
$ export VIRTUAL_HOST_NAME=apache-sample-host
87+
$ export SSL_CERT_FILE=apache-sample.crt
88+
$ export SSL_CERT_KEY_FILE=apache-sample.key
89+
$ sh certgen.sh
90+
```
91+
92+
## 6. Prepare the Input Values for Apache Webtier Helm Chart
93+
Run following commands to prepare the input value file for Apache webtier helm chart.
94+
```
95+
$ base64 -i ${SSL_CERT_FILE} | tr -d '\n'
96+
$ base64 -i ${SSL_CERT_KEY_FILE} | tr -d '\n'
97+
$ touch input.yaml
98+
```
99+
Edit the input parameters file `input.yaml`, the file content is similar as below.
100+
```
101+
# Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
102+
#
103+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
104+
105+
# Use this to provide your own Apache webtier configuration as needed; simply define this
106+
# path and put your own custom_mod_wl_apache.conf file under this path.
107+
volumePath: <host-config-dir>
108+
109+
# The VirtualHostName of the Apache HTTP server. It is used to enable custom SSL configuration.
110+
virtualHostName: apache-sample-host
111+
112+
# The customer supplied certificate to use for Apache webtier SSL configuration.
113+
# The value must be a string containing a base64 encoded certificate. Run following command to get it.
114+
# base64 -i ${SSL_CERT_FILE} | tr -d '\n'
115+
customCert: <cert_data>
116+
117+
# The customer supplied private key to use for Apache webtier SSL configuration.
118+
# The value must be a string containing a base64 encoded key. Run following command to get it.
119+
# base64 -i ${SSL_KEY_FILE} | tr -d '\n'
120+
customKey: <key_data>
121+
```
122+
123+
## 7. Install Apache Webtier Helm Chart
124+
Apache webtier helm chart is located in kubernetes/samples/charts/apache-webtier directory. Install Apache webtier helm chart to apache-sample namespace with specified input parameters:
125+
```
126+
$ cd kubernetes/samples/charts
127+
$ helm install --name my-release --values apache-samples/custom-sample/input.yaml --namespace apache-sample apache-webtier
128+
```
129+
130+
## 8. Run the Sample Application
131+
Now you can send requests to different WebLogic domains with the unique entry point of Apache with different path. Alternatively, you can access the URLs in a web browser.
132+
```
133+
$ curl --silent http://${HOSTNAME}:30305/weblogic1/testwebapp/
134+
$ curl --silent http://${HOSTNAME}:30305/weblogic2/testwebapp/
135+
```
136+
You can also use SSL URLs to send requests to different WebLogic domains. Access the SSL URL via the curl command or a web browser.
137+
```
138+
$ curl -k --silent https://${HOSTNAME}:30443/weblogic1/testwebapp/
139+
$ curl -k --silent https://${HOSTNAME}:30443/weblogic2/testwebapp/
140+
```
141+
142+
## 9. Uninstall Apache Webtier
143+
```
144+
$ helm delete --purge my-release
145+
```
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/sh
2+
#
3+
# Since: June, 2018
4+
5+
# Description: script to start Apache HTTP Server
6+
#
7+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8+
#
9+
# Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
10+
#
11+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
12+
13+
# Generated configuration file
14+
CONFIG_FILE="config.txt"
15+
16+
cat > $CONFIG_FILE <<-EOF
17+
[req]
18+
default_bits = 2048
19+
prompt = no
20+
default_md = sha256
21+
req_extensions=v3_req
22+
extensions=v3_req
23+
distinguished_name = dn
24+
25+
[dn]
26+
C = US
27+
ST = CA
28+
L = Redwood Shores
29+
O = Oracle Corporation
30+
OU = Apache HTTP Server With Plugin
31+
CN = $VIRTUAL_HOST_NAME
32+
33+
[v3_req]
34+
subjectAltName = @alt_names
35+
[alt_names]
36+
DNS.1 = $VIRTUAL_HOST_NAME
37+
DNS.2 = $VIRTUAL_HOST_NAME.us.oracle.com
38+
DNS.3 = $VIRTUAL_HOST_NAME.cloud.oracle.com
39+
DNS.4 = *.$VIRTUAL_HOST_NAME
40+
DNS.5 = localhost
41+
EOF
42+
43+
echo "Generating certs for $VIRTUAL_HOST_NAME"
44+
45+
# Generate our Private Key, CSR and Certificate
46+
# Use SHA-2 as SHA-1 is unsupported from Jan 1, 2017
47+
48+
openssl req -x509 -newkey rsa:2048 -sha256 -nodes -keyout "$SSL_CERT_KEY_FILE" -days 3650 -out "$SSL_CERT_FILE" -config "$CONFIG_FILE"
49+
50+
# OPTIONAL - write an info to see the details of the generated crt
51+
openssl x509 -noout -fingerprint -text < "$SSL_CERT_FILE" > "$SSL_CERT_FILE.info"
52+
# Protect the key
53+
chmod 400 "$SSL_CERT_KEY_FILE"
54+
chmod 400 "$SSL_CERT_FILE.info"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
2+
#
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4+
#
5+
6+
<IfModule mod_weblogic.c>
7+
WebLogicHost ${WEBLOGIC_HOST}
8+
WebLogicPort ${WEBLOGIC_PORT}
9+
</IfModule>
10+
11+
# Directive for weblogic admin Console deployed on Weblogic Admin Server
12+
<Location /console>
13+
SetHandler weblogic-handler
14+
WebLogicHost domain1-admin-server
15+
WebLogicPort ${WEBLOGIC_PORT}
16+
</Location>
17+
18+
# Directive for all application deployed on weblogic cluster with a prepath defined by LOCATION variable
19+
# For example, if the LOCAITON is set to '/weblogic', all applications deployed on the cluster can be accessed via
20+
# http://myhost:myport/weblogic/application_end_url
21+
# where 'myhost' is the IP of the machine that runs the Apache web tier, and
22+
# 'myport' is the port that the Apache web tier is publicly exposed to.
23+
# Note that LOCATION cannot be set to '/' unless this is the only Location module configured.
24+
<Location /weblogic1>
25+
WLSRequest On
26+
WebLogicCluster domain1-cluster-cluster-1:8001
27+
PathTrim /weblogic1
28+
</Location>
29+
30+
# Directive for all application deployed on weblogic cluster with a prepath defined by LOCATION2 variable
31+
# For example, if the LOCAITON2 is set to '/weblogic2', all applications deployed on the cluster can be accessed via
32+
# http://myhost:myport/weblogic2/application_end_url
33+
# where 'myhost' is the IP of the machine that runs the Apache web tier, and
34+
# 'myport' is the port that the Apache webt ier is publicly exposed to.
35+
<Location /weblogic2>
36+
WLSRequest On
37+
WebLogicCluster domain2-cluster-cluster-1:8021
38+
PathTrim /weblogic2
39+
</Location>

0 commit comments

Comments
 (0)