Skip to content

Commit 24e67eb

Browse files
committed
Merge remote-tracking branch 'origin/master' into develop
2 parents b5f8e7d + d9bb5a7 commit 24e67eb

37 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)