Skip to content

Commit d3ddbe8

Browse files
authored
Merge pull request #1183 from oracle/OWLS-75483
OWLS-75483: add sample scripts to create FMW Domain using domain-home…
2 parents 3eedba7 + c613284 commit d3ddbe8

File tree

3 files changed

+422
-0
lines changed

3 files changed

+422
-0
lines changed
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
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 http://oss.oracle.com/licenses/upl.
3+
4+
# The version of this inputs file. Do not modify.
5+
version: create-weblogic-sample-domain-inputs-v1
6+
7+
# Port number for admin server
8+
adminPort: 7001
9+
10+
# Name of the Admin Server
11+
adminServerName: admin-server
12+
13+
# Unique ID identifying a domain.
14+
# This ID must not contain an underscope ("_"), and must be lowercase and unique across all domains
15+
# in a Kubernetes cluster.
16+
domainUID: domain1
17+
18+
# Determines which OracleFMWInfrastructure Servers the operator will start up
19+
# Legal values are "NEVER", "IF_NEEDED", or "ADMIN_ONLY"
20+
serverStartPolicy: IF_NEEDED
21+
22+
# Cluster name
23+
clusterName: cluster-1
24+
25+
# Number of managed servers to generate for the domain
26+
configuredManagedServerCount: 5
27+
28+
# Number of managed servers to initially start for the domain
29+
initialManagedServerReplicas: 2
30+
31+
# Base string used to generate managed server names
32+
managedServerNameBase: managed-server
33+
34+
# Port number for each managed server
35+
managedServerPort: 8001
36+
37+
# Boolean indicating if production mode is enabled for the domain
38+
productionModeEnabled: true
39+
40+
# OracleFMWInfrastructure Server Docker image that the operator uses to start the domain.
41+
#
42+
# The create domain scripts generate a OracleFMWInfrastructure Server Docker image with a domain home in it.
43+
# By default, the scripts tag the generated OracleFMWInfrastructure server Docker image as either
44+
# `domain-home-in-image` or `domain-home-in-image-wdt` based on the `domainHomeImageBuildPath`
45+
# property, and use it to set the `image` element in the generated domain YAML file.
46+
#
47+
# If this property is set, the create domain scripts will use the value specified, instead of the
48+
# default value, to tag the generated image and set the `image` in the domain YAML file.
49+
#
50+
# A unique value is required for each domain that is created using the scripts.
51+
#
52+
# If you are running the sample scripts from a machine that is remote to the Kubernetes cluster where
53+
# the domain is going to be running, you need to set this property to the image name that is intended
54+
# to be used in a registry local to that Kubernetes cluster. You also need to push the `image` to
55+
# that registry before starting the domain using the `kubectl create -f` or `kubectl apply -f` command.
56+
# See README.md for more help.
57+
#image:
58+
59+
# Image pull policy
60+
# Legal values are "IfNotPresent", "Always", or "Never"
61+
imagePullPolicy: IfNotPresent
62+
63+
# Name of the Kubernetes secret to access the Docker Store to pull the OracleFMWInfrastructure Server Docker image
64+
# The presence of the secret will be validated when this parameter is enabled.
65+
#imagePullSecretName:
66+
67+
# Name of the Kubernetes secret for the Admin Server's username and password
68+
# The name must be lowercase.
69+
# If not specified, the value is derived from the domainUID as <domainUID>-weblogic-credentials
70+
weblogicCredentialsSecretName: domain1-weblogic-credentials
71+
72+
# Whether to include server .out to the pod's stdout.
73+
# The default is true.
74+
includeServerOutInPodLog: true
75+
76+
# Specifies whether the log home is stored on the persistent volume.
77+
# If set to true, then you must specify the 'logHome', 'persistentVolumeClaimName'
78+
# and 'domainPVMountPath' properties.
79+
# The default is false.
80+
logHomeOnPV: false
81+
82+
# The in-pod location for domain log, server logs, server out, and node manager log files
83+
# If not specified, the value is derived from the domainUID as /shared/logs/<domainUID>
84+
# This parameter is required if 'logHomeOnPV' is true.
85+
# Otherwise, it is ignored.
86+
logHome: /shared/logs/domain1
87+
88+
# Port for the T3Channel of the NetworkAccessPoint
89+
t3ChannelPort: 30012
90+
91+
# Public address for T3Channel of the NetworkAccessPoint. This value should be set to the
92+
# kubernetes server address, which you can get by running "kubectl cluster-info". If this
93+
# value is not set to that address, WLST will not be able to connect from outside the
94+
# kubernetes cluster.
95+
#t3PublicAddress:
96+
97+
# Boolean to indicate if the channel should be exposed as a service
98+
exposeAdminT3Channel: false
99+
100+
# NodePort to expose for the admin server
101+
adminNodePort: 30701
102+
103+
# Boolean to indicate if the adminNodePort will be exposed
104+
exposeAdminNodePort: false
105+
106+
# Name of the domain namespace
107+
namespace: default
108+
109+
# Java Option for OracleFMWInfrastructure Server
110+
javaOptions: -Dweblogic.StdoutDebugEnabled=false
111+
112+
# Name of the persistent volume claim
113+
# If not specified, the value is derived from the domainUID as <domainUID>-weblogic-sample-pvc
114+
# This parameter is required if 'logHomeOnPV' is true.
115+
# Otherwise, it is ignored.
116+
persistentVolumeClaimName: domain1-weblogic-sample-pvc
117+
118+
# Mount path of the domain persistent volume.
119+
# This parameter is required if 'logHomeOnPV' is true.
120+
# Otherwise, it is ignored.
121+
domainPVMountPath: /shared
122+
123+
# Base OracleFMWInfrastructure binary image used to build the OracleFMWInfrastructure domain image
124+
# The operator requires OracleFMWInfrastructure Server 12.2.1.3.0 with patch 29135930 applied.
125+
# The OracleFMWInfrastructure Docker image, `fmw-infrastructure:12.2.1.3`, has all the necessary patches applied.
126+
# Refer to [OracleFMWInfrastructure Docker images](../../../../../site/weblogic-docker-images.md) for details on how
127+
# to obtain or create the image.
128+
# See README.md for more help.
129+
domainHomeImageBase: container-registry.oracle.com/middleware/fmw-infrastructure:12.2.1.3
130+
131+
# Location of the OracleFMWInfrastructure "domain home in image" Docker image sample in the
132+
# `https://github.com/oracle/docker-images.git` project.
133+
# If not specified, use "./docker-images/OracleFMWInfrastructure/samples/12213-domain-home-in-image".
134+
# Another possible value is "./docker-images/OracleFMWInfrastructure/samples/12213-domain-home-in-image-wdt",
135+
# which uses WDT, instead of WLST, to generate the domain configuration.
136+
domainHomeImageBuildPath: ./docker-images/OracleFMWInfrastructure/samples/12213-domain-home-in-image
137+
138+
#
139+
# RCU configuration details
140+
#
141+
142+
# The schema prefix to use in the database, for example `SOA1`. You may wish to make this
143+
# the same as the domainUID in order to simplify matching domains to their RCU schemas.
144+
rcuSchemaPrefix: domain1
145+
146+
# The database URL
147+
rcuDatabaseURL: database:1521/service
148+
149+
# The kubernetes secret containing the database credentials
150+
rcuCredentialsSecret: domain1-rcu-credentials
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4+
#
5+
# Description
6+
# This sample script creates a WebLogic domain home in docker image, and generates the domain resource
7+
# yaml file, which can be used to restart the Kubernetes artifacts of the corresponding domain.
8+
#
9+
# The domain creation inputs can be customized by editing create-domain-inputs.yaml
10+
#
11+
# The following pre-requisites must be handled prior to running this script:
12+
# * The WDT sample requires that JAVA_HOME is set to a java JDK version 1.8 or greater
13+
# * The kubernetes namespace must already be created
14+
# * The kubernetes secrets 'username' and 'password' of the admin account have been created in the namespace
15+
# * The host directory that will be used as the persistent volume must already exist
16+
# and have the appropriate file permissions set.
17+
# * If logHomeOnPV is enabled, the kubernetes persisitent volume must already be created
18+
# * If logHomeOnPV is enabled, the kubernetes persisitent volume claim must already be created
19+
#
20+
21+
# Initialize
22+
script="${BASH_SOURCE[0]}"
23+
scriptDir="$( cd "$( dirname "${script}" )" && pwd )"
24+
source ${scriptDir}/../../common/utility.sh
25+
source ${scriptDir}/../../common/validate.sh
26+
27+
function usage {
28+
echo usage: ${script} -o dir -i file -u username -p password [-k] [-e] [-v] [-h]
29+
echo " -i Parameter inputs file, must be specified."
30+
echo " -o Output directory for the generated properties and YAML files, must be specified."
31+
echo " -u Username used in building the Docker image for WebLogic domain in image."
32+
echo " -p Password used in building the Docker image for WebLogic domain in image."
33+
echo " -e Also create the resources in the generated YAML files, optional."
34+
echo " -v Validate the existence of persistentVolumeClaim, optional."
35+
echo " -k Keep what has been previously from cloned https://github.com/oracle/docker-images.git, optional. "
36+
echo " If not specified, this script will always remove existing project directory and clone again."
37+
echo " -h Help"
38+
exit $1
39+
}
40+
41+
#
42+
# Parse the command line options
43+
#
44+
doValidation=false
45+
executeIt=false
46+
cloneIt=true
47+
while getopts "evhki:o:u:p:" opt; do
48+
case $opt in
49+
i) valuesInputFile="${OPTARG}"
50+
;;
51+
o) outputDir="${OPTARG}"
52+
;;
53+
v) doValidation=true
54+
;;
55+
e) executeIt=true
56+
;;
57+
u) username="${OPTARG}"
58+
;;
59+
p) password="${OPTARG}"
60+
;;
61+
k) cloneIt=false;
62+
;;
63+
h) usage 0
64+
;;
65+
*) usage 1
66+
;;
67+
esac
68+
done
69+
70+
if [ -z ${valuesInputFile} ]; then
71+
echo "${script}: -i must be specified."
72+
missingRequiredOption="true"
73+
fi
74+
75+
if [ -z ${username} ]; then
76+
echo "${script}: -u must be specified."
77+
missingRequiredOption="true"
78+
fi
79+
80+
if [ -z ${password} ]; then
81+
echo "${script}: -p must be specified."
82+
missingRequiredOption="true"
83+
fi
84+
85+
if [ -z ${outputDir} ]; then
86+
echo "${script}: -o must be specified."
87+
missingRequiredOption="true"
88+
fi
89+
90+
if [ "${missingRequiredOption}" == "true" ]; then
91+
usage 1
92+
fi
93+
94+
#
95+
# Function to initialize and validate the output directory
96+
# for the generated properties and yaml files for this domain.
97+
#
98+
function initOutputDir {
99+
domainOutputDir="${outputDir}/weblogic-domains/${domainUID}"
100+
# Create a directory for this domain's output files
101+
mkdir -p ${domainOutputDir}
102+
103+
removeFileIfExists ${domainOutputDir}/${valuesInputFile}
104+
removeFileIfExists ${domainOutputDir}/create-domain-inputs.yaml
105+
removeFileIfExists ${domainOutputDir}/domain.properties
106+
removeFileIfExists ${domainOutputDir}/domain.yaml
107+
}
108+
109+
# try to execute docker to see whether docker is available
110+
function validateDockerAvailable {
111+
if ! [ -x "$(command -v docker)" ]; then
112+
validationError "docker is not installed"
113+
fi
114+
}
115+
116+
#
117+
# Function to setup the environment to create domain
118+
#
119+
function initialize {
120+
121+
# Validate the required files exist
122+
validateErrors=false
123+
124+
validateDockerAvailable
125+
validateKubectlAvailable
126+
127+
if [ -z "${valuesInputFile}" ]; then
128+
validationError "You must use the -i option to specify the name of the inputs parameter file (a modified copy of kubernetes/samples/scripts/create-fmw-infrastructure-domain/domain-home-in-image/create-domain-inputs.yaml)."
129+
else
130+
if [ ! -f ${valuesInputFile} ]; then
131+
validationError "Unable to locate the input parameters file ${valuesInputFile}"
132+
fi
133+
fi
134+
135+
if [ -z "${outputDir}" ]; then
136+
validationError "You must use the -o option to specify the name of an existing directory to store the generated properties and yaml files in."
137+
fi
138+
139+
domainPropertiesInput="${scriptDir}/properties-template.properties"
140+
if [ ! -f ${domainPropertiesInput} ]; then
141+
validationError "The template file ${domainPropertiesInput} for creating a WebLogic domain was not found"
142+
fi
143+
144+
dcrInput="${scriptDir}/../../common/domain-template.yaml"
145+
if [ ! -f ${dcrInput} ]; then
146+
validationError "The template file ${dcrInput} for creating the domain resource was not found"
147+
fi
148+
149+
failIfValidationErrors
150+
151+
validateCommonInputs
152+
153+
validateBooleanInputParamsSpecified logHomeOnPV
154+
failIfValidationErrors
155+
156+
initOutputDir
157+
158+
if [ "${cloneIt}" = true ] || [ ! -d ${domainHomeImageBuildPath} ]; then
159+
getDockerSample
160+
fi
161+
}
162+
163+
#
164+
# Function to get the dependency docker sample
165+
#
166+
function getDockerSample {
167+
dockerImagesDir=${domainHomeImageBuildPath%/OracleFMWInfrastructure*}
168+
rm -rf ${dockerImagesDir}
169+
git clone https://github.com/oracle/docker-images.git ${dockerImagesDir}
170+
}
171+
172+
#
173+
# Function to build docker image and create WebLogic domain home
174+
#
175+
function createDomainHome {
176+
dockerDir=${domainHomeImageBuildPath}
177+
dockerPropsDir=${dockerDir}/properties
178+
cp ${domainPropertiesOutput} ${dockerPropsDir}
179+
180+
# 12213-domain-home-in-image use one properties file for the credentials
181+
usernameFile="${dockerPropsDir}/domain_security.properties"
182+
passwordFile="${dockerPropsDir}/domain_security.properties"
183+
184+
rcuPropFile="${dockerPropsDir}/rcu.properties"
185+
rcuSecurityPropFile="${dockerPropsDir}/rcu_security.properties"
186+
187+
# 12213-domain-home-in-image-wdt uses two properties files for the credentials
188+
if [ ! -f $usernameFile ]; then
189+
usernameFile="${dockerPropsDir}/adminuser.properties"
190+
passwordFile="${dockerPropsDir}/adminpass.properties"
191+
fi
192+
193+
sed -i -e "s|myusername|${username}|g" $usernameFile
194+
sed -i -e "s|welcome1|${password}|g" $passwordFile
195+
196+
sed -i -e "s|INFRA08|${rcuSchemaPrefix}|g" $rcuPropFile
197+
sed -i -e "s|InfraDB:1521/InfraPDB1.us.oracle.com|${rcuDatabaseURL}|g" $rcuPropFile
198+
199+
if [ ! -z $domainHomeImageBase ]; then
200+
sed -i -e "s|\(FROM \).*|\1 ${domainHomeImageBase}|g" ${dockerDir}/Dockerfile
201+
fi
202+
203+
cp ${domainPropertiesOutput} ${dockerPropsDir}
204+
sed -i '$ a extract_env IMAGE_TAG ${PROPERTIES_FILE} ' ${dockerDir}/container-scripts/setEnv.sh
205+
206+
#exit -1000
207+
sh ${dockerDir}/build.sh
208+
209+
if [ "$?" != "0" ]; then
210+
fail "Create domain ${domainName} failed."
211+
fi
212+
213+
# clean up the generated domain.properties file
214+
rm ${domainPropertiesOutput}
215+
216+
echo ""
217+
echo "Create domain ${domainName} successfully."
218+
}
219+
220+
#
221+
# Function to output to the console a summary of the work completed
222+
#
223+
function printSummary {
224+
225+
# Get the IP address of the kubernetes cluster (into K8S_IP)
226+
getKubernetesClusterIP
227+
228+
echo ""
229+
echo "Domain ${domainName} was created and will be started by the WebLogic Kubernetes Operator"
230+
echo ""
231+
if [ "${exposeAdminNodePort}" = true ]; then
232+
echo "Administration console access is available at http://${K8S_IP}:${adminNodePort}/console"
233+
fi
234+
if [ "${exposeAdminT3Channel}" = true ]; then
235+
echo "T3 access is available at t3://${K8S_IP}:${t3ChannelPort}"
236+
fi
237+
echo "The following files were generated:"
238+
echo " ${domainOutputDir}/create-domain-inputs.yaml"
239+
echo " ${dcrOutput}"
240+
echo ""
241+
echo "Completed"
242+
}
243+
244+
# Perform the sequence of steps to create a domain
245+
createDomain true
246+

0 commit comments

Comments
 (0)