Skip to content

Commit b2b8a5b

Browse files
authored
Merge pull request #47 from oracle/issue-42
provide option in create domain script to remove any pre-existing data in PV
2 parents 805c6be + a3b69a5 commit b2b8a5b

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

kubernetes/create-domain-job-inputs.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ persistenceVolumeClaimName: pv001-claim
5252
# if it is not already
5353
persistenceVolumeName: pv001
5454

55+
# Boolean indiciating whether to erase/overwrite an existing data found in the persistent volume
56+
# WARNING: if you set this to true, then ALL data found in the persistent volume will be deleted!
57+
replaceExistingDomain: false
58+
5559
# Boolean indicating if production mode is enabled for the domain
5660
productionModeEnabled: true
5761

kubernetes/create-domain-job.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ function initialize {
273273
validateInputParamsSpecified adminPort adminServerName createDomainScript domainName domainUid clusterName managedServerCount managedServerStartCount managedServerNameBase
274274
validateInputParamsSpecified managedServerPort persistencePath persistenceSize persistenceVolumeClaimName persistenceVolumeName
275275
validateInputParamsSpecified productionModeEnabled secretsMountPath secretName t3ChannelPort exposeAdminT3Channel adminNodePort exposeAdminNodePort
276-
validateInputParamsSpecified namespace loadBalancer loadBalancerWebPort loadBalancerAdminPort loadBalancer
276+
validateInputParamsSpecified namespace loadBalancer loadBalancerWebPort loadBalancerAdminPort loadBalancer replaceExistingDomain
277277
validateStorageClass
278278
validateLoadBalancer
279279
validateImagePullSecretName
@@ -349,6 +349,7 @@ function createYamlFiles {
349349
sed -i -e "s:%T3_CHANNEL_PORT%:${t3ChannelPort}:g" ${jobOutput}
350350
sed -i -e "s:%T3_PUBLIC_ADDRESS%:${t3PublicAddress}:g" ${jobOutput}
351351
sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${jobOutput}
352+
sed -i -e "s:%REPLACE_EXISTING_DOMAIN%:${replaceExistingDomain}:g" ${jobOutput}
352353

353354
# Generate the yaml to create the domain custom resource
354355
echo Generating ${dcrOutput}

kubernetes/internal/domain-job-template.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,16 @@ data:
6060
fail "The domain secret %SECRETS_MOUNT_PATH%/password was not found"
6161
fi
6262
63-
# Do not proceed if the domain already exists
63+
# Check if the domain already exists
6464
domainFolder=${SHARED_PATH}/domain/%DOMAIN_NAME%
6565
if [ -d ${domainFolder} ]; then
66-
fail "The create domain job will not overwrite an existing domain. The domain folder ${domainFolder} already exists"
66+
# check if user asked to replace existing data
67+
if [ "%REPLACE_EXISTING_DOMAIN%" = "true" ]; then
68+
echo "As requested, deleting all data in the peristent volume to make way for new domain!"
69+
rm -rf ${SHARED_PATH}/*
70+
else
71+
fail "The create domain job will not overwrite an existing domain unless you set the parameter 'replaceExistingDomain' to 'true'. The domain folder ${domainFolder} already exists"
72+
fi
6773
fi
6874
6975
# Create the base folders
@@ -177,8 +183,8 @@ data:
177183
sleep 15
178184
echo "Finished waiting for the nodemanager to start"
179185
180-
echo "Update JVM arguments"
181-
echo "Arguments=\${USER_MEM_ARGS} -XX\:+UnlockExperimentalVMOptions -XX\:+UseCGroupMemoryLimitForHeap \${JAVA_OPTIONS}" >> ${startProp}
186+
echo "Update JVM arguments"
187+
echo "Arguments=\${USER_MEM_ARGS} -XX\:+UnlockExperimentalVMOptions -XX\:+UseCGroupMemoryLimitForHeap \${JAVA_OPTIONS}" >> ${startProp}
182188
183189
echo "Start the server"
184190
wlst.sh -skipWLSModuleScanning ${pyFile}
@@ -207,7 +213,7 @@ data:
207213
checkFileExists ${pyFile}
208214
209215
# Create a liveness probe script. It checks a WL server state file maintained by the node manager.
210-
# The script and 'EOF' on the following lines must not be indented!
216+
# The script and 'EOF' on the following lines must not be indented!
211217
212218
scriptFile=${nmdir}/livenessProbe.sh
213219
@@ -317,7 +323,7 @@ data:
317323
done
318324
319325
echo "Successfully Completed"
320-
326+
321327
create-domain.py: |-
322328
# This python script is used to create a WebLogic domain
323329

site/creating-domain.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ The following parameters must be provided in the input file:
106106
| persistenceStorageClass | Name of the storage class to set for the persistent volume and persistent volume claim. | weblogic |
107107
| persistenceVolumeClaimName | Name of the Kubernetes persistent volume claim for this domain. | pv001-claim |
108108
| persistenceVolumeName | Name of the Kubernetes persistent volume for this domain. | pv001 |
109+
| replaceExistingDomain | If set to 'true' the script will remove any data it finds in the persistent volume before creating the new domain. Use with caution. | false |
109110
| productionModeEnabled | Boolean indicating if production mode is enabled for the domain. | true |
110111
| secretsMountPath | Path for mounting secrets. This parameter should not be modified. | /var/run/secrets-domain1 |
111112
| secretName | Name of the Kubernetes secret for the Administration Server's username and password. | domain1-weblogic-credentials |

0 commit comments

Comments
 (0)