Skip to content

Commit aeebf7d

Browse files
authored
Merge pull request #146 from oracle/simon-meng-cn/100-fixes
Add persistent volume configuration to support NFS
2 parents 86b2fb4 + 395b9e6 commit aeebf7d

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

kubernetes/create-domain-job-inputs.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ managedServerNameBase: managed-server
3636
# Port number for each managed server
3737
managedServerPort: 8001
3838

39+
# Persistent volume type, the value must be hostPath or nfs.
40+
# If using nfs, nfsServer must be specified.
41+
persistenceType: hostPath
42+
43+
# NFS server name or ip
44+
nfsServer: nfsServer
45+
3946
# Physical path of the persistent volume storage
4047
persistencePath: /scratch/k8s_dir/persistentVolume001
4148

kubernetes/create-domain-job.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function validatePersistentVolumeClaimName {
8686
#
8787
# Function to validate the persistent volume name
8888
#
89-
function validatePersistenVolumeName {
89+
function validatePersistentVolumeName {
9090
validateLowerCase ${persistenceVolumeName} "persistenceVolumeName"
9191

9292
if [[ ${persistenceVolumeName} != ${domainUid}-* ]] ; then
@@ -96,6 +96,17 @@ function validatePersistenVolumeName {
9696
fi
9797
}
9898

99+
#
100+
# Function to validate the persistence type
101+
#
102+
function validatePersistenceType {
103+
if [ ${persistenceType} == "nfs" ] ; then
104+
validateInputParamsSpecified nfsServer
105+
elif [ ${persistenceType} != "hostPath" ] ; then
106+
validationError "The persistenceType ${persistenceType} is invalid, it must be hostPath or nfs"
107+
fi
108+
}
109+
99110
#
100111
# Function to validate the secret name
101112
#
@@ -262,7 +273,8 @@ function initialize {
262273
validateDomainUid
263274
validateClusterName
264275
validateStorageClass
265-
validatePersistenVolumeName
276+
validatePersistenceType
277+
validatePersistentVolumeName
266278
validatePersistentVolumeClaimName
267279
validateSecretName
268280
validateImagePullSecretName
@@ -283,12 +295,22 @@ function createYamlFiles {
283295
echo Generating ${pvOutput}
284296

285297
cp ${pvInput} ${pvOutput}
298+
if [ "${persistenceType}" == "nfs" ]; then
299+
hostPathPrefix="${disabledPrefix}"
300+
nfsPrefix="${enabledPrefix}"
301+
sed -i -e "s:%NFS_SERVER%:${nfsServer}:g" ${pvOutput}
302+
else
303+
hostPathPrefix="${enabledPrefix}"
304+
nfsPrefix="${disabledPrefix}"
305+
fi
286306
sed -i -e "s:%DOMAIN_UID%:${domainUid}:g" ${pvOutput}
287307
sed -i -e "s:%NAMESPACE%:$namespace:g" ${pvOutput}
288308
sed -i -e "s:%PERSISTENT_VOLUME%:${persistenceVolumeName}:g" ${pvOutput}
289309
sed -i -e "s:%PERSISTENT_VOLUME_PATH%:${persistencePath}:g" ${pvOutput}
290310
sed -i -e "s:%PERSISTENT_VOLUME_SIZE%:${persistenceSize}:g" ${pvOutput}
291311
sed -i -e "s:%STORAGE_CLASS_NAME%:${persistenceStorageClass}:g" ${pvOutput}
312+
sed -i -e "s:%HOST_PATH_PREFIX%:${hostPathPrefix}:g" ${pvOutput}
313+
sed -i -e "s:%NFS_PREFIX%:${nfsPrefix}:g" ${pvOutput}
292314

293315
# Generate the yaml to create the persistent volume claim
294316
echo Generating ${pvcOutput}

kubernetes/internal/persistent-volume-template.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ spec:
1414
accessModes:
1515
- ReadWriteMany
1616
persistentVolumeReclaimPolicy: Retain
17-
hostPath:
17+
%HOST_PATH_PREFIX%hostPath:
18+
%NFS_PREFIX%nfs:
19+
%NFS_PREFIX%server: %NFS_SERVER%
1820
path: "%PERSISTENT_VOLUME_PATH%"

0 commit comments

Comments
 (0)