Skip to content

Commit 3f6086b

Browse files
committed
add server pod resource requests and limits to samples
1 parent 939720f commit 3f6086b

File tree

4 files changed

+65
-2
lines changed

4 files changed

+65
-2
lines changed

kubernetes/samples/scripts/common/domain-template.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ spec:
4747
value: "%JAVA_OPTIONS%"
4848
- name: USER_MEM_ARGS
4949
value: "-XX:+UseContainerSupport -Djava.security.egd=file:/dev/./urandom "
50+
%OPTIONAL_SERVERPOD_RESOURCES%
5051
%LOG_HOME_ON_PV_PREFIX%volumes:
5152
%LOG_HOME_ON_PV_PREFIX%- name: weblogic-domain-storage-volume
5253
%LOG_HOME_ON_PV_PREFIX% persistentVolumeClaim:
@@ -79,4 +80,4 @@ spec:
7980
experimental:
8081
istio:
8182
enabled: %ISTIO_ENABLED%
82-
readinessPort: %ISTIO_READINESS_PORT%
83+
readinessPort: %ISTIO_READINESS_PORT%

kubernetes/samples/scripts/common/utility.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,42 @@ function getKubernetesClusterIP {
213213

214214
}
215215

216+
#
217+
# Function to set the serverPodResources variable for including into the generated
218+
# domain.yaml, base on the serverPod resource requests and limits input values,
219+
# if specified.
220+
# The serverPodResources variable remains unset if none of the input values are provided.
221+
#
222+
function buildServerPodResources {
223+
224+
if [ -n "${serverPodMemoryRequest}" ]; then
225+
local memoryRequest=" memory\: \"${serverPodMemoryRequest}\"\n"
226+
fi
227+
if [ -n "${serverPodCpuRequest}" ]; then
228+
local cpuRequest=" cpu\: \"${serverPodCpuRequest}\"\n"
229+
fi
230+
if [ -n "${memoryRequest}" ] || [ -n "${cpuRequest}" ]; then
231+
local requests=" requests\: \n$memoryRequest $cpuRequest"
232+
echo "requests is $requests"
233+
fi
234+
235+
if [ -n "${serverPodMemoryLimit}" ]; then
236+
local memoryLimit=" memory\: \"${serverPodMemoryLimit}\"\n"
237+
fi
238+
if [ -n "${serverPodCpuLimit}" ]; then
239+
local cpuLimit=" cpu\: \"${serverPodCpuLimit}\"\n"
240+
fi
241+
if [ -n "${memoryLimit}" ] || [ -n "${cpuLimit}" ]; then
242+
local limits=" limits\: \n$memoryLimit $cpuLimit"
243+
echo "limits is $limits"
244+
fi
245+
246+
if [ -n "${requests}" ] || [ -n "${limits}" ]; then
247+
# build resources element and remove last '\n'
248+
serverPodResources=$(echo "resources\:\n${requests}${limits}" | sed -e 's/\\n$//')
249+
fi
250+
}
251+
216252
#
217253
# Function to generate the properties and yaml files for creating a domain
218254
#
@@ -428,6 +464,13 @@ function createFiles {
428464
sed -i -e "s:%ISTIO_ENABLED%:${istioEnabled}:g" ${dcrOutput}
429465
sed -i -e "s:%ISTIO_READINESS_PORT%:${istioReadinessPort}:g" ${dcrOutput}
430466

467+
buildServerPodResources
468+
if [ -z "${serverPodResources}" ]; then
469+
sed -i -e "/%OPTIONAL_SERVERPOD_RESOURCES%/d" ${dcrOutput}
470+
else
471+
sed -i -e "s:%OPTIONAL_SERVERPOD_RESOURCES%:${serverPodResources}:g" ${dcrOutput}
472+
fi
473+
431474
if [ "${domainHomeInImage}" == "true" ]; then
432475

433476
# now we know which image to use, update the domain yaml file

kubernetes/samples/scripts/create-weblogic-domain/domain-home-in-image/create-domain-inputs.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,13 @@ domainHomeImageBase: container-registry.oracle.com/middleware/weblogic:12.2.1.3
134134
# Another possible value is "./docker-images/OracleWebLogic/samples/12213-domain-home-in-image-wdt",
135135
# which uses WDT, instead of WLST, to generate the domain configuration.
136136
domainHomeImageBuildPath: ./docker-images/OracleWebLogic/samples/12213-domain-home-in-image
137+
138+
# Uncomment and edit value(s) below to specify resource requests and limits of
139+
# each server pod. This is optional.
140+
# Please refer to the kubernetes documentation on meaning of the values.
141+
#
142+
# serverPodMemoryRequest: "64Mi"
143+
# serverPodCpuRequest: "250m"
144+
# serverPodMemoryLimit: "1Gi"
145+
# serverPodCpuLimit: "1000m"
146+

kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/create-domain-inputs.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,19 @@ createDomainScriptName: create-domain-job.sh
135135
# so that the Kubernetes pod can use the scripts and supporting files to create a domain home.
136136
createDomainFilesDir: wlst
137137

138+
# Uncomment and edit value(s) below to specify resource requests and limits of
139+
# each server pod. This is optional.
140+
# Please refer to the kubernetes documentation on meaning of the values.
141+
#
142+
# serverPodMemoryRequest: "64Mi"
143+
# serverPodCpuRequest: "250m"
144+
# serverPodMemoryLimit: "1Gi"
145+
# serverPodCpuLimit: "1000m"
146+
138147
# experimental
139148
# istioEnabled specifies whether or not it is deployed under Istio.
140149
istioEnabled: false
141150

142151
# experimental
143152
# istioReadinessPort specifies the WebLogic port for readiness probe which is used under Istio.
144-
istioReadinessPort: 8888
153+
istioReadinessPort: 8888

0 commit comments

Comments
 (0)