Skip to content

Commit 6135ce7

Browse files
rjeberhardmriccell
andauthored
Merge pull request #1873 from edburns/edburns-msft-180-02-wls-aks (#1894)
Add sample running Oracle WLS Kubernetes Operator on Azure Kubernetes Service Co-authored-by: Monica Riccelli <[email protected]>
1 parent 1876ada commit 6135ce7

File tree

14 files changed

+2235
-1
lines changed

14 files changed

+2235
-1
lines changed

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

Lines changed: 979 additions & 0 deletions
Large diffs are not rendered by default.
Loading
Loading

kubernetes/samples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ While these samples may be useful and usable as is, it is intended that you woul
1616
* [Sample for configuring the Elasticsearch and Kibana](scripts/elasticsearch-and-kibana/README.md) deployments and services for the operator's logs.
1717
* [Sample for generating a self-signed certificate and private key](scripts/rest/README.md) that can be used for the operator's external REST API.
1818
* [Sample for creating an OKE cluster using Terraform](scripts/terraform/README.md).
19+
* [Sample for running a WebLogic cluster on the Azure Kubernetes Service](scripts/create-weblogic-domain-on-azure-kubernetes-service/README.md), and the YAML file for deploying the Azure resources and generated WebLogic domain.
1920

2021
## Sample Helm charts
2122

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2018, 2020, Oracle Corporation and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
#
5+
# Description
6+
# This sample script creates a Kubernetes secret for Azure Storage to use Azure file share on AKS.
7+
#
8+
# The following pre-requisites must be handled prior to running this script:
9+
# * The kubernetes namespace must already be created
10+
#
11+
12+
script="${BASH_SOURCE[0]}"
13+
14+
#
15+
# Function to exit and print an error message
16+
# $1 - text of message
17+
function fail {
18+
echo [ERROR] $*
19+
exit 1
20+
}
21+
22+
# Try to execute kubectl to see whether kubectl is available
23+
function validateKubectlAvailable {
24+
if ! [ -x "$(command -v kubectl)" ]; then
25+
fail "kubectl is not installed"
26+
fi
27+
}
28+
29+
function usage {
30+
echo usage: ${script} -c storageAccountName -k storageAccountKey [-s secretName] [-n namespace] [-h]
31+
echo " -a storage account name, must be specified."
32+
echo " -k storage account key, must be specified."
33+
echo " -s secret name, optional. Use azure-secret if not specified."
34+
echo " -n namespace, optional. Use the default namespace if not specified."
35+
echo " -h Help"
36+
exit $1
37+
}
38+
39+
#
40+
# Parse the command line options
41+
#
42+
secretName=azure-secret
43+
namespace=default
44+
while getopts "ha:k:s:n:" opt; do
45+
case $opt in
46+
a) storageAccountName="${OPTARG}"
47+
;;
48+
k) storageAccountKey="${OPTARG}"
49+
;;
50+
s) secretName="${OPTARG}"
51+
;;
52+
n) namespace="${OPTARG}"
53+
;;
54+
h) usage 0
55+
;;
56+
*) usage 1
57+
;;
58+
esac
59+
done
60+
61+
if [ -z ${storageAccountName} ]; then
62+
echo "${script}: -e must be specified."
63+
missingRequiredOption="true"
64+
fi
65+
66+
if [ -z ${storageAccountKey} ]; then
67+
echo "${script}: -p must be specified."
68+
missingRequiredOption="true"
69+
fi
70+
71+
if [ "${missingRequiredOption}" == "true" ]; then
72+
usage 1
73+
fi
74+
75+
# check and see if the secret already exists
76+
result=`kubectl get secret ${secretName} -n ${namespace} --ignore-not-found=true | grep ${secretName} | wc | awk ' { print $1; }'`
77+
if [ "${result:=Error}" != "0" ]; then
78+
fail "The secret ${secretName} already exists in namespace ${namespace}."
79+
fi
80+
81+
# create the secret
82+
kubectl -n $namespace create secret generic $secretName \
83+
--from-literal=azurestorageaccountname=$storageAccountName \
84+
--from-literal=azurestorageaccountkey=$storageAccountKey
85+
86+
# Verify the secret exists
87+
SECRET=`kubectl get secret ${secretName} -n ${namespace} | grep ${secretName} | wc | awk ' { print $1; }'`
88+
if [ "${SECRET}" != "1" ]; then
89+
fail "The secret ${secretName} was not found in namespace ${namespace}"
90+
fi
91+
92+
echo "The secret ${secretName} has been successfully created in the ${namespace} namespace."
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2018, 2020, Oracle Corporation and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
#
5+
# Description
6+
# This sample script creates a Kubernetes secret for Docker credentials for use with the WLS Operator on AKS.
7+
#
8+
# The following pre-requisites must be handled prior to running this script:
9+
# * The kubernetes namespace must already be created
10+
#
11+
12+
script="${BASH_SOURCE[0]}"
13+
14+
#
15+
# Function to exit and print an error message
16+
# $1 - text of message
17+
function fail {
18+
echo [ERROR] $*
19+
exit 1
20+
}
21+
22+
# Try to execute kubectl to see whether kubectl is available
23+
function validateKubectlAvailable {
24+
if ! [ -x "$(command -v kubectl)" ]; then
25+
fail "kubectl is not installed"
26+
fi
27+
}
28+
29+
function usage {
30+
echo usage: ${script} -e email -p password -u username [-s secretName] [-d dockerServer] [-n namespace] [-h]
31+
echo " -e email, must be specified."
32+
echo " -p password, must be specified."
33+
echo " -u username, must be specified."
34+
echo " -s secret name, optional, Use regcred if not specified."
35+
echo " -d docker server, optional, Use docker.io if not specified."
36+
echo " -n namespace, optional. Use the default namespace if not specified"
37+
echo " -h Help"
38+
exit $1
39+
}
40+
41+
#
42+
# Parse the command line options
43+
#
44+
secretName=regcred
45+
namespace=default
46+
dockerServer=container-registry.oracle.com
47+
while getopts "he:p:u:n:d:s:d:" opt; do
48+
case $opt in
49+
e) email="${OPTARG}"
50+
;;
51+
p) password="${OPTARG}"
52+
;;
53+
u) username="${OPTARG}"
54+
;;
55+
s) secretName="${OPTARG}"
56+
;;
57+
d) dockerServer="${OPTARG}"
58+
;;
59+
n) namespace="${OPTARG}"
60+
;;
61+
h) usage 0
62+
;;
63+
*) usage 1
64+
;;
65+
esac
66+
done
67+
68+
if [ -z ${email} ]; then
69+
echo "${script}: -e must be specified."
70+
missingRequiredOption="true"
71+
fi
72+
73+
if [ -z ${password} ]; then
74+
echo "${script}: -p must be specified."
75+
missingRequiredOption="true"
76+
fi
77+
78+
if [ -z ${username} ]; then
79+
echo "${script}: -u must be specified."
80+
missingRequiredOption="true"
81+
fi
82+
83+
if [ "${missingRequiredOption}" == "true" ]; then
84+
usage 1
85+
fi
86+
87+
# check and see if the secret already exists
88+
result=`kubectl get secret ${secretName} -n ${namespace} --ignore-not-found=true | grep ${secretName} | wc | awk ' { print $1; }'`
89+
if [ "${result:=Error}" != "0" ]; then
90+
fail "The secret ${secretName} already exists in namespace ${namespace}."
91+
fi
92+
93+
# create the secret
94+
kubectl -n $namespace create secret docker-registry $secretName \
95+
--docker-email=$email \
96+
--docker-password=$password \
97+
--docker-server=$dockerServer \
98+
--docker-username=$username
99+
100+
# Verify the secret exists
101+
SECRET=`kubectl get secret ${secretName} -n ${namespace} | grep ${secretName} | wc | awk ' { print $1; }'`
102+
if [ "${SECRET}" != "1" ]; then
103+
fail "The secret ${secretName} was not found in namespace ${namespace}"
104+
fi
105+
106+
echo "The secret ${secretName} has been successfully created in the ${namespace} namespace."
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Please see the documentation for this sample [in the documentation for the Operator](https://oracle.github.io/weblogic-kubernetes-operator/samples/simple/azure-kubernetes-service/).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (c) 2018, 2020, Oracle Corporation and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
apiVersion: v1
5+
kind: PersistentVolume
6+
metadata:
7+
name: %PERSISTENT_VOLUME_NAME%
8+
labels:
9+
usage: %PERSISTENT_VOLUME_NAME%
10+
spec:
11+
capacity:
12+
storage: 10Gi
13+
accessModes:
14+
- ReadWriteMany
15+
storageClassName: %STORAGE_CLASS_NAME%
16+
persistentVolumeReclaimPolicy: Retain
17+
azureFile:
18+
secretName: %AZURE_FILE_SHARE_SECRET_NAME%
19+
shareName: %AZURE_FILE_SHARE_NAME%
20+
readOnly: false
21+
mountOptions:
22+
- dir_mode=0777
23+
- file_mode=0777
24+
- uid=1000
25+
- gid=1000
26+
- mfsymlinks
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2018, 2020, Oracle Corporation and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
apiVersion: v1
5+
kind: PersistentVolumeClaim
6+
metadata:
7+
name: %PERSISTENT_VOLUME_CLAIM_NAME%
8+
spec:
9+
accessModes:
10+
- ReadWriteMany
11+
storageClassName: %STORAGE_CLASS_NAME%
12+
resources:
13+
requests:
14+
storage: 10Gi
15+
selector:
16+
matchLabels:
17+
usage: %PERSISTENT_VOLUME_CLAIM_NAME%
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Copyright (c) 2018, 2020, Oracle Corporation and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
# The version of this inputs file. Do not modify.
5+
version: create-domain-on-aks-inputs-v1
6+
7+
#
8+
# Parameters that must be changed from these values!
9+
#
10+
11+
# The service principal is used to login to azure and create an azure kubernetes cluster.
12+
# If you don't have a service principal, please follow README.md
13+
# Application id of the service principal.
14+
azureServicePrincipalAppId: azure-service-principal-app-id
15+
16+
# A client secret of the service principal.
17+
azureServicePrincipalClientSecret: azure-service-principal-client-secret
18+
19+
# Tenant (Directory) id of the service principal.
20+
azureServicePrincipalTenantId: azure-service-principal-tenant-id
21+
22+
# Oracle Single Sign-On (SSO) account email, used to pull the WebLogic Server Docker image
23+
dockerEmail: docker-email
24+
25+
# Password for Oracle SSO account password, used to pull the WebLogic Server Docker image
26+
dockerPassword: docker-password
27+
28+
# The same value as dockerEmail
29+
dockerUserName: docker-user-name
30+
31+
# Specify where to create azure resource.
32+
azureLocation: eastus
33+
34+
# Specify a prefix to name resources, only allow lowercase letters and numbers, between 1 and 7 characters.
35+
# Resource group is named with ${namePrefix}resourcegroup<timestamp>, e.g. wlsresourcegroup1592469388
36+
# Kubernetes cluster is named with ${namePrefix}akscluster<timestamp>, e.g. wlsakscluster1592469388
37+
# Storage account is named with ${namePrefix}storage<timestamp>, e.g. wlsstorage1592469388
38+
namePrefix: wls
39+
40+
#
41+
# Parameters that may optionally be changed.
42+
#
43+
44+
# The suffix of file share secret name, the complete value is ${namePrefix}${azureFileShareSecretNameSuffix}.
45+
azureFileShareSecretNameSuffix: azure-secret
46+
47+
# Number of azure kubernetes nodes, used to create azure kubernetes cluster.
48+
azureKubernetesNodeCount: 2
49+
50+
# VM size of azure kubernetes node.
51+
azureKubernetesNodeVMSize: Standard_DS2_v2
52+
53+
# The suffix of azure kubernetes node pool name, the azure kubernetes node pool name will be${azureKubernetesNodepoolNamePrefix} ${namePrefix}.
54+
azureKubernetesNodepoolNamePrefix: pool1
55+
56+
# SKU of azure storage account, used to create storage account.
57+
azureStorageAccountSku: Standard_LRS
58+
59+
# Name of Azure Storage Class. We will use initial StorageClasses azurefile.
60+
# If you want to create new class, follow the document: https://docs.microsoft.com/en-us/azure/aks/azure-files-dynamic-pv#create-a-storage-class.
61+
# Go to this page for more details: https://docs.microsoft.com/en-us/azure/aks/concepts-storage#storage-classes
62+
azureStorageClassName: azurefile
63+
64+
# The suffix of azure storage file share name, the complete value is ${namePrefix}-${azureStorageShareNameSuffix}-<timestamp>, used to create file share, and mount file share.
65+
azureStorageShareNameSuffix: weblogic
66+
67+
# The suffix of the Kubernetes secret name, the complete value is ${namePrefix}${imagePullSecretNameSuffix}. The secret name is used to access the Docker Store to pull the WebLogic Server Docker image
68+
# Used to create kubenetes secret for docker hub account.
69+
# Parameter "imagePullSecretName" will be overwritten with this field in kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain-inputs.yaml
70+
imagePullSecretNameSuffix: regcred
71+
72+
# The suffix of the persistent volume claim name, the complete value is ${namePrefix}-${persistentVolumeClaimNameSuffix}-<timestamp>.
73+
# Parameter "persistentVolumeClaimName" will be overwritten with this field in kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain-inputs.yaml
74+
persistentVolumeClaimNameSuffix: azurefile
75+
76+
# Password for weblogic account.
77+
weblogicAccountPassword: welcome1
78+
79+
# WebLogic Server Docker image.
80+
# Parameter "image" will be overwritten with this field in kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain-inputs.yaml
81+
weblogicDockerImage: container-registry.oracle.com/middleware/weblogic:12.2.1.3
82+
83+
# Name of weblogic user.
84+
weblogicUserName: weblogic
85+
86+
87+

0 commit comments

Comments
 (0)