Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add java memory arguments #8115

Merged
merged 6 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions charts/janssen/charts/auth-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ Create user custom defined secret envs
{{- end }}
{{- end }}

{{/*
Create JAVA_OPTIONS ENV for passing custom work and detailed logs
*/}}
{{- define "auth-server.customJavaOptions"}}
{{ $custom := "" }}
{{- $cnCustomJavaOptions := index .Values.global "auth-server" "cnCustomJavaOptions" }}
{{- $custom := printf "%s" $cnCustomJavaOptions }}
{{ $memory := .Values.resources.limits.memory | replace "Mi" "" | int -}}
{{- $maxDirectMemory := printf "-XX:MaxDirectMemorySize=%dm" $memory -}}
{{- $xmx := printf "-Xmx%dm" (sub $memory 300) -}}
{{- $customJavaOptions := printf "%s %s" $maxDirectMemory $xmx -}}
{{ $customJavaOptions | trimSuffix " " | quote }}
iromli marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If cnCustomJavaOptions is set to empty string, the generated YAML would be:

- name: CN_AUTH_JAVA_OPTIONS
  value: " -XX:MaxDirectMemorySize=2500m -Xmx2200m"

Notice the leading whitespace.

It's better to use trim instead of trimSuffix to remove leading and trailing whitespaces.

{{- end }}

{{/*
Create topologySpreadConstraints lists
*/}}
Expand Down
2 changes: 2 additions & 0 deletions charts/janssen/charts/auth-server/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
env:
- name: CN_AUTH_JAVA_OPTIONS
value: {{ include "auth-server.customJavaOptions" . | trim }}
{{- include "auth-server.usr-envs" . | indent 12 }}
{{- include "auth-server.usr-secret-envs" . | indent 12 }}
securityContext:
Expand Down
13 changes: 13 additions & 0 deletions charts/janssen/charts/casa/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ Create user custom defined secret envs
{{- end }}
{{- end }}

{{/*
Create JAVA_OPTIONS ENV for passing custom work and detailed logs
*/}}
{{- define "casa.customJavaOptions"}}
{{ $custom := "" }}
{{ $custom = printf "%s" .Values.global.casa.cnCustomJavaOptions }}
{{ $memory := .Values.resources.limits.memory | replace "Mi" "" | int -}}
{{- $maxDirectMemory := printf "-XX:MaxDirectMemorySize=%dm" $memory -}}
{{- $xmx := printf "-Xmx%dm" (sub $memory 300) -}}
{{- $customJavaOptions := printf "%s %s" $maxDirectMemory $xmx -}}
{{ $customJavaOptions | trimSuffix " " | quote }}
{{- end }}

{{/*
Create topologySpreadConstraints lists
*/}}
Expand Down
2 changes: 2 additions & 0 deletions charts/janssen/charts/casa/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
env:
- name: CN_CASA_JAVA_OPTIONS
value: {{ include "casa.customJavaOptions" . | trim }}
{{- include "casa.usr-envs" . | indent 12 }}
{{- include "casa.usr-secret-envs" . | indent 12 }}
{{- if or (eq .Values.global.storageClass.provisioner "kubernetes.io/aws-ebs") (eq .Values.global.storageClass.provisioner "openebs.io/local") ( .Values.customScripts) }}
Expand Down
14 changes: 14 additions & 0 deletions charts/janssen/charts/config-api/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ Create user custom defined secret envs
{{- end }}
{{- end }}

{{/*
Create JAVA_OPTIONS ENV for passing custom work and detailed logs
*/}}
{{- define "config-api.customJavaOptions"}}
{{ $custom := "" }}
{{- $cnCustomJavaOptions := index .Values.global "config-api" "cnCustomJavaOptions" }}
{{- $custom := printf "%s" $cnCustomJavaOptions }}
{{ $memory := .Values.resources.limits.memory | replace "Mi" "" | int -}}
{{- $maxDirectMemory := printf "-XX:MaxDirectMemorySize=%dm" $memory -}}
{{- $xmx := printf "-Xmx%dm" (sub $memory 300) -}}
{{- $customJavaOptions := printf "%s %s" $maxDirectMemory $xmx -}}
{{ $customJavaOptions | trimSuffix " " | quote }}
{{- end }}

