Jiří Locker
2020-03-11 52a3f345337fcf368ba8060bf274d4d97df35bfb
Set memory request and limit (#1302)

1 files modified
17 ■■■■■ changed files
ansible/roles/ocp-workload-optaweb-employee-rostering/tasks/workload.yml 17 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-optaweb-employee-rostering/tasks/workload.yml
@@ -20,12 +20,27 @@
  shell: "oc new-app --name employee-rostering \
      --strategy=docker \
      java:8~{{optaweb_git_repository}}#{{optaweb_git_branch}} \
      -e JAVA_TOOL_OPTIONS=\"-XX:InitialHeapSize=4g -XX:MaxHeapSize=8g\" \
      -e JAVA_TOOL_OPTIONS=\"-XX:InitialHeapSize=1g -XX:MaxHeapSize=4g\" \
      -n {{ocp_project}}"
- name: "Share PostgreSQL secret with OptaWeb app"
  shell: "oc set env dc/employee-rostering --from=secret/postgresql -n {{ocp_project}}"
# The memory limit needs to be higher than actual maximum JVM memory consumption.
# Recommendation: set the memory limit to MaxHeapSize + 1 GiB.
#
# If JVM memory consumption exceeds container memory limit, the JVM process will be killed by OOM killer.
# More info:
# - https://docs.openshift.com/container-platform/3.11/dev_guide/application_memory_sizing.html
# - https://docs.openshift.com/container-platform/3.11/dev_guide/compute_resources.html
# Also note that cluster has a Limit Range defining maximum resource limits containers/pods can ask.
# Verify the max memory limit at Administration > Limit Ranges before increasing the limit.
- name: "Set OptaWeb's resource requests and limits"
  shell: "oc set resources dc employee-rostering \
      --limits=cpu=2,memory=5Gi \
      --requests=cpu=1,memory=1Gi \
      -n {{ocp_project}}"
- name: "Expose the service"
  shell: "oc expose svc/employee-rostering -n {{ocp_project}}"