|
| 1 | + |
| 2 | +# Persistent Volumes |
| 3 | + |
| 4 | +This guide outlines how to set up a Kubernetes persistent volume (PV) and persistent volume claim (PVC), which can then be used in a domain custom resource 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. |
| 5 | + |
| 6 | +## Prerequisites |
| 7 | + |
| 8 | +The following prerequisites must be fulfilled before proceeding with the creation of the persistent volume. |
| 9 | +* Create a Kubernetes namespace for the persistent volume claim unless the intention is to use the default namespace. Note that a PVC has to be in the same namespace as the domain resource that uses it. |
| 10 | +* Make sure that the host directory that will be used as the persistent volume already exists and has the appropriate file permissions set. |
| 11 | + |
| 12 | +# Persistent volume YAML files |
| 13 | + |
| 14 | +For sample YAML templates, please refer to this example. |
| 15 | +* [Persistent Volumes example](../kubernetes/samples/scripts/create-weblogic-domain-pv-pvc/README.md) |
| 16 | + |
| 17 | +## Naming conventions |
| 18 | + |
| 19 | +Persistent volumes and claims and their properties are described in YAML files. For each PV, you should create one PV YAML file and one PVC YAML file. In the example above, you will find 2 YAML templates, one for the PV and one for the PVC. The example suggest that you name the PV and PVC [domainUID]-[baseName]-pv and [domainUID]-[baseName]-pvc respectively, where domainUID is the ID of the domain resource to which the generated PV and PVC will be dedicated, and baseName is the base name of the PV and PVC. |
| 20 | + |
| 21 | +## Storage locations |
| 22 | +PVs can point to different storage locations, for example NFS server storage or local path. Please read the [Kubernetes documentation](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) regarding on how to configure this. |
| 23 | + |
| 24 | +# Kubernetes resources |
| 25 | + |
| 26 | +After you have written your YAML files, please use them to create the PV by creating Kubernetes resources using the `kubectl create -f` command. |
| 27 | + |
| 28 | +``` |
| 29 | + kubectl create -f pv.yaml |
| 30 | + kubectl create -f pvc.yaml |
| 31 | +
|
| 32 | +``` |
| 33 | + |
| 34 | +## Shared versus dedicated PVC |
| 35 | + |
| 36 | +By default, the `domainUID` is left empty in the inputs file so that the generated PV and PVC can be shared by multiple domain resources in the same Kubernetes namespaces. |
| 37 | + |
| 38 | +For the use cases where a dedicated PV and PVC is desired for a particular domain, the `domainUID` can be set, which will cause the generated PV and PVC to be associated with the specified `domainUID`. In the per domain PV and PVC case, 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`. |
| 39 | + |
| 40 | +# Common problems |
| 41 | + |
| 42 | +This section provides details of common problems that might occur while running the script and how to resolve them. |
| 43 | + |
| 44 | +### Persistent volume provider not configured correctly |
| 45 | + |
| 46 | +Possibly the most common problem experienced during testing was the incorrect configuration of the persistent volume provider. The persistent volume must be accessible to all Kubernetes nodes, and must be able to be mounted as Read/Write/Many. If this is not the case, the PV/PVC creation will fail. |
| 47 | + |
| 48 | +The simplest case is where the `HOST_PATH` provider is used. This can be either with one Kubernetes node, or with the `HOST_PATH` residing in shared storage available at the same location on every node (for example, on an NFS mount). In this case, the path used for the persistent volume must have its permission bits set to 777. |
| 49 | + |
| 50 | +# Verify the results |
| 51 | + |
| 52 | +To confirm that the PV and PVC were created, use these commands: |
| 53 | + |
| 54 | +``` |
| 55 | +kubectl describe pv [PV name] |
| 56 | +kubectl describe pvc -n NAMESPACE [PVC name] |
| 57 | +``` |
| 58 | + |
| 59 | +Replace `NAMESPACE` with the namespace that the PVC was created in. |
0 commit comments