From 1d8cda8295272f61c90ccafd988992770af4cb50 Mon Sep 17 00:00:00 2001 From: galiacheng Date: Thu, 23 Dec 2021 14:13:01 +0800 Subject: [PATCH 1/9] apply resources limits to wls 14 to solve the evicted pod issue. Signed-off-by: galiacheng Changes to be committed: new file: weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh modified: weblogic-azure-aks/src/main/bicep/mainTemplate.bicep new file: weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep Fix script update update update update introspectorJobActiveDeadlineSeconds debug update script remove debug code fix script fix timestamp fix domain uid fix interval create global const for JVM args. Signed-off-by: galiacheng Changes to be committed: modified: weblogic-azure-aks/src/main/arm/scripts/common.sh modified: weblogic-azure-aks/src/main/arm/scripts/genDomainConfig.sh --- .../main/arm/scripts/applyGuaranteedQos.sh | 137 ++++++++++++++++++ .../src/main/arm/scripts/common.sh | 2 + .../src/main/arm/scripts/genDomainConfig.sh | 2 +- .../src/main/bicep/mainTemplate.bicep | 23 ++- .../_ds-apply-guaranteed-qos.bicep | 62 ++++++++ 5 files changed, 224 insertions(+), 2 deletions(-) create mode 100644 weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh create mode 100644 weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep diff --git a/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh b/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh new file mode 100644 index 000000000..44f2e31c5 --- /dev/null +++ b/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh @@ -0,0 +1,137 @@ +# Copyright (c) 2021, Oracle Corporation and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# This script runs on Azure Container Instance with Alpine Linux that Azure Deployment script creates. +# +# env inputs: +# AKS_CLUSTER_NAME +# AKS_CLUSTER_RESOURCEGROUP_NAME +# WLS_DOMAIN_UID + +# Main script +script="${BASH_SOURCE[0]}" +scriptDir="$(cd "$(dirname "${script}")" && pwd)" +source ${scriptDir}/common.sh +source ${scriptDir}/utility.sh + +qualityofService="BestEffort" +wlsContainerName="weblogic-server" +wlsDomainNS="${WLS_DOMAIN_UID}-ns" + +echo_stdout "install kubectl" +install_kubectl + +echo_stdout "Connect AKS" +az aks get-credentials \ + --resource-group ${AKS_CLUSTER_RESOURCEGROUP_NAME} \ + --name ${AKS_CLUSTER_NAME} \ + --overwrite-existing + +adminPodName=$(kubectl -n ${wlsDomainNS} get pod -l weblogic.serverName=admin-server -o json | + jq '.items[0] | .metadata.name' | + tr -d "\"") +if [ -z "${adminPodName}" ]; then + echo_stderr "Fail to get admin server pod." + exit 1 +fi + +wlstQueryVersionScript=queryVersion.py +cat <${wlstQueryVersionScript} +print '#version#:' + version +EOF + +echo_stdout "copy WLST script ${wlstQueryVersionScript} to ${adminPodName}:/tmp/${wlstQueryVersionScript}" +targetPyFilePath=/tmp/${wlstQueryVersionScript} +kubectl cp ${wlstQueryVersionScript} -n ${wlsDomainNS} ${adminPodName}:${targetPyFilePath} +version=$(kubectl exec -it ${adminPodName} -n ${wlsDomainNS} -c ${wlsContainerName} -- bash -c "wlst.sh ${targetPyFilePath}") +# output sample: +# Initializing WebLogic Scripting Tool (WLST) ... + +# Welcome to WebLogic Server Administration Scripting Shell + +# Type help() for help on available commands + +# #version#:WebLogic Server 14.1.1.0.0 +version="${version##*\#version\#\:}" # match #version#:, this is a special mark for the version output, please do not change it. +echo_stdout ${version} + +if [ "${version#*WebLogic Server 14.1.1.0}" != "$version" ]; then + timestampBeforePatchingDomain=$(date +%s) + echo "timestampBeforePatchingDomain=${timestampBeforePatchingDomain}" + + # we assume the customer to create WebLogic Server using the offer or template, + # and specify the same resources requirement for admin server and managed server. + cpuRequest=$(kubectl get domain ${WLS_DOMAIN_UID} -n ${wlsDomainNS} -o json | + jq '. |.spec.serverPod.resources.requests.cpu' | + tr -d "\"") + echo_stdout "Previous CPU request: ${cpuRequest}" + + memoryRequest=$(kubectl get domain ${WLS_DOMAIN_UID} -n ${wlsDomainNS} -o json | + jq '. | .spec.serverPod.resources.requests.memory' | + tr -d "\"") + echo_stdout "Previous memory request: ${memoryRequest}" + + restartVersion=$(kubectl -n ${wlsDomainNS} get domain ${WLS_DOMAIN_UID} -o json | + jq '. | .spec.restartVersion' | + tr -d "\"") + restartVersion=$((restartVersion+1)) + + # check CPU units, set units with "m" + if [[ ${cpuRequest} =~ "m" ]]; then + cpu=$(echo $cpuRequest | sed 's/[^0-9]*//g') + else + cpu=$((cpuRequest * 1000)) + fi + # make sure there is enough CPU limits to run the WebLogic Server + # if the cpu is less than 500m, set it 500m + # the domain configuration will be outputed after the offer deployment finishes. + if [ $cpu -lt 500 ]; then + cpu=500 + fi + + # create patch configuration with YAML file + # keep resources.limits the same with requests + cat <patch-resource-limits.yaml +spec: + serverPod: + resources: + requests: + cpu: "${cpu}m" + memory: "${memoryRequest}" + limits: + cpu: "${cpu}m" + memory: "${memoryRequest}" + configuration: + introspectorJobActiveDeadlineSeconds: ${constIntrospectorJobActiveDeadlineSeconds} + restartVersion: "${restartVersion}" +EOF + echo_stdout "New resrouces configurations: " + echo_stdout $(cat patch-resource-limits.yaml) + # patch the domain with resource limits + kubectl -n ${wlsDomainNS} patch domain ${WLS_DOMAIN_UID} \ + --type=merge \ + --patch "$(cat patch-resource-limits.yaml)" + + # make sure all of the pods are running correctly. + replicas=$(kubectl -n ${wlsDomainNS} get domain ${WLS_DOMAIN_UID} -o json | + jq '. | .spec.clusters[] | .replicas') + # pod provision will be slower as the resources is limited, set larger max attemp. + maxAttemps=$((checkPodStatusMaxAttemps * 2)) + interval=$((checkPodStatusInterval * 2)) + + utility_wait_for_pod_restarted \ + ${timestampBeforePatchingDomain} \ + ${replicas} \ + "${WLS_DOMAIN_UID}" \ + ${maxAttemps} \ + ${interval} + + qualityofService="Guaranteed" +fi + +# output the WebLogic Server version and quality of service. +result=$(jq -n -c \ + --arg wlsVersion "$version" \ + --arg qualityofService "$qualityofService" \ + '{wlsVersion: $wlsVersion, qualityofService: $qualityofService}') +echo "result is: $result" +echo $result >$AZ_SCRIPTS_OUTPUT_PATH diff --git a/weblogic-azure-aks/src/main/arm/scripts/common.sh b/weblogic-azure-aks/src/main/arm/scripts/common.sh index 1a3195109..5dcb9b456 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/common.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/common.sh @@ -10,8 +10,10 @@ export constAdminServerName='admin-server' export constClusterName='cluster-1' export constClusterT3AddressEnvName="T3_TUNNELING_CLUSTER_ADDRESS" export constDefaultJavaOptions="-Dlog4j2.formatMsgNoLookups=true -Dweblogic.StdoutDebugEnabled=false" # the java options will be applied to the cluster +export constDefaultJVMArgs="-Djava.security.egd=file:/dev/./urandom -XX:MinRAMPercentage=25.0 -XX:MaxRAMPercentage=50.0 " # the JVM options will be applied to the cluster export constFalse="false" export constTrue="true" +export constIntrospectorJobActiveDeadlineSeconds=300 # for Guaranteed Qos export curlMaxTime=120 # seconds export ocrLoginServer="container-registry.oracle.com" diff --git a/weblogic-azure-aks/src/main/arm/scripts/genDomainConfig.sh b/weblogic-azure-aks/src/main/arm/scripts/genDomainConfig.sh index c0ce95bcf..f237fb504 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/genDomainConfig.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/genDomainConfig.sh @@ -90,7 +90,7 @@ spec: - name: JAVA_OPTIONS value: "${constDefaultJavaOptions} ${javaOptions}" - name: USER_MEM_ARGS - value: "-Djava.security.egd=file:/dev/./urandom -Xms256m -Xmx512m -XX:MinRAMPercentage=25.0 -XX:MaxRAMPercentage=50.0 " + value: "${constDefaultJVMArgs}" - name: MANAGED_SERVER_PREFIX value: "${wlsManagedPrefix}" EOF diff --git a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep index 635814a28..321e6dd24 100644 --- a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep +++ b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep @@ -646,6 +646,27 @@ module datasourceDeployment 'modules/_setupDBConnection.bicep' = if (enableDB) { ] } +/* +* Apply resource limits to WebLogic Server 14c. +* The script will check the WebLogic Server version, and apply resource limits to 14c. +* The resource limits will be the same with requests. +*/ +module applyGuaranteedQos 'modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep' = { + name: 'apply-resources-limits-to-wls14' + params:{ + _artifactsLocation: _artifactsLocation + _artifactsLocationSasToken: _artifactsLocationSasToken + aksClusterRGName: ref_wlsDomainDeployment.outputs.aksClusterRGName.value + aksClusterName: ref_wlsDomainDeployment.outputs.aksClusterName.value + identity: identity + location: location + wlsDomainUID: wlsDomainUID + } + dependsOn: [ + datasourceDeployment + ] +} + /* * To check if all the applciations in WLS cluster become ACTIVE state after all configurations are completed. * This should be the last step. @@ -664,7 +685,7 @@ module validateApplciations 'modules/_deployment-scripts/_ds-validate-applicatio wlsUserName: wlsUserName } dependsOn: [ - datasourceDeployment + applyGuaranteedQos ] } diff --git a/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep b/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep new file mode 100644 index 000000000..4484062ad --- /dev/null +++ b/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep @@ -0,0 +1,62 @@ +// Copyright (c) 2021, Oracle Corporation and/or its affiliates. +// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +/* This script is to apply Guaranteed Qos by specifying resources.limits +* To solve pod evicted issue in Oracle WebLogic 14c. +* The script will promote CPU request and limit to 500m if the CPU request is less than 500m. +*/ + +param _artifactsLocation string = deployment().properties.templateLink.uri +@secure() +param _artifactsLocationSasToken string = '' + +param aksClusterName string = '' +param aksClusterRGName string = '' + +param identity object +param location string +param utcValue string = utcNow() + +param wlsDomainUID string = 'sample-domain1' + +var const_azcliVersion = '2.15.0' +var const_constScript = 'common.sh' +var const_deploymentName = 'ds-apply-guaranteed-qos' +var const_scriptLocation = uri(_artifactsLocation, 'scripts/') +var const_updateQosScript = 'applyGuaranteedQos.sh' +var const_utilityScript = 'utility.sh' + +resource deploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01' = { + name: const_deploymentName + location: location + kind: 'AzureCLI' + identity: identity + properties: { + azCliVersion: const_azcliVersion + environmentVariables: [ + { + name: 'AKS_CLUSTER_NAME' + value: aksClusterName + } + { + name: 'AKS_CLUSTER_RESOURCEGROUP_NAME' + value: aksClusterRGName + } + { + name: 'WLS_DOMAIN_UID' + value: wlsDomainUID + } + ] + primaryScriptUri: uri(const_scriptLocation, '${const_updateQosScript}${_artifactsLocationSasToken}') + supportingScriptUris: [ + uri(const_scriptLocation, '${const_constScript}${_artifactsLocationSasToken}') + uri(const_scriptLocation, '${const_utilityScript}${_artifactsLocationSasToken}') + ] + cleanupPreference: 'OnSuccess' + retentionInterval: 'P1D' + forceUpdateTag: utcValue + } +} + +output wlsVersion string = string(reference(const_deploymentName).outputs.wlsVersion) +output qualityofService string = string(reference(const_deploymentName).outputs.qualityofService) From 7dad2138f0ed9a798adc9a4af8387a1bcd5f74f1 Mon Sep 17 00:00:00 2001 From: galiacheng Date: Tue, 28 Dec 2021 11:14:28 +0800 Subject: [PATCH 2/9] increase pom version to 1.0.30 Signed-off-by: galiacheng Changes to be committed: modified: weblogic-azure-aks/pom.xml --- weblogic-azure-aks/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weblogic-azure-aks/pom.xml b/weblogic-azure-aks/pom.xml index c8776f770..bc99701b7 100644 --- a/weblogic-azure-aks/pom.xml +++ b/weblogic-azure-aks/pom.xml @@ -17,7 +17,7 @@ com.oracle.weblogic.azure wls-on-aks-azure-marketplace - 1.0.29 + 1.0.30 com.microsoft.azure.iaas From 55233475d88f3c69d71c09e7bb07a79c49c8fc0b Mon Sep 17 00:00:00 2001 From: galiacheng Date: Fri, 31 Dec 2021 16:54:20 +0800 Subject: [PATCH 3/9] get version with "java weblogic.version" Signed-off-by: galiacheng --- .../main/arm/scripts/applyGuaranteedQos.sh | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh b/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh index 44f2e31c5..0c3d6d73c 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh @@ -14,18 +14,18 @@ source ${scriptDir}/common.sh source ${scriptDir}/utility.sh qualityofService="BestEffort" -wlsContainerName="weblogic-server" wlsDomainNS="${WLS_DOMAIN_UID}-ns" echo_stdout "install kubectl" install_kubectl -echo_stdout "Connect AKS" +echo_stdout "Connect to AKS" az aks get-credentials \ --resource-group ${AKS_CLUSTER_RESOURCEGROUP_NAME} \ --name ${AKS_CLUSTER_NAME} \ --overwrite-existing +# get name of the running admin pod adminPodName=$(kubectl -n ${wlsDomainNS} get pod -l weblogic.serverName=admin-server -o json | jq '.items[0] | .metadata.name' | tr -d "\"") @@ -34,27 +34,23 @@ if [ -z "${adminPodName}" ]; then exit 1 fi -wlstQueryVersionScript=queryVersion.py -cat <${wlstQueryVersionScript} -print '#version#:' + version -EOF - -echo_stdout "copy WLST script ${wlstQueryVersionScript} to ${adminPodName}:/tmp/${wlstQueryVersionScript}" -targetPyFilePath=/tmp/${wlstQueryVersionScript} -kubectl cp ${wlstQueryVersionScript} -n ${wlsDomainNS} ${adminPodName}:${targetPyFilePath} -version=$(kubectl exec -it ${adminPodName} -n ${wlsDomainNS} -c ${wlsContainerName} -- bash -c "wlst.sh ${targetPyFilePath}") -# output sample: -# Initializing WebLogic Scripting Tool (WLST) ... - -# Welcome to WebLogic Server Administration Scripting Shell +# run `source $ORACLE_HOME/wlserver/server/bin/setWLSEnv.sh > /dev/null 2>&1 && java weblogic.version` to get the version. +# the command will print three lines, with WLS version in the first line. +# use `grep "WebLogic Server" to get the first line. -# Type help() for help on available commands +# $ source $ORACLE_HOME/wlserver/server/bin/setWLSEnv.sh > /dev/null 2>&1 && java weblogic.version +# WebLogic Server 12.2.1.4.0 Thu Sep 12 04:04:29 GMT 2019 1974621 +# Use 'weblogic.version -verbose' to get subsystem information +# Use 'weblogic.utils.Versions' to get version information for all modules +rawOutput=$(kubectl exec -it ${adminPodName} -n ${wlsDomainNS} -c ${wlsContainerName} \ + -- bash -c 'source $ORACLE_HOME/wlserver/server/bin/setWLSEnv.sh > /dev/null 2>&1 && java weblogic.version | grep "WebLogic Server"')) -# #version#:WebLogic Server 14.1.1.0.0 -version="${version##*\#version\#\:}" # match #version#:, this is a special mark for the version output, please do not change it. -echo_stdout ${version} +# get version from string like "WebLogic Server 12.2.1.4.0 Thu Sep 12 04:04:29 GMT 2019 1974621" +stringArray=($rawOutput) +version=${stringArray[2]} +echo_stdout "WebLogic Server version: ${version}" -if [ "${version#*WebLogic Server 14.1.1.0}" != "$version" ]; then +if [ "${version#*14.1.1.0}" != "$version" ]; then timestampBeforePatchingDomain=$(date +%s) echo "timestampBeforePatchingDomain=${timestampBeforePatchingDomain}" From d84b00c657fa2afe0a51293d74420dd987f1e2f7 Mon Sep 17 00:00:00 2001 From: galiacheng Date: Fri, 31 Dec 2021 17:00:28 +0800 Subject: [PATCH 4/9] typos Signed-off-by: galiacheng --- weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh b/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh index 0c3d6d73c..cbec8fd8a 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh @@ -100,7 +100,7 @@ spec: introspectorJobActiveDeadlineSeconds: ${constIntrospectorJobActiveDeadlineSeconds} restartVersion: "${restartVersion}" EOF - echo_stdout "New resrouces configurations: " + echo_stdout "New resource configurations: " echo_stdout $(cat patch-resource-limits.yaml) # patch the domain with resource limits kubectl -n ${wlsDomainNS} patch domain ${WLS_DOMAIN_UID} \ @@ -110,7 +110,7 @@ EOF # make sure all of the pods are running correctly. replicas=$(kubectl -n ${wlsDomainNS} get domain ${WLS_DOMAIN_UID} -o json | jq '. | .spec.clusters[] | .replicas') - # pod provision will be slower as the resources is limited, set larger max attemp. + # pod provision will be slower, set larger max attemp. maxAttemps=$((checkPodStatusMaxAttemps * 2)) interval=$((checkPodStatusInterval * 2)) From 4f37b4d1a151a7b207caadd8ec5c3aa4c42a24b7 Mon Sep 17 00:00:00 2001 From: galiacheng Date: Fri, 31 Dec 2021 17:16:01 +0800 Subject: [PATCH 5/9] use exact version 14.1.1.0 in comment that has 14c. Signed-off-by: galiacheng --- weblogic-azure-aks/src/main/bicep/mainTemplate.bicep | 4 ++-- .../_deployment-scripts/_ds-apply-guaranteed-qos.bicep | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep index 321e6dd24..4d3365f8c 100644 --- a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep +++ b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep @@ -647,8 +647,8 @@ module datasourceDeployment 'modules/_setupDBConnection.bicep' = if (enableDB) { } /* -* Apply resource limits to WebLogic Server 14c. -* The script will check the WebLogic Server version, and apply resource limits to 14c. +* Apply resource limits to WebLogic Server 14.1.1.0. +* The script will check the WebLogic Server version, and apply resource limits to 14.1.1.0. * The resource limits will be the same with requests. */ module applyGuaranteedQos 'modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep' = { diff --git a/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep b/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep index 4484062ad..92cf04be6 100644 --- a/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep +++ b/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep @@ -2,7 +2,7 @@ // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. /* This script is to apply Guaranteed Qos by specifying resources.limits -* To solve pod evicted issue in Oracle WebLogic 14c. +* To solve pod evicted issue in Oracle WebLogic 14.1.1.0. * The script will promote CPU request and limit to 500m if the CPU request is less than 500m. */ From a399318209e9b9ab6a187e1aee4e0dfbde784760 Mon Sep 17 00:00:00 2001 From: Galia Cheng Date: Fri, 31 Dec 2021 18:31:01 +0800 Subject: [PATCH 6/9] fix syntax error near unexpected token `)' --- weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh b/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh index cbec8fd8a..46d9c20e2 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh @@ -43,7 +43,7 @@ fi # Use 'weblogic.version -verbose' to get subsystem information # Use 'weblogic.utils.Versions' to get version information for all modules rawOutput=$(kubectl exec -it ${adminPodName} -n ${wlsDomainNS} -c ${wlsContainerName} \ - -- bash -c 'source $ORACLE_HOME/wlserver/server/bin/setWLSEnv.sh > /dev/null 2>&1 && java weblogic.version | grep "WebLogic Server"')) + -- bash -c 'source $ORACLE_HOME/wlserver/server/bin/setWLSEnv.sh > /dev/null 2>&1 && java weblogic.version | grep "WebLogic Server"') # get version from string like "WebLogic Server 12.2.1.4.0 Thu Sep 12 04:04:29 GMT 2019 1974621" stringArray=($rawOutput) From aee82e18868fb98d0ea01e6fabc395b842c5fa13 Mon Sep 17 00:00:00 2001 From: galiacheng Date: Thu, 6 Jan 2022 09:12:30 +0800 Subject: [PATCH 7/9] apply Ed's comments. Signed-off-by: galiacheng --- weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh | 1 + weblogic-azure-aks/src/main/bicep/mainTemplate.bicep | 1 + 2 files changed, 2 insertions(+) diff --git a/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh b/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh index cbec8fd8a..2ef303dc9 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh @@ -2,6 +2,7 @@ # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. # This script runs on Azure Container Instance with Alpine Linux that Azure Deployment script creates. # +# Temporary workaround for https://github.com/oracle/weblogic-kubernetes-operator/issues/2693 # env inputs: # AKS_CLUSTER_NAME # AKS_CLUSTER_RESOURCEGROUP_NAME diff --git a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep index 4d3365f8c..21af4227a 100644 --- a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep +++ b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep @@ -647,6 +647,7 @@ module datasourceDeployment 'modules/_setupDBConnection.bicep' = if (enableDB) { } /* +* Temporary workaround for https://github.com/oracle/weblogic-kubernetes-operator/issues/2693 * Apply resource limits to WebLogic Server 14.1.1.0. * The script will check the WebLogic Server version, and apply resource limits to 14.1.1.0. * The resource limits will be the same with requests. From 8cd232dc63cb50167a18752f75ba5aad6201912c Mon Sep 17 00:00:00 2001 From: galiacheng Date: Thu, 6 Jan 2022 09:24:53 +0800 Subject: [PATCH 8/9] fix the default jvm memory args for lower version by specifying -Xms256m -Xmx512m. Signed-off-by: galiacheng --- weblogic-azure-aks/src/main/arm/scripts/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weblogic-azure-aks/src/main/arm/scripts/common.sh b/weblogic-azure-aks/src/main/arm/scripts/common.sh index 5dcb9b456..6313b353a 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/common.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/common.sh @@ -10,7 +10,7 @@ export constAdminServerName='admin-server' export constClusterName='cluster-1' export constClusterT3AddressEnvName="T3_TUNNELING_CLUSTER_ADDRESS" export constDefaultJavaOptions="-Dlog4j2.formatMsgNoLookups=true -Dweblogic.StdoutDebugEnabled=false" # the java options will be applied to the cluster -export constDefaultJVMArgs="-Djava.security.egd=file:/dev/./urandom -XX:MinRAMPercentage=25.0 -XX:MaxRAMPercentage=50.0 " # the JVM options will be applied to the cluster +export constDefaultJVMArgs="-Djava.security.egd=file:/dev/./urandom -Xms256m -Xmx512m -XX:MinRAMPercentage=25.0 -XX:MaxRAMPercentage=50.0 " # the JVM options will be applied to the cluster export constFalse="false" export constTrue="true" export constIntrospectorJobActiveDeadlineSeconds=300 # for Guaranteed Qos From 0082b2652134b1c672e22c25d9b9d06ff21a5040 Mon Sep 17 00:00:00 2001 From: galiacheng Date: Fri, 7 Jan 2022 13:50:38 +0800 Subject: [PATCH 9/9] query the wls version in managed server pod. Signed-off-by: galiacheng Changes to be committed: modified: weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh modified: weblogic-azure-aks/src/main/bicep/mainTemplate.bicep modified: weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep --- .../main/arm/scripts/applyGuaranteedQos.sh | 21 +++++++++++-------- .../src/main/bicep/mainTemplate.bicep | 2 ++ .../_ds-apply-guaranteed-qos.bicep | 6 +++++- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh b/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh index 97b181121..7ec4a929d 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/applyGuaranteedQos.sh @@ -6,6 +6,7 @@ # env inputs: # AKS_CLUSTER_NAME # AKS_CLUSTER_RESOURCEGROUP_NAME +# WLS_CLUSTER_NAME # WLS_DOMAIN_UID # Main script @@ -26,14 +27,16 @@ az aks get-credentials \ --name ${AKS_CLUSTER_NAME} \ --overwrite-existing -# get name of the running admin pod -adminPodName=$(kubectl -n ${wlsDomainNS} get pod -l weblogic.serverName=admin-server -o json | - jq '.items[0] | .metadata.name' | - tr -d "\"") -if [ -z "${adminPodName}" ]; then - echo_stderr "Fail to get admin server pod." - exit 1 -fi +# we should not run the script in admin pod, as there is no admin pod for slim image. +podNum=$(kubectl -n ${wlsDomainNS} get pod -l weblogic.clusterName=${WLS_CLUSTER_NAME} -o json | jq '.items| length') + if [ ${podNum} -le 0 ]; then + echo_stderr "Ensure your cluster has at least one pod." + exit 1 + fi + +podName=$(kubectl -n ${wlsDomainNS} get pod -l weblogic.clusterName=${WLS_CLUSTER_NAME} -o json \ + | jq '.items[0] | .metadata.name' \ + | tr -d "\"") # run `source $ORACLE_HOME/wlserver/server/bin/setWLSEnv.sh > /dev/null 2>&1 && java weblogic.version` to get the version. # the command will print three lines, with WLS version in the first line. @@ -43,7 +46,7 @@ fi # WebLogic Server 12.2.1.4.0 Thu Sep 12 04:04:29 GMT 2019 1974621 # Use 'weblogic.version -verbose' to get subsystem information # Use 'weblogic.utils.Versions' to get version information for all modules -rawOutput=$(kubectl exec -it ${adminPodName} -n ${wlsDomainNS} -c ${wlsContainerName} \ +rawOutput=$(kubectl exec -it ${podName} -n ${wlsDomainNS} -c ${wlsContainerName} \ -- bash -c 'source $ORACLE_HOME/wlserver/server/bin/setWLSEnv.sh > /dev/null 2>&1 && java weblogic.version | grep "WebLogic Server"') # get version from string like "WebLogic Server 12.2.1.4.0 Thu Sep 12 04:04:29 GMT 2019 1974621" diff --git a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep index 21af4227a..3ceae2100 100644 --- a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep +++ b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep @@ -276,6 +276,7 @@ var const_hasStorageAccount = !createAKSCluster && reference('query-existing-sto var const_identityKeyStoreType = (sslConfigurationAccessOption == const_wlsSSLCertOptionKeyVault) ? sslKeyVaultCustomIdentityKeyStoreType : sslUploadedCustomIdentityKeyStoreType var const_keyvaultNameFromTag = const_hasTags && contains(resourceGroup().tags, name_tagNameForKeyVault) ? resourceGroup().tags.wlsKeyVault : '' var const_trustKeyStoreType = (sslConfigurationAccessOption == const_wlsSSLCertOptionKeyVault) ? sslKeyVaultCustomTrustKeyStoreType : sslUploadedCustomTrustKeyStoreType +var const_wlsClusterName = 'cluster-1' var const_wlsJavaOptions = wlsJavaOption == '' ? 'null' : wlsJavaOption var const_wlsSSLCertOptionKeyVault = 'keyVaultStoredConfig' var name_defaultPidDeployment = 'pid' @@ -661,6 +662,7 @@ module applyGuaranteedQos 'modules/_deployment-scripts/_ds-apply-guaranteed-qos. aksClusterName: ref_wlsDomainDeployment.outputs.aksClusterName.value identity: identity location: location + wlsClusterName: const_wlsClusterName wlsDomainUID: wlsDomainUID } dependsOn: [ diff --git a/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep b/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep index 92cf04be6..dd898df44 100644 --- a/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep +++ b/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-apply-guaranteed-qos.bicep @@ -16,7 +16,7 @@ param aksClusterRGName string = '' param identity object param location string param utcValue string = utcNow() - +param wlsClusterName string = 'cluster-1' param wlsDomainUID string = 'sample-domain1' var const_azcliVersion = '2.15.0' @@ -42,6 +42,10 @@ resource deploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01' = { name: 'AKS_CLUSTER_RESOURCEGROUP_NAME' value: aksClusterRGName } + { + name: 'WLS_CLUSTER_NAME' + value: wlsClusterName + } { name: 'WLS_DOMAIN_UID' value: wlsDomainUID