Skip to content

Commit cda34e9

Browse files
authored
Merge pull request #831 from oracle/owls-71300-sample-updates
OWLS-71300 sample updates and cleanup
2 parents c14763c + 61544b0 commit cda34e9

File tree

7 files changed

+44
-32
lines changed

7 files changed

+44
-32
lines changed

kubernetes/samples/scripts/common/utility.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ function createFiles {
277277
domainPropertiesOutput="${domainOutputDir}/domain.properties"
278278
domainHome="/u01/oracle/user_projects/domains/${domainName}"
279279

280+
if [ -z $domainHomeImageBuildPath ]; then
281+
domainHomeImageBuildPath="./docker-images/OracleWebLogic/samples/12213-domain-home-in-image"
282+
fi
283+
280284
# Generate the properties file that will be used when creating the weblogic domain
281285
echo Generating ${domainPropertiesOutput}
282286

@@ -294,6 +298,15 @@ function createFiles {
294298
sed -i -e "s:%T3_CHANNEL_PORT%:${t3ChannelPort}:g" ${domainPropertiesOutput}
295299
sed -i -e "s:%T3_PUBLIC_ADDRESS%:${t3PublicAddress}:g" ${domainPropertiesOutput}
296300

301+
if [ -z "${image}" ]; then
302+
# calculate the internal name to tag the generated image
303+
defaultImageName="`basename ${domainHomeImageBuildPath} | sed 's/^[0-9]*-//'`"
304+
baseTag=${domainHomeImageBase#*:}
305+
defaultImageName=${defaultImageName}:${baseTag:-"latest"}
306+
sed -i -e "s|%IMAGE_NAME%|${defaultImageName}|g" ${domainPropertiesOutput}
307+
else
308+
sed -i -e "s|%IMAGE_NAME%|${image}|g" ${domainPropertiesOutput}
309+
fi
297310
else
298311

299312
createJobOutput="${domainOutputDir}/create-domain-job.yaml"
@@ -401,23 +414,20 @@ function createFiles {
401414
sed -i -e "s:%INITIAL_MANAGED_SERVER_REPLICAS%:${initialManagedServerReplicas}:g" ${dcrOutput}
402415

403416
if [ "${domainHomeInImage}" == "true" ]; then
404-
if [ -z $domainHomeImageBuildPath ]; then
405-
domainHomeImageBuildPath="./docker-images/OracleWebLogic/samples/12213-domain-home-in-image-wdt"
406-
fi
407-
imageName="`basename ${domainHomeImageBuildPath} | sed 's/^[0-9]*-//'`"
408-
417+
409418
# now we know which image to use, update the domain yaml file
410419
if [ -z $image ]; then
411-
sed -i -e "s|%WEBLOGIC_IMAGE%|${imageName}|g" ${dcrOutput}
420+
sed -i -e "s|%WEBLOGIC_IMAGE%|${defaultImageName}|g" ${dcrOutput}
412421
else
413422
sed -i -e "s|%WEBLOGIC_IMAGE%|${image}|g" ${dcrOutput}
414423
fi
415424
else
416425
sed -i -e "s:%WEBLOGIC_IMAGE%:${image}:g" ${dcrOutput}
417426
fi
418427

419-
# Remove any "...yaml-e" files left over from running sed
428+
# Remove any "...yaml-e" and "...properties-e" files left over from running sed
420429
rm -f ${domainOutputDir}/*.yaml-e
430+
rm -f ${domainOutputDir}/*.properties-e
421431
}
422432

423433
#

kubernetes/samples/scripts/create-weblogic-domain/domain-home-in-image/README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Before you begin, read this guide, [Domain Resource](../../../../../site/domain-
88

99
The following prerequisites must be handled prior to running the create domain script:
1010
* The WDT sample requires that `JAVA_HOME` is set to a Java JDK version 1.8 or later.
11-
* The operator requires WebLogic Server 12.2.1.3.0 with patch 29135930 applied. Refer to [WebLogic Docker images](../../../../../site/weblogic-docker-images.md) for details on how to create one.
11+
* The operator requires WebLogic Server 12.2.1.3.0 with patch 29135930 applied. The existing WebLogic Docker image, `store/oracle/weblogic:12.2.1.3`, was updated on January 17, 2019, and has all the necessary patches applied; a `docker pull` is required if you already have this image. Refer to [WebLogic Docker images](../../../../../site/weblogic-docker-images.md) for details on how to obtain or create the image.
1212
* Create a Kubernetes namespace for the domain unless the intention is to use the default namespace.
1313
* If logHomeOnPV is enabled, create the Kubernetes persistent volume where the log home will be hosted, and the Kubernetes persistent volume claim for the domain in the same Kubernates namespace. For samples to create a PV and PVC, see [Create sample PV and PVC](../../create-weblogic-domain-pv-pvc/README.md).
1414
* Create a Kubernetes secret for the WebLogic administrator credentials that contains the fields `username` and `password`, and make sure that the secret name matches the value specified for `weblogicCredentialsSecretName` (see Configuration table below). For example:
@@ -26,6 +26,12 @@ $ create-weblogic-credentials.sh
2626

2727
## Use the script to create a domain
2828

29+
**Note**: The `create-domain.sh` script generates a new Docker image on each run with a new domain home and a different internal `domain secret` in it. To prevent having disparate images with different domain secrets in the same domain, we strongly recommend that a new domain uses a `domainUID` that is different from any of the active domains, or that you delete the existing domain resource using the following command and wait until all the server pods are terminated before you create a domain with the same `domainUID`:
30+
31+
```
32+
$kubectl delete domain [domainUID] -n [domainNamespace]
33+
```
34+
2935
Make a copy of the `create-domain-inputs.yaml` file, and run the create script, pointing it at your inputs file and an output directory:
3036

3137
```
@@ -40,7 +46,7 @@ The script will perform the following steps:
4046

4147
* Create a directory for the generated properties and Kubernetes YAML files for this domain if it does not already exist. The pathname is `/path/to/weblogic-operator-output-directory/weblogic-domains/<domainUID>`. If the directory already exists, its contents will be removed.
4248
* Create a properties file, `domain.properties`, in the directory that is created above. This properties file will be used to create a sample WebLogic Server domain.
43-
* Clone the WebLogic docker-images project into the current directory using `git clone https://github.com/oracle/docker-images.git`.
49+
* Clone the WebLogic docker-images project into the directory that is derived from the `domainHomeImageBuildPath` property using `git clone https://github.com/oracle/docker-images.git`. By default, the script always cleans up the directory and clones it again on every run. You need to specify the `-k` option if you want to use a previously cloned project. Note that if the specified `domainHomeImageBuildPath` is empty, the script will still clone the project even if the `-k` option is specified.
4450
* Replace the built-in user name and password in the `properties/docker-build/domain_security.properties` file with the `username` and `password` that are supplied on the command line using the `-u` and `-p` options. These credentials need to match the WebLogic domain admin credentials in the secret that is specified via the `weblogicCredentialsSecretName` property in the `create-domain-inputs.yaml` file.
4551
* Build a Docker image based on the Docker sample, [Example Image with a WebLogic Server Domain using the Oracle WebLogic Scripting Tooling (WLST)](https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/12213-domain-home-in-image) or [Example Image with a WebLogic Server Domain using the Oracle WebLogic Deploy Tooling (WDT)](https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/12213-domain-home-in-image-wdt). It will create a sample WebLogic Server domain in the Docker image. **Note**: Oracle recommends keeping the domain home image private in the local repository.
4652
* Create a tag that refers to the generated Docker image.
@@ -102,13 +108,13 @@ The following parameters can be provided in the inputs file.
102108
| `adminServerName` | Name of the Administration Server. | `admin-server` |
103109
| `clusterName` | Name of the WebLogic cluster instance to generate for the domain. | `cluster-1` |
104110
| `configuredManagedServerCount` | Number of Managed Server instances to generate for the domain. | `5` |
105-
| `domainHomeImageBase` | Base WebLogic binary image used to build the WebLogic domain image. The operator requires WebLogic Server 12.2.1.3.0 with patch 29135930 applied. Refer to [WebLogic Docker images](../../../../../site/weblogic-docker-images.md) for details on how to create one. | |
111+
| `domainHomeImageBase` | Base WebLogic binary image used to build the WebLogic domain image. The operator requires WebLogic Server 12.2.1.3.0 with patch 29135930 applied. The existing WebLogic Docker image, `store/oracle/weblogic:12.2.1.3`, was updated on January 17, 2019, and has all the necessary patches applied; a `docker pull` is required if you already have this image. Refer to [WebLogic Docker images](../../../../../site/weblogic-docker-images.md) for details on how to obtain or create the image. | `store/oracle/weblogic:12.2.1.3` |
106112
| `domainHomeImageBuildPath` | Location of the WebLogic "domain home in image" Docker image in `https://github.com/oracle/docker-images.git` project. If not specified, use "./docker-images/OracleWebLogic/samples/12213-domain-home-in-image". Another possible value is "./docker-images/OracleWebLogic/samples/12213-domain-home-in-image-wdt" which uses WDT, instead of WLST, to generate the domain configuration. | `./docker-images/OracleWebLogic/samples/12213-domain-home-in-image` |
107113
| `domainPVMountPath` | Mount path of the domain persistent volume. This parameter is required if `logHomeOnPV` is true. Otherwise, it is ignored. | `/shared` |
108114
| `domainUID` | Unique ID that will be used to identify this particular domain. Used as the name of the generated WebLogic domain as well as the name of the Kubernetes domain resource. This ID must be unique across all domains in a Kubernetes cluster. This ID cannot contain any character that is not valid in a Kubernetes service name. | `domain1` |
109115
| `exposeAdminNodePort` | Boolean indicating if the Administration Server is exposed outside of the Kubernetes cluster. | `false` |
110116
| `exposeAdminT3Channel` | Boolean indicating if the T3 administrative channel is exposed outside the Kubernetes cluster. | `false` |
111-
| `image` | WebLogic Server Docker image that the operator uses to start the domain. The create domain scripts generate a WebLogic Server Docker image with a domain home in it. By default, the scripts tag the generated WebLogic server Docker image as either `domain-home-in-image` or `domain-home-in-image-wdt` based on the `domainHomeImageBuildPath` property, and use it to set the `image` element in the generated domain YAML file. If this property is set, the create domain scripts will use the value specified, instead of the default value, to tag the generated image and set the `image` in the domain YAML file. If you are running the sample scripts from a machine that is remote to the Kubernetes cluster where the domain is going to be running, you need to set this property to the image name that is intended to be used in a registry local to that Kubernetes cluster. You also need to push the `image` to that registry before starting the domain using the `kubectl create -f` or `kubectl apply -f` command. | |
117+
| `image` | WebLogic Server Docker image that the operator uses to start the domain. The create domain scripts generate a WebLogic Server Docker image with a domain home in it. By default, the scripts tag the generated WebLogic server Docker image as either `domain-home-in-image` or `domain-home-in-image-wdt` based on the `domainHomeImageBuildPath` property, and use it plus the tag that is obtained from the `domainHomeImageBase` to set the `image` element in the generated domain YAML file. If this property is set, the create domain scripts will use the value specified, instead of the default value, to tag the generated image and set the `image` in the domain YAML file. If you are running the sample scripts from a machine that is remote to the Kubernetes cluster where the domain is going to be running, you need to set this property to the image name that is intended to be used in a registry local to that Kubernetes cluster. You also need to push the `image` to that registry before starting the domain using the `kubectl create -f` or `kubectl apply -f` command. | |
112118
| `imagePullPolicy` | WebLogic Docker image pull policy. Legal values are `IfNotPresent`, `Always`, or `Never`. | `IfNotPresent` |
113119
| `imagePullSecretName` | Name of the Kubernetes secret to access the Docker Store to pull the WebLogic Server Docker image. The presence of the secret will be validated when this parameter is specified. | |
114120
| `includeServerOutInPodLog` | Boolean indicating whether to include `server.out` to the pod's stdout. | `true` |
@@ -161,7 +167,7 @@ spec:
161167
# If the domain home is in the image
162168
domainHomeInImage: true
163169
# The WebLogic Server Docker image that the operator uses to start the domain
164-
image: "domain-home-in-image"
170+
image: "domain-home-in-image:12.2.1.3"
165171
# imagePullPolicy defaults to "Always" if image version is :latest
166172
imagePullPolicy: "IfNotPresent"
167173
# Identify which Secret contains the credentials for pulling an image
@@ -295,7 +301,7 @@ Spec:
295301
Server Start State: RUNNING
296302
Domain Home: /u01/oracle/user_projects/domains/domain1
297303
Domain Home In Image: true
298-
Image: domain-home-in-image
304+
Image: domain-home-in-image:12.2.1.3
299305
Image Pull Policy: IfNotPresent
300306
Include Server Out In Pod Log: true
301307
Managed Servers:

kubernetes/samples/scripts/create-weblogic-domain/domain-home-in-image/create-domain-inputs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ domainPVMountPath: /shared
125125
# Refer to [WebLogic Docker images](../../../../../site/weblogic-docker-images.md) for details on how
126126
# to obtain or create the image.
127127
# See README.md for more help.
128-
#domainHomeImageBase:
128+
domainHomeImageBase: store/oracle/weblogic:12.2.1.3
129129

130130
# Location of the WebLogic "domain home in image" Docker image sample in the
131131
# `https://github.com/oracle/docker-images.git` project.

kubernetes/samples/scripts/create-weblogic-domain/domain-home-in-image/create-domain.sh

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function initialize {
155155

156156
initOutputDir
157157

158-
if [ "${cloneIt}" = true ]; then
158+
if [ "${cloneIt}" = true ] || [ ! -d ${domainHomeImageBuildPath} ]; then
159159
getDockerSample
160160
fi
161161
}
@@ -164,15 +164,16 @@ function initialize {
164164
# Function to get the dependency docker sample
165165
#
166166
function getDockerSample {
167-
rm -rf ${scriptDir}/docker-images
168-
git clone https://github.com/oracle/docker-images.git ${scriptDir}/docker-images
167+
dockerImagesDir=${domainHomeImageBuildPath%/OracleWebLogic*}
168+
rm -rf ${dockerImagesDir}
169+
git clone https://github.com/oracle/docker-images.git ${dockerImagesDir}
169170
}
170171

171172
#
172173
# Function to build docker image and create WebLogic domain home
173174
#
174175
function createDomainHome {
175-
dockerDir=${scriptDir}/${domainHomeImageBuildPath}
176+
dockerDir=${domainHomeImageBuildPath}
176177
dockerPropsDir=${dockerDir}/properties
177178
cp ${domainPropertiesOutput} ${dockerPropsDir}/docker-build
178179

@@ -194,19 +195,14 @@ function createDomainHome {
194195
fi
195196

196197
sh ${dockerDir}/build.sh
197-
imageNameOrigin="`basename ${domainHomeImageBuildPath}`"
198-
199-
# if use the default images, we tag it to a more generic name (without the release version numbers)
200-
if [ -z $image ]; then
201-
docker tag $imageNameOrigin:latest $imageName:latest
202-
else
203-
docker tag $imageNameOrigin:latest $image
204-
fi
205198

206199
if [ "$?" != "0" ]; then
207200
fail "Create domain ${domainName} failed."
208201
fi
209202

203+
# clean up the generated domain.properties file
204+
rm ${domainPropertiesOutput}
205+
210206
echo ""
211207
echo "Create domain ${domainName} successfully."
212208
}
@@ -230,7 +226,6 @@ function printSummary {
230226
fi
231227
echo "The following files were generated:"
232228
echo " ${domainOutputDir}/create-domain-inputs.yaml"
233-
echo " ${domainPropertiesOutput}"
234229
echo " ${dcrOutput}"
235230
echo ""
236231
echo "Completed"

kubernetes/samples/scripts/create-weblogic-domain/domain-home-in-image/properties-template.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ CLUSTER_TYPE=DYNAMIC
1515
JAVA_OPTIONS=%JAVA_OPTIONS%
1616
T3_CHANNEL_PORT=%T3_CHANNEL_PORT%
1717
T3_PUBLIC_ADDRESS=%T3_PUBLIC_ADDRESS%
18+
IMAGE_TAG=%IMAGE_NAME%

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Before you begin, read this guide, [Domain Resource](../../../../../site/domain-
88

99
The following prerequisites must be handled prior to running the create domain script:
1010
* Make sure the WebLogic operator is running.
11-
* The operator requires WebLogic Server 12.2.1.3.0 with patch 29135930 applied. Refer to [WebLogic Docker images](../../../../../site/weblogic-docker-images.md) for details on how to create one.
11+
* The operator requires WebLogic Server 12.2.1.3.0 with patch 29135930 applied. The existing WebLogic Docker image, `store/oracle/weblogic:12.2.1.3`, was updated on January 17, 2019, and has all the necessary patches applied; a `docker pull` is required if you already have this image. Refer to [WebLogic Docker images](../../../../../site/weblogic-docker-images.md) for details on how to obtain or create the image.
1212
* Create a Kubernetes namespace for the domain unless the intention is to use the default namespace.
1313
* In the same Kubernetes namespace, create the Kubernetes persistent volume where the domain home will be hosted, and the Kubernetes persistent volume claim for the domain. For samples to create a PV and PVC, see [Create sample PV and PVC](../../create-weblogic-domain-pv-pvc/README.md).
1414
* Create the Kubernetes secrets `username` and `password` of the admin account in the same Kubernetes namespace as the domain.
@@ -82,7 +82,7 @@ The following parameters can be provided in the inputs file.
8282
| `domainUID` | Unique ID that will be used to identify this particular domain. Used as the name of the generated WebLogic domain as well as the name of the Kubernetes domain resource. This ID must be unique across all domains in a Kubernetes cluster. This ID cannot contain any character that is not valid in a Kubernetes service name. | `domain1` |
8383
| `exposeAdminNodePort` | Boolean indicating if the Administration Server is exposed outside of the Kubernetes cluster. | `false` |
8484
| `exposeAdminT3Channel` | Boolean indicating if the T3 administrative channel is exposed outside the Kubernetes cluster. | `false` |
85-
| `image` | WebLogic Docker image. The operator requires WebLogic Server 12.2.1.3.0 with patch 29135930 applied. Refer to [WebLogic Docker images](../../../../../site/weblogic-docker-images.md) for details on how to create one. | |
85+
| `image` | WebLogic Docker image. The operator requires WebLogic Server 12.2.1.3.0 with patch 29135930 applied. The existing WebLogic Docker image, `store/oracle/weblogic:12.2.1.3`, was updated on January 17, 2019, and has all the necessary patches applied; a `docker pull` is required if you already have this image. Refer to [WebLogic Docker images](../../../../../site/weblogic-docker-images.md) for details on how to obtain or create the image. | `store/oracle/weblogic:12.2.1.3` |
8686
| `imagePullPolicy` | WebLogic Docker image pull policy. Legal values are "IfNotPresent", "Always", or "Never" | `IfNotPresent` |
8787
| `imagePullSecretName` | Name of the Kubernetes secret to access the Docker Store to pull the WebLogic Server Docker image. The presence of the secret will be validated when this parameter is specified | |
8888
| `includeServerOutInPodLog` | Boolean indicating whether to include server .out to the pod's stdout. | `true` |
@@ -135,7 +135,7 @@ spec:
135135
# If the domain home is in the image
136136
domainHomeInImage: false
137137
# The WebLogic Server Docker image that the operator uses to start the domain
138-
image: "oracle/weblogic:12213-patch-wls-for-k8s"
138+
image: "store/oracle/weblogic:12.2.1.3"
139139
# imagePullPolicy defaults to "Always" if image version is :latest
140140
imagePullPolicy: "IfNotPresent"
141141
# Identify which Secret contains the credentials for pulling an image
@@ -268,7 +268,7 @@ Spec:
268268
Server Start State: RUNNING
269269
Domain Home: /shared/domains/domain1
270270
Domain Home In Image: false
271-
Image: oracle/weblogic:12213-patch-wls-for-k8s
271+
Image: store/oracle/weblogic:12.2.1.3
272272
Image Pull Policy: IfNotPresent
273273
Include Server Out In Pod Log: true
274274
Log Home: /shared/logs/domain1

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ managedServerPort: 8001
4343
# and has all the necessary patches applied; a `docker pull` is required if you already have this image.
4444
# Refer to [WebLogic Docker images](../../../../../site/weblogic-docker-images.md) for details on how
4545
# to obtain or create the image.
46-
#image:
46+
image: store/oracle/weblogic:12.2.1.3
4747

4848
# Image pull policy
4949
# Legal values are "IfNotPresent", "Always", or "Never"

0 commit comments

Comments
 (0)