{{/*
Create topologySpreadConstraints lists
*/}}
Expand Down
2 changes: 2 additions & 0 deletions charts/janssen/charts/config-api/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ spec:
- name: {{ include "config-api.name" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
env:
- name: CN_CONFIG_API_JAVA_OPTIONS
value: {{ include "config-api.customJavaOptions" . | trim }}
{{- include "config-api.usr-envs" . | indent 12 }}
{{- include "config-api.usr-secret-envs" . | indent 12 }}
securityContext:
Expand Down
13 changes: 13 additions & 0 deletions charts/janssen/charts/fido2/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ Create user custom defined secret envs
{{- end }}
{{- end }}

{{/*
Create JAVA_OPTIONS ENV for passing custom work and detailed logs
*/}}
{{- define "fido2.customJavaOptions"}}
{{ $custom := "" }}
{{ $custom = printf "%s" .Values.global.fido2.cnCustomJavaOptions }}
{{ $memory := .Values.resources.limits.memory | replace "Mi" "" | int -}}
{{- $maxDirectMemory := printf "-XX:MaxDirectMemorySize=%dm" $memory -}}
{{- $xmx := printf "-Xmx%dm" (sub $memory 300) -}}
{{- $customJavaOptions := printf "%s %s" $maxDirectMemory $xmx -}}
{{ $customJavaOptions | trimSuffix " " | quote }}
{{- end }}

{{/*
Create topologySpreadConstraints lists
*/}}
Expand Down
2 changes: 2 additions & 0 deletions charts/janssen/charts/fido2/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ spec:
runAsUser: 1000
runAsNonRoot: true
env:
- name: CN_FIDO2_JAVA_OPTIONS
value: {{ include "fido2.customJavaOptions" . | trim }}
{{- include "fido2.usr-envs" . | indent 12 }}
{{- include "fido2.usr-secret-envs" . | indent 12 }}
{{- if or (eq .Values.global.storageClass.provisioner "kubernetes.io/aws-ebs") (eq .Values.global.storageClass.provisioner "openebs.io/local") ( .Values.customScripts) }}
Expand Down
13 changes: 13 additions & 0 deletions charts/janssen/charts/link/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ Create user custom defined secret envs
{{- end }}
{{- end }}

{{/*
Create JAVA_OPTIONS ENV for passing custom work and detailed logs
*/}}
{{- define "link.customJavaOptions"}}
{{ $custom := "" }}
{{ $custom = printf "%s" .Values.global.link.cnCustomJavaOptions }}
{{ $memory := .Values.resources.limits.memory | replace "Mi" "" | int -}}
{{- $maxDirectMemory := printf "-XX:MaxDirectMemorySize=%dm" $memory -}}
{{- $xmx := printf "-Xmx%dm" (sub $memory 300) -}}
{{- $customJavaOptions := printf "%s %s" $maxDirectMemory $xmx -}}
{{ $customJavaOptions | trimSuffix " " | quote }}
{{- end }}

{{/*
Create topologySpreadConstraints lists
*/}}
Expand Down
2 changes: 2 additions & 0 deletions charts/janssen/charts/link/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ spec:
- name: {{ include "link.name" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
env:
- name: CN_LINK_JAVA_OPTIONS
value: {{ include "link.customJavaOptions" . | trim }}
{{- include "link.usr-envs" . | indent 12 }}
{{- include "link.usr-secret-envs" . | indent 12 }}
securityContext:
Expand Down
13 changes: 13 additions & 0 deletions charts/janssen/charts/saml/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ Create user custom defined secret envs
{{- end }}
{{- end }}

{{/*
Create JAVA_OPTIONS ENV for passing custom work and detailed logs
*/}}
{{- define "saml.customJavaOptions"}}
{{ $custom := "" }}
{{ $custom = printf "%s" .Values.global.saml.cnCustomJavaOptions }}
{{ $memory := .Values.resources.limits.memory | replace "Mi" "" | int -}}
{{- $maxDirectMemory := printf "-XX:MaxDirectMemorySize=%dm" $memory -}}
{{- $xmx := printf "-Xmx%dm" (sub $memory 300) -}}
{{- $customJavaOptions := printf "%s %s" $maxDirectMemory $xmx -}}
{{ $customJavaOptions | trimSuffix " " | quote }}
{{- end }}

{{/*
Create topologySpreadConstraints lists
*/}}
Expand Down
2 changes: 2 additions & 0 deletions charts/janssen/charts/saml/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
env:
- name: CN_SAML_JAVA_OPTIONS
value: {{ include "saml.customJavaOptions" . | trim }}
{{- include "saml.usr-envs" . | indent 12 }}
{{- include "saml.usr-secret-envs" . | indent 12 }}
{{- if or (eq .Values.global.storageClass.provisioner "kubernetes.io/aws-ebs") (eq .Values.global.storageClass.provisioner "openebs.io/local") ( .Values.customScripts) }}
Expand Down
13 changes: 13 additions & 0 deletions charts/janssen/charts/scim/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ Create user custom defined secret envs
{{- end }}
{{- end }}

{{/*
Create JAVA_OPTIONS ENV for passing custom work and detailed logs
*/}}
{{- define "scim.customJavaOptions"}}
{{ $custom := "" }}
{{ $custom = printf "%s" .Values.global.scim.cnCustomJavaOptions }}
{{ $memory := .Values.resources.limits.memory | replace "Mi" "" | int -}}
{{- $maxDirectMemory := printf "-XX:MaxDirectMemorySize=%dm" $memory -}}
{{- $xmx := printf "-Xmx%dm" (sub $memory 300) -}}
{{- $customJavaOptions := printf "%s %s" $maxDirectMemory $xmx -}}
{{ $customJavaOptions | trimSuffix " " | quote }}
{{- end }}

{{/*
Create topologySpreadConstraints lists
*/}}
Expand Down
2 changes: 2 additions & 0 deletions charts/janssen/charts/scim/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ spec:
runAsUser: 1000
runAsNonRoot: true
env:
- name: CN_SCIM_JAVA_OPTIONS
value: {{ include "scim.customJavaOptions" . | trim }}
{{- include "scim.usr-envs" . | indent 12 }}
{{- include "scim.usr-secret-envs" . | indent 12 }}
{{- if or (eq .Values.global.storageClass.provisioner "kubernetes.io/aws-ebs") (eq .Values.global.storageClass.provisioner "openebs.io/local") ( .Values.customScripts) }}
Expand Down
15 changes: 14 additions & 1 deletion charts/janssen/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,8 @@ global:
authServerServiceName: auth-server
# -- Boolean flag to enable/disable auth-server chart. You should never set this to false.
enabled: true
# -- passing custom java options to auth-server. Notice you do not need to pass in any loggers optoins as they are introduced below in appLoggers. DO NOT PASS JAVA_OPTIONS in envs.
cnCustomJavaOptions: ""
# -- App loggers can be configured to define where the logs will be redirected to and the level of each in which it should be displayed.
appLoggers:
# -- Enable log prefixing which enables prepending the STDOUT logs with the file name. i.e auth-server-script ===> 2022-12-20 17:49:55,744 INFO
Expand Down Expand Up @@ -799,6 +801,8 @@ global:
# -- Azure storage kind if using Azure disks
azureStorageKind: Managed
casa:
# -- passing custom java options to casa. Notice you do not need to pass in any loggers optoins as they are introduced below in appLoggers. DO NOT PASS JAVA_OPTIONS in envs.
cnCustomJavaOptions: ""
# -- App loggers can be configured to define where the logs will be redirected to and the level of each in which it should be displayed.
appLoggers:
# -- Enable log prefixing which enables prepending the STDOUT logs with the file name. i.e casa ===> 2022-12-20 17:49:55,744 INFO
Expand Down Expand Up @@ -850,6 +854,8 @@ global:
configApiServerServiceName: config-api
# -- Boolean flag to enable/disable the config-api chart.
enabled: true
# -- passing custom java options to config-api. Notice you do not need to pass in any loggers optoins as they are introduced below in appLoggers. DO NOT PASS JAVA_OPTIONS in envs.
cnCustomJavaOptions: ""
# -- App loggers can be configured to define where the logs will be redirected to and the level of each in which it should be displayed.
appLoggers:
# -- Enable log prefixing which enables prepending the STDOUT logs with the file name. i.e config-api_persistence ===> 2022-12-20 17:49:55,744 INFO
Expand Down Expand Up @@ -887,6 +893,8 @@ global:
fido2ServiceName: fido2
# -- Boolean flag to enable/disable the fido2 chart.
enabled: true
# -- passing custom java options to fido2. Notice you do not need to pass in any loggers optoins as they are introduced below in appLoggers. DO NOT PASS JAVA_OPTIONS in envs.
iromli marked this conversation as resolved.
Show resolved Hide resolved
cnCustomJavaOptions: ""
# -- App loggers can be configured to define where the logs will be redirected to and the level of each in which it should be displayed.
appLoggers:
# -- Enable log prefixing which enables prepending the STDOUT logs with the file name. i.e fido2 ===> 2022-12-20 17:49:55,744 INFO
Expand Down Expand Up @@ -948,6 +956,8 @@ global:
scimServiceName: scim
# -- Boolean flag to enable/disable the SCIM chart.
enabled: true
# -- passing custom java options to scim. Notice you do not need to pass in any loggers optoins as they are introduced below in appLoggers. DO NOT PASS JAVA_OPTIONS in envs.
cnCustomJavaOptions: ""
# -- App loggers can be configured to define where the logs will be redirected to and the level of each in which it should be displayed.
appLoggers:
# -- Enable log prefixing which enables prepending the STDOUT logs with the file name. i.e jans-scim ===> 2022-12-20 17:49:55,744 INFO
Expand Down Expand Up @@ -999,6 +1009,8 @@ global:
linkServiceName: link
# -- Boolean flag to enable/disable the link chart.
enabled: false
# -- passing custom java options to link. Notice you do not need to pass in any loggers optoins as they are introduced below in appLoggers. DO NOT PASS JAVA_OPTIONS in envs.
cnCustomJavaOptions: ""
# -- App loggers can be configured to define where the logs will be redirected to and the level of each in which it should be displayed.
appLoggers:
# -- Enable log prefixing which enables prepending the STDOUT logs with the file name. i.e link-persistence ===> 2022-12-20 17:49:55,744 INFO
Expand Down Expand Up @@ -1036,7 +1048,8 @@ global:
ingress:
# Enable saml endpoints /kc
samlEnabled: false

# -- passing custom java options to saml. DO NOT PASS JAVA_OPTIONS in envs.
cnCustomJavaOptions: ""
# -- Path to SQL password file
cnSqlPasswordFile: /etc/jans/conf/sql_password
# -- Path to Couchbase password file
Expand Down