Skip to content

Commit d9bb5a7

Browse files
edburnsgaliacheng
andauthored
Refactor WLS on AKS to cover two domain home source type scenarios. (#2219)
* Refactor WLS on AKS to cover two domain home source type scenarios. * Model in Image * Domain on PV This refactoring uses hugo shortcodes, like so: ``` {{< readfile file="/samples/simple/azure-kubernetes-service/includes/prerequisites-01.txt" >}} ``` This shortcode is defined in `docs-source/layouts/shortcodes/readfile.html`, which is simply: ``` {{ $toRead := .Get "file" }} {{ readFile $toRead | markdownify }} ``` By using hugo shortcodes, we can keep the text DRY, but maintain readability. Before this change, the WLS on AKS arrangement looks like: ``` 3. Samples Simple samples Credentials ... Azure Kubernetes Service Tanzu Kubernetes Service ``` After this change, the WLS on AKS arrangement looks like: ``` 3. Samples Simple samples Credentials ... Azure Kubernetes Service Domain home on a PV Model in image Troubleshooting Tanzu Kubernetes Service ``` Naturally, the steps in the two domain home source types have significant overlap. Hugho shortcode readfile allows us to account for that overlap while maintaining DRY. Running WLS on AKS via "Model in image" On branch wls-on-aks-model-in-image modified: docs-source/content/samples/simple/azure-kubernetes-service/_index.md - Use "Domain home source type" instead of "Domain home source scenario" for consistency with other parts of the documentation. - Update into to account for other values of Domain home source type. - Use "Domain in PV" instead of "Domain on a PV" for consistency with other parts of the docs. modified: docs-source/content/userguide/managing-domains/_index.md - Add "Azure Container Registry". modified: docs-source/content/userguide/managing-domains/domain-resource.md - Use the term `domainUID` consistently. modified: docs-source/content/userguide/managing-domains/prepare.md - Briefly define the term `domainUID` in place. modified: docs-source/content/userguide/overview/k8s-setup.md modified: docs-source/content/samples/simple/azure-kubernetes-service/domain-on-pv.md - Add automation step for domain-on-pv. - Validate service account - Complete PENDING activities. - Additional TOC entry Remove steps to build image. Use readfile with shortcode to allow content reuse On branch wls-on-aks-model-in-image Completed refactoring to verify domain-on-pv is correct. Next step is to revisit model-in-image. * Moved info block "The following sections of the" to the top, to get it out of the include. * Section *Prerequisites*. * Add dependency on Docker for Desktop. * Section *Oracle Container Registry*. * Simplified steps. * 12.2.1.4 pull. * Moved section *Clone WebLogic Server Kubernetes Operator repository* lower, to get it out of the include. * Added correctness check at end of section on setting up AKS. Starts with "After your Kubernetes cluster is up and running". * See above about info block. * Section *Generate configuration files* has been renamed *Create PV and PVC* The table in this section has been greatly simplified. * Things start to diverge greatly when the upstream says "Now let’s ask the operator to create a WebLogic Server domain within the AKS cluster." and the fork says "Follow Domain home on a PV - Use the script to create a domain to create the WebLogic domain home within the AKS cluster." We get back on track with the text "You may observe error-related output during the creation of the domain." * In the fork, in the section that starts with the text "You must create LoadBalancer services" the YAML snippets for the admin and managed servers are adjacent, and the apply commands are in the same execute block. * Troubleshooting is a separate section. modified: docs-source/content/samples/simple/azure-kubernetes-service/_index.md - Remove TOC entries to non-existent content. - Capitalize D in domain when appropriate. - Make it clear the two sub-sections are independent. deleted: docs-source/content/samples/simple/azure-kubernetes-service/create-aks-cluster.md - Content absorbed into files included with `readFile` shortcode. modified: docs-source/content/samples/simple/azure-kubernetes-service/domain-on-pv.md - See above. new file: docs-source/content/samples/simple/azure-kubernetes-service/includes/clean-up-resources.md modified: docs-source/content/samples/simple/azure-kubernetes-service/includes/create-aks-cluster-body.md modified: docs-source/content/samples/simple/azure-kubernetes-service/includes/create-aks-cluster-storage.md - Extractions. modified: docs-source/content/samples/simple/azure-kubernetes-service/model-in-image.md - Start first validation work. On branch wls-on-aks-model-in-image Complete refactoring. modified: docs-source/content/samples/simple/azure-kubernetes-service/domain-on-pv.md - Use 3.1.1 instead of 3.0.3. - Move prerequisites into include. new file: docs-source/content/samples/simple/azure-kubernetes-service/includes/prerequisites.md - Move prerequisites into include. modified: docs-source/content/samples/simple/azure-kubernetes-service/model-in-image.md - Move prerequisites into include. - Remove OCR. It is in a file that is included. - Move clone steps up. - Apply lessons from Jianguo from Azure/AKS#1517 (comment) modified: docs-source/content/samples/simple/azure-kubernetes-service/model-in-image.md - Add JDK to prereqs. - Add "--admin-enabled". - Fix typos in table. On branch wls-on-aks-model-in-image modified: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/model-in-image/mii-initial.yaml modified: kubernetes/samples/scripts/create-weblogic-domain/model-in-image/domain-resources/JRF/mii-initial-d1-JRF-v1.yaml modified: kubernetes/samples/scripts/create-weblogic-domain/model-in-image/domain-resources/WLS/mii-initial-d1-WLS-v1.yaml - Correct admin/managed. On branch wls-on-aks-model-in-image modified: docs-source/content/samples/simple/azure-kubernetes-service/domain-on-pv.md - Move notice to correct place. - Make headings be same as in live docs. new file: docs-source/content/samples/simple/azure-kubernetes-service/includes/create-aks-cluster-body-01.md new file: docs-source/content/samples/simple/azure-kubernetes-service/includes/create-aks-cluster-body-02.md - Break up files to separate parts. deleted: docs-source/content/samples/simple/azure-kubernetes-service/includes/create-aks-cluster-body.md modified: docs-source/content/samples/simple/azure-kubernetes-service/includes/create-aks-cluster-storage.md - Re-add rows removed from table. modified: docs-source/content/samples/simple/azure-kubernetes-service/model-in-image.md - Use two parts. - Remove unnecessary heading. modified: docs-source/content/samples/simple/azure-kubernetes-service/domain-on-pv.md new file: docs-source/content/samples/simple/azure-kubernetes-service/includes/clean-up-resources-body-01.md new file: docs-source/content/samples/simple/azure-kubernetes-service/includes/clean-up-resources-body-02.md deleted: docs-source/content/samples/simple/azure-kubernetes-service/includes/clean-up-resources.md modified: docs-source/content/samples/simple/azure-kubernetes-service/includes/create-aks-cluster-storage.md modified: docs-source/content/samples/simple/azure-kubernetes-service/model-in-image.md modified: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/azure-file-pv-template.yaml modified: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/azure-file-pvc-template.yaml renamed: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/create-aks-cluster-inputs.yaml -> kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/create-domain-on-aks-inputs.yaml renamed: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/create-aks-cluster.sh -> kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/create-domain-on-aks.sh deleted: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/domain-on-pv/admin-lb.yaml deleted: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/domain-on-pv/cluster-lb.yaml deleted: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/domain-on-pv/create-domain-inputs.yaml new file: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/loadbalancer-template.yaml modified: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/model-in-image/admin-lb.yaml modified: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/model-in-image/cluster-lb.yaml modified: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/model-in-image/helm-sa-cluster-admin-role.yaml modified: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/model-in-image/mii-initial.yaml Fix the menu issue. The live page will show included files in the menu. Change the included files as txt can solve this problem. Changes to be committed: modified: ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/domain-on-pv.md renamed: ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/includes/clean-up-resources-body-01.md -> ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/includes/clean-up-resources-body-01.txt renamed: ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/includes/clean-up-resources-body-02.md -> ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/includes/clean-up-resources-body-02.txt renamed: ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/includes/create-aks-cluster-body-01.md -> ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/includes/create-aks-cluster-body-01.txt renamed: ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/includes/create-aks-cluster-body-02.md -> ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/includes/create-aks-cluster-body-02.txt renamed: ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/includes/create-aks-cluster-storage.md -> ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/includes/create-aks-cluster-storage.txt renamed: ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/includes/prerequisites.md -> ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/includes/prerequisites-01.txt new file: ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/includes/prerequisites-02.txt modified: ../../../../../docs-source/content/samples/simple/azure-kubernetes-service/model-in-image.md - Validate model-in-image On branch wls-on-aks-model-in-image modified: docs-source/content/samples/simple/azure-kubernetes-service/domain-on-pv.md - Added note to skip to sample deployment. - Use 1. for numbered lists. modified: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/create-domain-on-aks-inputs.yaml - Update weblogic version number in image to 12.2.1.4. Add troubeshooting for WebLogic Kubernetes Operator ErrImagePull Troubleshooting for VM size error Update troubleshooting.md Update domain-on-pv.md Remove diff markers Thanks @tbarnes-us. On branch wls-on-aks-model-in-image Apply suggestions from @rosemarymarano and @tbarnes-us. modified: docs-source/content/samples/simple/azure-kubernetes-service/_index.md modified: docs-source/content/samples/simple/azure-kubernetes-service/domain-on-pv.md modified: docs-source/content/samples/simple/azure-kubernetes-service/includes/create-aks-cluster-storage.txt modified: docs-source/content/samples/simple/azure-kubernetes-service/includes/prerequisites-02.txt modified: docs-source/content/samples/simple/azure-kubernetes-service/model-in-image.md modified: docs-source/content/samples/simple/azure-kubernetes-service/troubleshooting.md modified: docs-source/content/userguide/managing-domains/prepare.md modified: kubernetes/samples/scripts/create-weblogic-domain/model-in-image/domain-resources/JRF/mii-initial-d1-JRF-v1.yaml modified: kubernetes/samples/scripts/create-weblogic-domain/model-in-image/domain-resources/WLS/mii-initial-d1-WLS-v1.yaml modified: operator/integration-tests/model-in-image/mii-sample-wrapper/mii-domain.yaml.template-JRF modified: operator/integration-tests/model-in-image/mii-sample-wrapper/mii-domain.yaml.template-WLS deleted: kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/model-in-image/mii-initial.yaml * On branch wls-on-aks-model-in-image-from-master modified: docs-source/content/samples/simple/azure-kubernetes-service/troubleshooting.md - Address @ddsharpe's comment: @rjeberhard Image Tool 1.9.8 (latest release) no longer has this issue. The user can use Docker with or without buildkit enabled. modified: docs-source/content/samples/simple/azure-kubernetes-service/model-in-image.md - Address @rjeberhard's comments - This is obsoleted. Helm needed it's own service account only for Helm 2.x. With Helm 3.x the service account of the customer running the helm install is used. - My preference, though, would be to go further and find a way to do periodic integration testing so that we can just tell customers to use the latest version of the operator. We've had very few upgrade bugs (although, we did just fix one) and we are making it a priority to keep upgrading simple. Therefore, I believe that it will be safe to tell customers to use the latest as long as we do periodic tests (e.g. once per quarter). - @edburns: Yes, let's just go with master. * On branch wls-on-aks-model-in-image-from-master Address comment from @tbarnes-us modified: kubernetes/samples/scripts/create-weblogic-domain/model-in-image/domain-resources/JRF/mii-update1-d1-JRF-v1-ds.yaml modified: kubernetes/samples/scripts/create-weblogic-domain/model-in-image/domain-resources/JRF/mii-update2-d2-JRF-v1-ds.yaml modified: kubernetes/samples/scripts/create-weblogic-domain/model-in-image/domain-resources/JRF/mii-update3-d1-JRF-v2-ds.yaml modified: kubernetes/samples/scripts/create-weblogic-domain/model-in-image/domain-resources/WLS/mii-update1-d1-WLS-v1-ds.yaml modified: kubernetes/samples/scripts/create-weblogic-domain/model-in-image/domain-resources/WLS/mii-update2-d2-WLS-v1-ds.yaml modified: kubernetes/samples/scripts/create-weblogic-domain/model-in-image/domain-resources/WLS/mii-update3-d1-WLS-v2-ds.yaml modified: src/integration-tests/model-in-image/mii-sample-wrapper/mii-domain.yaml.template-JRF modified: src/integration-tests/model-in-image/mii-sample-wrapper/mii-domain.yaml.template-WLS Address comment from @tbarnes-us: - Note that 8 files will change in total, and all of them must be checked-in so that the integration test will pass... * On branch wls-on-aks-model-in-image-from-master Address comment from @tbarnes-us modified: docs-source/content/samples/simple/azure-kubernetes-service/_index.md - Please append "/_index.md" to the reference. * Append _index.md to relref Co-authored-by: haixia <haixia.cheng@microsoft.com>
1 parent 298f6a6 commit d9bb5a7

34 files changed

+2174
-1024
lines changed

docs-source/content/samples/simple/azure-kubernetes-service/_index.md

Lines changed: 26 additions & 998 deletions
Large diffs are not rendered by default.

docs-source/content/samples/simple/azure-kubernetes-service/domain-on-pv.md

Lines changed: 549 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
The output from the `create-domain-on-aks.sh` script includes a statement about the Azure resources created by the script. To delete the cluster and free all related resources, simply delete the resource groups. The output will list the resource groups, such as.
2+
3+
```bash
4+
The following Azure resouces have been created:
5+
Resource groups: ejb8191resourcegroup1597641911, MC_ejb8191resourcegroup1597641911_ejb8191akscluster1597641911_eastus
6+
```
7+
8+
Given the above output, the following Azure CLI commands will delete the resource groups.
9+
10+
```bash
11+
az group delete --yes --no-wait --name ejb8191resourcegroup1597641911
12+
az group delete --yes --no-wait --name MC_ejb8191resourcegroup1597641911_ejb8191akscluster1597641911_eastus
13+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```bash
2+
$ az group delete --yes --no-wait --name $AKS_PERS_RESOURCE_GROUP
3+
$ az group delete --yes --no-wait --name "MC_$AKS_PERS_RESOURCE_GROUP"_"$AKS_CLUSTER_NAME"_"$AKS_PERS_LOCATION"
4+
$ az ad sp delete --id $SP_APP_ID
5+
```
6+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
##### Create a Service Principal for AKS
2+
3+
An AKS cluster requires either an [Azure Active Directory (AD) service principal](https://docs.microsoft.com/azure/active-directory/develop/app-objects-and-service-principals) or a [managed identity](https://docs.microsoft.com/azure/aks/use-managed-identity) to interact with Azure resources.
4+
5+
We will use a service principal to create an AKS cluster. Follow the commands below to create a new service principal.
6+
7+
Please run `az login` first. Do set the subscription you want to work with. You can get a list of your subscriptions by running `az account list`.
8+
9+
```bash
10+
# Login
11+
$ az login
12+
13+
# Set your working subscription
14+
$ export SUBSCRIPTION_ID=<your-subscription-id>
15+
$ az account set -s $SUBSCRIPTION_ID
16+
```
17+
18+
Create the new service principal with the following commands:
19+
20+
```bash
21+
# Create Service Principal
22+
$ export SP_NAME=myAKSClusterServicePrincipal
23+
$ az ad sp create-for-rbac --skip-assignment --name $SP_NAME
24+
25+
# Copy the output to a file, we will use it later.
26+
```
27+
28+
If you see an error similar to the following:
29+
30+
```bash
31+
Found an existing application instance of "5pn2s201-nq4q-43n1-z942-p9r9571qr3rp". We will patch it
32+
Insufficient privileges to complete the operation.
33+
```
34+
35+
The problem may be a pre-existing service principal with the same name. Either delete the other Service Principal or pick a different name.
36+
37+
Successful output will look like the following:
38+
39+
```json
40+
{
41+
"appId": "r3qnq743-61s9-4758-8163-4qpo87s72s54",
42+
"displayName": "myAKSClusterServicePrincipal",
43+
"name": "http://myAKSClusterServicePrincipal",
44+
"password": "TfhR~uOJ1C1ftD5NS_LzJJj6UOjS2OwXfz",
45+
"tenant": "82sr215n-0ns5-404e-9161-206r0oqyq999"
46+
}
47+
```
48+
49+
Grant your service principal with a contributor role to create AKS resources.
50+
51+
```bash
52+
# Use the <appId> from the output of the last command
53+
$ export SP_APP_ID=r3qnq743-61s9-4758-8163-4qpo87s72s54
54+
$ az role assignment create --assignee $SP_APP_ID --role Contributor
55+
```
56+
57+
Successful output will look like the following:
58+
59+
```json
60+
{
61+
"canDelegate": null,
62+
"id": "/subscriptions/p7844r91-o11q-4n7s-np6s-996308sopqo9/providers/Microsoft.Authorization/roleAssignments/4oq396os-rs95-4n6s-n3qo-sqqpnpo91035",
63+
"name": "4oq396os-rs95-4n6s-n3qo-sqqpnpo91035",
64+
"principalId": "952551r8-n129-4on3-oqo9-231n0s6011n3",
65+
"principalType": "ServicePrincipal",
66+
"roleDefinitionId": "/subscriptions/p7844r91-o11q-4n7s-np6s-996308sopqo9/providers/Microsoft.Authorization/roleDefinitions/o24988np-6180-42n0-no88-20s7382qq24p",
67+
"scope": "/subscriptions/p7844r91-o11q-4n7s-np6s-996308sopqo9",
68+
}
69+
```
70+
71+
##### Oracle Container Registry
72+
73+
You will need an Oracle account. The following steps will direct you to accept the license agreement for WebLogic Server. Make note of your Oracle Account password and email. This sample pertains to 12.2.1.4, but other versions may work as well.
74+
75+
- In a web browser, navigate to https://container-registry.oracle.com and log in using the Oracle Single Sign-On authentication service. If you do not already have SSO credentials, at the top of the page, click the **Sign In** link to create them.
76+
- The Oracle Container Registry provides a WebLogic Server 12.2.1.4.0 Docker image, which already has the necessary patches applied, and the Oracle WebLogic Server 12.2.1.4.0 and 14.1.1.0.0 images, which do not require any patches.
77+
- Ensure Docker desktop is running. Find and then pull the WebLogic 12.2.1.4 install image:
78+
```bash
79+
$ docker pull container-registry.oracle.com/middleware/weblogic:12.2.1.4
80+
```
81+
82+
If you have problems accessing the Oracle Container Registry, you can build your own docker images from the [Oracle GitHub repository](https://github.com/oracle/docker-images/tree/main/OracleWebLogic/dockerfiles).
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#### Create the AKS cluster
2+
3+
This sample requires that you disable the AKS addon `http_application_routing` by default. If you want to enable `http_application_routing`, please follow [HTTP application routing](https://docs.microsoft.com/azure/aks/http-application-routing).
4+
5+
Run the following commands to create the AKS cluster instance.
6+
7+
```bash
8+
# Change these parameters as needed for your own environment
9+
# Specify a prefix to name resources, only allow lowercase letters and numbers, between 1 and 7 characters
10+
$ export NAME_PREFIX=wls
11+
# Used to generate resource names.
12+
$ export TIMESTAMP=`date +%s`
13+
$ export AKS_CLUSTER_NAME="${NAME_PREFIX}aks${TIMESTAMP}"
14+
$ export AKS_PERS_RESOURCE_GROUP="${NAME_PREFIX}resourcegroup${TIMESTAMP}"
15+
$ export AKS_PERS_LOCATION=eastus
16+
$ export SP_APP_ID=<appId from the az ad sp create-for-rbac command>
17+
$ export SP_CLIENT_SECRET=<password from the az ad sp create-for-rbac command>
18+
19+
$ az group create --name $AKS_PERS_RESOURCE_GROUP --location $AKS_PERS_LOCATION
20+
$ az aks create \
21+
--resource-group $AKS_PERS_RESOURCE_GROUP \
22+
--name $AKS_CLUSTER_NAME \
23+
--node-count 2 \
24+
--generate-ssh-keys \
25+
--nodepool-name nodepool1 \
26+
--node-vm-size Standard_DS2_v2 \
27+
--location $AKS_PERS_LOCATION \
28+
--service-principal $SP_APP_ID \
29+
--client-secret $SP_CLIENT_SECRET
30+
```
31+
32+
Successful output will be a JSON object with the entry `"type": "Microsoft.ContainerService/ManagedClusters"`.
33+
34+
After the deployment finishes, run the following command to connect to the AKS cluster. This command updates your local `~/.kube/config` so that subsequent `kubectl` commands interact with the named AKS cluster.
35+
36+
```bash
37+
$ az aks get-credentials --resource-group $AKS_PERS_RESOURCE_GROUP --name $AKS_CLUSTER_NAME
38+
```
39+
40+
Successful output will look similar to:
41+
42+
```bash
43+
Merged "wlsaks1596087429" as current context in /home/username/.kube/config
44+
```
45+
46+
After your Kubernetes cluster is up and running, run the following commands to make sure kubectl can access the Kubernetes cluster:
47+
48+
```shell
49+
$ kubectl get nodes -o wide
50+
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
51+
aks-pool1haiche-33688868-vmss000000 Ready agent 4m25s v1.17.13 10.240.0.4 <none> Ubuntu 16.04.7 LTS 4.15.0-1098-azure docker://19.3.12
52+
aks-pool1haiche-33688868-vmss000001 Ready agent 4m12s v1.17.13 10.240.0.5 <none> Ubuntu 16.04.7 LTS 4.15.0-1098-azure docker://19.3.12
53+
```
54+
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
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.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#### Prerequisites
2+
3+
This sample assumes the following prerequisite environment.
4+
5+
* Operating System: GNU/Linux, macOS or [WSL2 for Windows 10](https://docs.microsoft.com/windows/wsl/install-win10).
6+
* [Git](https://git-scm.com/downloads), use `git --version` to test if `git` works. This document was tested with version 2.17.1.
7+
* [Azure CLI](https://docs.microsoft.com/cli/azure), use `az --version` to test if `az` works. This document was tested with version 2.9.1.
8+
* [Docker for Desktop](https://www.docker.com/products/docker-desktop). This document was tested with `Docker version 20.10.2, build 2291f61`
9+
* [kubectl](https://kubernetes-io-vnext-staging.netlify.com/docs/tasks/tools/install-kubectl/), use `kubectl version` to test if `kubectl` works. This document was tested with version v1.16.3.
10+
* [helm](https://helm.sh/docs/intro/install/), version 3.1 and later, use `helm version` to check the `helm` version. This document was tested with version v3.2.4.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#### Prerequisites
2+
3+
This sample assumes the following prerequisite environment.
4+
5+
* Operating System: GNU/Linux, macOS or [WSL2 for Windows 10](https://docs.microsoft.com/windows/wsl/install-win10).
6+
* [Git](https://git-scm.com/downloads), use `git --version` to test if `git` works. This document was tested with version 2.17.1.
7+
* [Azure CLI](https://docs.microsoft.com/cli/azure), use `az --version` to test if `az` works. This document was tested with version 2.9.1.
8+
* [Docker for Desktop](https://www.docker.com/products/docker-desktop). This document was tested with `Docker version 20.10.2, build 2291f61`
9+
* [kubectl](https://kubernetes-io-vnext-staging.netlify.com/docs/tasks/tools/install-kubectl/), use `kubectl version` to test if `kubectl` works. This document was tested with version v1.16.3.
10+
* [Helm](https://helm.sh/docs/intro/install/), version 3.1 and later, use `helm version` to check the `helm` version. This document was tested with version v3.2.4.
11+
* A Java JDK, Version 8 or 11. Azure recommends [Azul Zulu for Azure](https://www.azul.com/downloads/azure-only/zulu/). Ensure your `JAVA_HOME` environment variable is set correctly in the shells in which you run the commands.
12+
* Ensure you have the zip/unzip utility installed, use `zip/unzip -v` to test if `zip/unzip` works.

0 commit comments

Comments
 (0)