7.1.4 Kubernetes永続ボリュームおよび永続ボリューム要求の作成
「永続ボリューム・ディレクトリの作成」で説明したように、Kubernetesクラスタのノードは、ネットワーク・ファイル・システム(NFS)マウントや共有ファイル・システムなどの永続ボリュームにアクセスできる必要があります。
永続ボリュームは、ディスク・マウントと同じですが、コンテナ内に存在します。Kubernetes永続ボリュームは、ディスク上の物理ボリュームにマップされる任意の名前です(この例ではOracleによって決定されます)。
コンテナは起動時に、そのボリュームをマウントする必要があります。コンテナが起動されるワーカー・ノードはわからないため、物理ボリュームはすべてのKubernetesワーカー・ノードからアクセス可能な共有ディスク上に存在する必要があります。Oracle Access Managementの場合、コンテナが停止しても永続ボリュームは消去されません。これにより、永続的な構成が可能になります。
次の例では、NFSマウント・ボリューム(<persistent_volume>/accessdomainpv
)を使用しています。その他のボリューム・タイプも使用できます。詳細は、ボリュームに関する項を参照してください。
Kubernetes永続ボリュームを作成するには、次のステップを実行します:
$WORKDIR/kubernetes/create-weblogic-domain-pv-pvc
ディレクトリに移動します:cd $WORKDIR/kubernetes/create-weblogic-domain-pv-pvc
create-pv-pvc-inputs.yaml
ファイルのバックアップ・コピーを作成し、output
ディレクトリを作成します:cp create-pv-pvc-inputs.yaml create-pv-pvc-inputs.yaml.orig
mkdir output
create-pv-pvc-inputs.yaml
ファイルを編集し、設定を反映するように次のパラメータを更新します。完了後、ファイルを保存します:
例:baseName: <domain> domainUID: <domain_uid> namespace: <domain_namespace> weblogicDomainStorageType: NFS weblogicDomainStorageNFSServer: <nfs_server> weblogicDomainStoragePath: <physical_path_of_persistent_storage> weblogicDomainStorageSize: 10Gi
# The base name of the pv and pvc baseName: domain # Unique ID identifying a domain. # If left empty, the generated pv can be shared by multiple domains # This ID must not contain an underscope ("_"), and must be lowercase and unique across all domains in a Kubernetes cluster. domainUID: accessdomain # Name of the namespace for the persistent volume claim namespace: oamns ... # Persistent volume type for the persistent storage. # The value must be 'HOST_PATH' or 'NFS'. # If using 'NFS', weblogicDomainStorageNFSServer must be specified. weblogicDomainStorageType: NFS # The server name or ip address of the NFS server to use for the persistent storage. # The following line must be uncomment and customized if weblogicDomainStorateType is NFS: weblogicDomainStorageNFSServer: mynfsserver # Physical path of the persistent storage. # 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. # The following line must be uncomment and customized: weblogicDomainStoragePath: /nfs_volumes/oam/accessdomainpv # Reclaim policy of the persistent storage # The valid values are: 'Retain', 'Delete', and 'Recycle' weblogicDomainStorageReclaimPolicy: Retain # Total storage allocated to the persistent storage. weblogicDomainStorageSize: 10Gi
create-pv-pvc.sh
スクリプトを実行して、PVおよびPVC構成ファイルを作成します:
出力は、次のようになります。./create-pv-pvc.sh -i create-pv-pvc-inputs.yaml -o output
Input parameters being used export version="create-weblogic-sample-domain-pv-pvc-inputs-v1" export baseName="domain" export domainUID="accessdomain" export namespace="oamns" export weblogicDomainStorageType="NFS" export weblogicDomainStorageNFSServer="mynfsserver" export weblogicDomainStoragePath="/nfs_volumes/oam/accessdomainpv" export weblogicDomainStorageReclaimPolicy="Retain" export weblogicDomainStorageSize="10Gi" Generating output/pv-pvcs/accessdomain-domain-pv.yaml Generating output/pv-pvcs/accessdomain-domain-pvc.yaml The following files were generated: output/pv-pvcs/accessdomain-domain-pv.yaml.yaml output/pv-pvcs/accessdomain-domain-pvc.yaml
- 次のコマンドを実行して、ファイルが作成されたことを示します:
出力は次のようになります:ls output/pv-pvcs
accessdomain-domain-pv.yaml accessdomain-domain-pvc.yaml create-pv-pvc-inputs.yaml
- 次のコマンドを実行して、ドメイン・ネームスペースにPVを作成します:
例:kubectl create -f output/pv-pvcs/accessdomain-domain-pv.yaml -n <domain_namespace>
出力は次のようになります:kubectl create -f output/pv-pvcs/accessdomain-domain-pv.yaml -n oamns
persistentvolume/accessdomain-domain-pv created
- 次のコマンドを実行して、PVが正常に作成されたことを確認します:
出力は次のようになります:kubectl describe pv accessdomain-domain-pv
Name: accessdomain-domain-pv Labels: weblogic.domainUID=accessdomain Annotations: pv.kubernetes.io/bound-by-controller: yes Finalizers: [kubernetes.io/pv-protection] StorageClass: accessdomain-domain-storage-class Status: Bound Claim: oamns/accessdomain-domain-pvc Reclaim Policy: Retain Access Modes: RWX VolumeMode: Filesystem Capacity: 10Gi Node Affinity: <none> Message: Source: Type: NFS (an NFS mount that lasts the lifetime of a pod) Server: mynfsserver Path: /nfs_volumes/oam/accessdomainpv ReadOnly: false Events: <none>
- 次のコマンドを実行して、ドメイン・ネームスペースにPVCを作成します:
例:kubectl create -f output/pv-pvcs/accessdomain-domain-pvc.yaml -n <domain_namespace>
出力は次のようになります:kubectl create -f output/pv-pvcs/accessdomain-domain-pvc.yaml -n oamns
persistentvolume/accessdomain-domain-pvc created
- 次のコマンドを実行して、PVCが正常に作成されたことを確認します:
例:kubectl describe pvc accessdomain-domain-pvc -n <namespace>
出力は次のようになります:kubectl describe pvc accessdomain-domain-pvc -n oamns
Name: accessdomain-domain-pvc Namespace: oamns StorageClass: accessdomain-domain-storage-class Status: Bound Volume: accessdomain-domain-pv Labels: weblogic.domainUID=accessdomain Annotations: pv.kubernetes.io/bind-completed: yes pv.kubernetes.io/bound-by-controller: yes Finalizers: [kubernetes.io/pvc-protection] Capacity: 10Gi Access Modes: RWX VolumeMode: Filesystem Events: <none> Mounted By: <none>