|
| 1 | +#### Create storage and set up file share |
| 2 | + |
| 3 | +Our usage pattern for the operator involves creating Kubernetes "persistent volumes" to allow the WebLogic Server to persist its configuration and data separately from the Kubernetes Pods that run WebLogic Server workloads. |
| 4 | + |
| 5 | +We will create an external data volume to access and persist data. There are several options for data sharing as described in [Storage options for applications in Azure Kubernetes Service (AKS)](https://docs.microsoft.com/azure/aks/concepts-storage). |
| 6 | + |
| 7 | +We will use Azure Files as a Kubernetes volume. Consult the [Azure Files Documentation](https://docs.microsoft.com/azure/aks/azure-files-volume) for details about this full featured cloud storage solution. |
| 8 | + |
| 9 | +##### Create an Azure Storage account |
| 10 | + |
| 11 | +Create a storage account using Azure CLI. Note that the storage account name can contain only lowercase letters and numbers, and must be between 3 and 24 characters in length: |
| 12 | + |
| 13 | +```bash |
| 14 | +# Change the value as needed for your own environment |
| 15 | +$ export AKS_PERS_STORAGE_ACCOUNT_NAME="${NAME_PREFIX}storage${TIMESTAMP}" |
| 16 | + |
| 17 | +$ az storage account create \ |
| 18 | + -n $AKS_PERS_STORAGE_ACCOUNT_NAME \ |
| 19 | + -g $AKS_PERS_RESOURCE_GROUP \ |
| 20 | + -l $AKS_PERS_LOCATION \ |
| 21 | + --sku Standard_LRS |
| 22 | +``` |
| 23 | + |
| 24 | +Successful output will be a JSON object with the entry `"type": "Microsoft.Storage/storageAccounts"`. |
| 25 | + |
| 26 | +Now we need to create a file share. To create the file share, you need a storage connection string. Run the `show-connection-string` command to get connection string, then create the share with `az storage share create`, as shown here. |
| 27 | + |
| 28 | +```bash |
| 29 | +# Change value as needed for your own environment |
| 30 | +$ export AKS_PERS_SHARE_NAME="${NAME_PREFIX}-weblogic-${TIMESTAMP}" |
| 31 | +# Get connection string |
| 32 | +$ export AZURE_STORAGE_CONNECTION_STRING=$(az storage account show-connection-string -n $AKS_PERS_STORAGE_ACCOUNT_NAME -g $AKS_PERS_RESOURCE_GROUP -o tsv) |
| 33 | +# Create file share |
| 34 | +$ az storage share create -n $AKS_PERS_SHARE_NAME --connection-string $AZURE_STORAGE_CONNECTION_STRING |
| 35 | +``` |
| 36 | + |
| 37 | +Successful output will be exactly the following: |
| 38 | + |
| 39 | +```bash |
| 40 | +{ |
| 41 | + "created": true |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +The operator uses Kubernetes Secrets. We need a storage key for the secret. These commands query the storage account to obtain the key, and then stores the storage account key as a Kubernetes secret. |
| 46 | + |
| 47 | +```bash |
| 48 | +$ export STORAGE_KEY=$(az storage account keys list --resource-group $AKS_PERS_RESOURCE_GROUP --account-name $AKS_PERS_STORAGE_ACCOUNT_NAME --query "[0].value" -o tsv) |
| 49 | +``` |
| 50 | + |
| 51 | +Verify the successful output by examining the `STORAGE_KEY` environment variable. It must not be empty. It must be a long ASCII string. |
| 52 | + |
| 53 | +We will use the `kubernetes/samples/scripts/create-kuberetes-secrets/create-azure-storage-credentials-secret.sh` script to create the storage account key as a Kubernetes secret, naming the secret with value `${NAME_PREFIX}azure-secret`. Please run: |
| 54 | + |
| 55 | +```bash |
| 56 | +# Please change persistentVolumeClaimNameSuffix if you changed pre-defined value "regcred" before generating the configuration files. |
| 57 | +$ export SECRET_NAME_AZURE_FILE="${NAME_PREFIX}azure-secret" |
| 58 | + |
| 59 | +#cd kubernetes/samples/scripts/create-kuberetes-secrets |
| 60 | +$ ./create-azure-storage-credentials-secret.sh -s $SECRET_NAME_AZURE_FILE -a $AKS_PERS_STORAGE_ACCOUNT_NAME -k $STORAGE_KEY |
| 61 | +``` |
| 62 | + |
| 63 | +You will see the following output: |
| 64 | + |
| 65 | +```text |
| 66 | +secret/wlsazure-secret created |
| 67 | +The secret wlsazure-secret has been successfully created in the default namespace. |
| 68 | +``` |
| 69 | + |
| 70 | +##### Create PV and PVC |
| 71 | + |
| 72 | +This sample uses Kubernetes Persistent Volume Claims (PVC) as storage resource. These features are passed to Kubernetes using YAML files. The script `kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/create-domain-on-aks.sh` generates the required configuration files automatically, given an input file containing the parameters. A parameters file is provided at `kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/create-domain-on-aks-inputs.yaml`. Copy and customize this file for your needs. |
| 73 | + |
| 74 | +To generate YAML files to create PV and PVC in the AKS cluster, the following values must be substituted in your copy of the input file. |
| 75 | + |
| 76 | +| Name in YAML file | Example value | Notes | |
| 77 | +|-------------------|---------------|-------| |
| 78 | +| `azureServicePrincipalAppId` | `nr086o75-pn59-4782-no5n-nq2op0rsr1q6` | Application ID of your service principal; refer to the application ID in the [Create Service Principal]({{< relref "/samples/simple/azure-kubernetes-service/domain-on-pv#create-a-service-principal-for-aks" >}}) section. | |
| 79 | +| `azureServicePrincipalClientSecret` | `8693089o-q190-45ps-9319-or36252s3s90` | A client secret of your service principal; refer to the client secret in the [Create Service Principal]({{< relref "/samples/simple/azure-kubernetes-service/domain-on-pv#create-a-service-principal-for-aks" >}}) section. | |
| 80 | +| `azureServicePrincipalTenantId` | `72s988os-86s1-cafe-babe-2q7pq011qo47` | Tenant (Directory ) ID of your service principal; refer to the client secret in the [Create Service Principal]({{< relref "/samples/simple/azure-kubernetes-service/domain-on-pv#create-a-service-principal-for-aks" >}}) section. | |
| 81 | +| `dockerEmail` | `yourDockerEmail` | Oracle Single Sign-On (SSO) account email, used to pull the WebLogic Server Docker image. | |
| 82 | +| `dockerPassword` | `yourDockerPassword`| Password for Oracle SSO account, used to pull the WebLogic Server Docker image. In clear text. | |
| 83 | +| `dockerUserName` | `yourDockerId` | The same value as `dockerEmail`. | |
| 84 | +| `namePrefix` | `wls` | Alphanumeric value used as a disambiguation prefix for several Kubernetes resources. Make sure the value matches the value of `${NAME_PREFIX}` to keep names in step-by-step commands the same with those in configuration files. | |
| 85 | + |
| 86 | +Use the following command to generate configuration files, assuming the output directory is `~/azure`. The script will overwrite any files generated by a previous invocation. |
| 87 | + |
| 88 | +```bash |
| 89 | +#cd kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service |
| 90 | +$ cp create-domain-on-aks-inputs.yaml my-create-domain-on-aks-inputs.yaml |
| 91 | +$ ./create-domain-on-aks.sh -i my-create-domain-on-aks-inputs.yaml -o ~/azure -u ${TIMESTAMP} |
| 92 | +``` |
| 93 | + |
| 94 | +After running the command, all needed configuration files are generated and output to `~/azure/weblogic-on-aks`: |
| 95 | + |
| 96 | +```bash |
| 97 | +The following files were generated: |
| 98 | + /home/username/azure/weblogic-on-aks/pv.yaml |
| 99 | + /home/username/azure/weblogic-on-aks/pvc.yaml |
| 100 | + /home/username/azure/weblogic-on-aks/admin-lb.yaml |
| 101 | + /home/username/azure/weblogic-on-aks/cluster-lb.yaml |
| 102 | + /home/username/azure/weblogic-on-aks/domain1.yaml |
| 103 | + /home/username/azure/weblogic-on-aks/cluster-admin-role.yaml |
| 104 | + |
| 105 | +Completed |
| 106 | +``` |
| 107 | + |
| 108 | +**Note:** Beyond the required and default configurations generated by the command, you can modify the generated YAML files to further customize your deployment. Please consult the operator documentation, [AKS documentation](https://docs.microsoft.com/en-us/azure/aks/) and Kubernetes references for further information about customizing your deployment. |
| 109 | + |
| 110 | +##### Apply generated configuration files |
| 111 | + |
| 112 | +In order to mount the file share as a persistent volume, we have provided a configuration file `pv.yaml`. You can find it in your output directory. The following content is an example that uses the value `wls-weblogic` as "shareName", `wlsazure-secret` as "secretName", and the persistent volume name is `wls-azurefile`. |
| 113 | + |
| 114 | +We will use the storage class `azurefile`. If you want to create a new class, follow this document [Create a storage class](https://docs.microsoft.com/en-us/azure/aks/azure-files-dynamic-pv#create-a-storage-class). For more information, see the page [Storage options for applications in Azure Kubernetes Service (AKS)](https://docs.microsoft.com/en-us/azure/aks/concepts-storage#storage-classes). |
| 115 | + |
| 116 | +```yaml |
| 117 | +apiVersion: v1 |
| 118 | +kind: PersistentVolume |
| 119 | +metadata: |
| 120 | + name: wls-azurefile |
| 121 | +spec: |
| 122 | + capacity: |
| 123 | + storage: 5Gi |
| 124 | + accessModes: |
| 125 | + - ReadWriteMany |
| 126 | + storageClassName: azurefile |
| 127 | + azureFile: |
| 128 | + secretName: wlsazure-secret |
| 129 | + shareName: wls-weblogic-1597391432 |
| 130 | + readOnly: false |
| 131 | + mountOptions: |
| 132 | + - dir_mode=0777 |
| 133 | + - file_mode=0777 |
| 134 | + - uid=1000 |
| 135 | + - gid=1000 |
| 136 | + - mfsymlinks |
| 137 | + - nobrl |
| 138 | +``` |
| 139 | + |
| 140 | +We have provided another configuration file `pvc.yaml` for the PersistentVolumeClaim. Both `pv.yaml` and `pvc.yaml` have exactly the same content for `storageClassName` attributes. This is required. We set the same value to the `metadata` property in both files. The following content is an example that uses the persistent volume claim name `wls-azurefile`. |
| 141 | + |
| 142 | +```yaml |
| 143 | +apiVersion: v1 |
| 144 | +kind: PersistentVolumeClaim |
| 145 | +metadata: |
| 146 | + name: wls-azurefile |
| 147 | +spec: |
| 148 | + accessModes: |
| 149 | + - ReadWriteMany |
| 150 | + storageClassName: azurefile |
| 151 | + resources: |
| 152 | + requests: |
| 153 | + storage: 5Gi |
| 154 | +``` |
| 155 | + |
| 156 | +Use the `kubectl` command to create the persistent volume and persistent volume claim to `default` namespace. |
| 157 | + |
| 158 | +```bash |
| 159 | +$ kubectl apply -f ~/azure/weblogic-on-aks/pv.yaml |
| 160 | +persistentvolume/wls-azurefile created |
| 161 | +$ kubectl apply -f ~/azure/weblogic-on-aks/pvc.yaml |
| 162 | +persistentvolumeclaim/wls-azurefile created |
| 163 | +``` |
| 164 | + |
| 165 | +Use the following command to verify: |
| 166 | + |
| 167 | +```bash |
| 168 | +$ kubectl get pv,pvc |
| 169 | +``` |
| 170 | + |
| 171 | +Example output: |
| 172 | + |
| 173 | +```bash |
| 174 | +$ kubectl get pv,pvc |
| 175 | +NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE |
| 176 | +persistentvolume/wls-azurefile 5Gi RWX Retain Bound default/wls-azurefile azurefile 16m |
| 177 | + |
| 178 | +NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE |
| 179 | +persistentvolumeclaim/wls-azurefile Bound wls-azurefile 5Gi RWX azurefile 16m |
| 180 | +``` |
| 181 | + |
| 182 | +> **Note**: Carefully inspect the output and verify it matches the above. `ACCESS MODES`, `CLAIM`, and `STORAGECLASS` are vital. |
0 commit comments