4. Application Configuration

This section covers how you can customize the deployment of your applications. You can use a number of deployer properties to influence settings for the applications that are deployed.

See KubernetesDeployerProperties for more of the supported options.

If you would like to override the default values for all apps that you deploy then you should modify the Spring Cloud Deployer for Kubernetes Properties for the server.

4.1 Memory and CPU Settings

The apps are deployed by default with the following "Limits" and "Requests" settings:

    Limits:
      cpu:	500m
      memory:	512Mi
    Requests:
      cpu:	500m
      memory:	512Mi

You might find that the 512Mi memory limit is too low and to increase it you can provide a common spring.cloud.deployer.memory deployer property like this (replace <app> with the name of the app you would like to set this for):

deployer.<app>.memory=640m

This property affects bot the Requests and Limits memory value set for the container.

If you would like to set the Requests and Limits values separately you would have to use the deployer properties that are specific to the Kubernetes deployer. To set the Limits to 1000m for cpu, 1024Mi for memory and Requests to 800m for cpu, 640Mi for memory you can use the following properties:

deployer.<app>.kubernetes.limits.cpu=1000m
deployer.<app>.kubernetes.limits.memory=1024Mi
deployer.<app>.kubernetes.requests.cpu=800m
deployer.<app>.kubernetes.requests.memory=640Mi

That should result in the following container settings being used:

    Limits:
      cpu:	1
      memory:	1Gi
    Requests:
      cpu:	800m
      memory:	640Mi
[Note]Note

When using the common memory property you should use and m suffix for the value while when using the Kubernetes specific properties you should use the Kubernetes Mi style suffix.

The settings we have used so far only affect the settings for the container, they do not affect the memory setting for the JVM process in the container. If you would like to set JVM memory settings you can provide an environment variable for this, see the next section for details.

4.2 Environment Variables

To influence the environment settings for a given app, you can take advantage of the spring.cloud.deployer.kubernetes.environmentVariables deployer property. For example, a common requirement in production settings is to influence the JVM memory arguments. This can be achieved by using the JAVA_TOOL_OPTIONS environment variable:

deployer.<app>.kubernetes.environmentVariables=JAVA_TOOL_OPTIONS=-Xmx1024m

This overrides the JVM memory setting for the desired <app> (just replace <app> with the name of your app).

4.3 Liveness and Readiness Probes

The liveness and readiness probes are using the paths \health and \info respectively. They use a delay of 10 for both and a period of 60 and 10 respectively. You can chage these defaults when you deploy by using deployer properties.

Here is an example changing the liveness probe (just replace <app> with the name of your app):

deployer.<app>.kubernetes.livenessProbePath=/info
deployer.<app>.kubernetes.livenessProbeDelay=120
deployer.<app>.kubernetes.livenessProbePeriod=20

Similarly, swap liveness for readiness to override the default readiness settings.