Am deploying springboot application in kubernets using Jib. When the service starting the memory usage is around 300MB but it grows up to 1.3gb over time. How to avoid this increase without any usage? The application is up and running. The API gateways are not open to user now still the memory is incrementing over time.
kubernets deployment configuration
# Source: services/charts/login/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: release-name
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: login
app.kubernetes.io/version: 1.16.0
name: login
spec:
selector:
matchLabels:
app.kubernetes.io/instance: release-name
app.kubernetes.io/name: login
template:
metadata:
labels:
app.kubernetes.io/instance: release-name
app.kubernetes.io/name: login
spec:
containers:
- env:
- name: APP_NAME
value: login-release-name
- name: JAVA_TOOL_OPTIONS
value: -Dspring.profiles.active=prod
image: dockerregistry.com/login:1.0.0
imagePullPolicy: Always
lifecycle:
preStop:
exec:
command:
- sh
- -c
- sleep 10
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 30
name: login
ports:
- containerPort: 8080
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 30
resources:
limits:
cpu: 2000m
memory: 1Gi
requests:
cpu: 100m
memory: 1Gi
imagePullSecrets:
- name: regcred
terminationGracePeriodSeconds: 60
spring boot configuration for kubernets
server.port=8080
server.shutdown=graceful
spring.lifecycle.timeout-per-shutdown-phase=45s
server.tomcat.accept-count=100
server.tomcat.max-connections=8000
server.tomcat.connection-timeout=10000
server.tomcat.max-threads=200
server.tomcat.min-spare-threads=10
spring.datasource.url=jdbc:postgresql://${DB_HOST:#{"postgres"}}/postgres
spring.datasource.username=${DB_USER:#{"postgres"}}
spring.datasource.password=${DB_PASSWORD:#{"na"}}
spring.datasource.type=org.springframework.jdbc.datasource.DriverManagerDataSource
spring.datasource.driver-class-name=org.postgresql.Driver
Do we need to configure anything to limit the memory usage to 1GB limit? Now the kubernets will kill the pod if it goes beyond 1GB.
am creating the image using the Jib.
mvn compile com.google.cloud.tools:jib-maven-plugin:3.3.0:dockerBuild -Dimage=login -DskipTests