Storage
Sample PersistentVolume and PersistentVolumeClaim
The sample scripts demonstrate the creation of a Kubernetes PersistentVolume (PV) and PersistentVolumeClaim (PVC), which can then be used in a Domain YAML file as a persistent storage for the WebLogic domain home or log files.
A PV and PVC can be shared by multiple WebLogic domains or dedicated to a particular domain.
Prerequisites
Before you begin, read this document, Persistent storage .
Using the scripts to create a PV and PVC
Prior to running the create-pv-pvc.sh script, make a copy of the create-pv-pvc-inputs.yaml file, and uncomment and explicitly configure the weblogicDomainStoragePath property in the inputs file.
Run the create script, pointing it at your inputs file and an output directory:
The create-pv-pvc.sh script will create a subdirectory pv-pvcs under the given /path/to/output-directory directory. By default, the script generates two YAML files, namely weblogic-sample-pv.yaml and weblogic-sample-pvc.yaml, in the /path/to/output-directory/pv-pvcs. These two YAML files can be used to create the Kubernetes resources using the kubectl create -f command.
As a convenience, the script can optionally create the PV and PVC resources using the -e option.
The usage of the create script is as follows:
If you copy the sample scripts to a different location, make sure that you copy everything in the <weblogic-kubernetes-operator-project>/kubernetes/samples/scripts directory together into the target directory, maintaining the original directory hierarchy.
Configuration parameters
The PV and PVC creation inputs can be customized by editing the create-pv-pvc-inputs.yaml file.
| Parameter | Definition | Default |
|---|---|---|
domainUID |
ID of the Domain to which the generated PV and PVC will be dedicated. Leave it empty if the PV and PVC are going to be shared by multiple domains. | no default |
namespace |
Kubernetes Namespace to create the PVC. | default |
baseName |
Base name of the PV and PVC. The generated PV and PVC will be <baseName>-pv and <baseName>-pvc respectively. |
weblogic-sample |
weblogicDomainStoragePath |
Physical path of the storage for the PV. When weblogicDomainStorageType is set to HOST_PATH, this value should be set the to path to the domain storage on the Kubernetes host. When weblogicDomainStorageType is set to NFS, then weblogicDomainStorageNFSServer should be set to the IP address or name of the DNS server, and this value should be set to the exported path on that server. Note that the path where the domain is mounted in the WebLogic containers is not affected by this setting; that is determined when you create your domain. |
no default |
weblogicDomainStorageReclaimPolicy |
Kubernetes PVC policy for the persistent storage. The valid values are: Retain, Delete, and Recycle. |
Retain |
weblogicDomainStorageSize |
Total storage allocated for the PVC. | 10Gi |
weblogicDomainStorageType |
Type of storage. Legal values are NFS and HOST_PATH. If using NFS, weblogicDomainStorageNFSServer must be specified. |
HOST_PATH |
weblogicDomainStorageNFSServer |
Name or IP address of the NFS server. This setting only applies if weblogicDomainStorateType is NFS. |
no default |
Shared versus dedicated PVC
By default, the domainUID is left empty in the inputs file, which means the generated PV and PVC will not be associated with a particular domain, but can be shared by multiple Domains in the same Kubernetes Namespaces as the PV and PVC. If the PV/PVC is being shared across domains, then, as a best practice, you should specify a unique baseName.
For the use cases where dedicated PV and PVC are desired for a particular domain, the domainUID needs to be set in the create-pv-pvc-inputs.yaml file. The presence of a non-empty domainUID in the inputs file will cause the generated PV and PVC to be associated with the specified domainUID. The association includes that the names of the generated YAML files and the Kubernetes PV and PVC objects are decorated with the domainUID, and the PV and PVC objects are also labeled with the domainUID.
Verify the results
The create script will verify that the PV and PVC were created, and will report a failure if there was any error. However, it may be desirable to manually verify the PV and PVC, even if just to gain familiarity with the various Kubernetes objects that were created by the script.
Generated YAML files with the default inputs
The content of the generated weblogic-sample-pvc.yaml:
The content of the generated weblogic-sample-pv.yaml:
Generated YAML files for dedicated PV and PVC
The content of the generated domain1-weblogic-sample-pvc.yaml when domainUID is set to domain1:
The content of the generated domain1-weblogic-sample-pv.yaml when domainUID is set to domain1:
Verify the PV and PVC objects
You can use this command to verify the PersistentVolume was created. Note that the Status field
should have the value Bound, indicating the that PersistentVolume has been claimed:
You can use this command to verify the PersistentVolumeClaim was created: