66 lines
2.0 KiB
Jsonnet
66 lines
2.0 KiB
Jsonnet
local deployment_manifest = import 'deployment_manifest.jsonnet';
|
|
local port_map = import 'port_map.jsonnet';
|
|
local exposedPorts = deployment_manifest.deployment.exposedPorts;
|
|
|
|
|
|
local isMicrometerPrometheusEnabled = deployment_manifest.labels['micrometer-prometheus'] == 'enabled';
|
|
local error_message = 'Metrics port not specified with micrometer-prometheus enabled';
|
|
|
|
local defaultReadinessCheck = {
|
|
type: 'tcp',
|
|
port: 'serviceport',
|
|
path: '/actuator/health',
|
|
successThreshold: 1,
|
|
initialDelaySeconds: 60,
|
|
periodSeconds: 30,
|
|
failureThreshold: 5,
|
|
httpHeaders: [],
|
|
};
|
|
|
|
local defaultLivenessCheck = {
|
|
type: 'tcp',
|
|
port: 'serviceport',
|
|
path: '/actuator/health',
|
|
successThreshold: 1,
|
|
initialDelaySeconds: 60,
|
|
periodSeconds: 30,
|
|
failureThreshold: 5,
|
|
httpHeaders: [],
|
|
} + if isMicrometerPrometheusEnabled then { port: 'metrics', type: 'http' } else {};
|
|
|
|
local defaultStartupProbe = {
|
|
successThreshold: 1,
|
|
initialDelaySeconds: 0,
|
|
periodSeconds: 10,
|
|
failureThreshold: 30,
|
|
httpHeaders: [],
|
|
};
|
|
|
|
{
|
|
generator(healthCheck): {
|
|
http:: {
|
|
httpGet: {
|
|
port: port_map.getPort(healthCheck.port),
|
|
path: healthCheck.path,
|
|
httpHeaders: healthCheck.httpHeaders,
|
|
},
|
|
successThreshold: healthCheck.successThreshold,
|
|
initialDelaySeconds: healthCheck.initialDelaySeconds,
|
|
periodSeconds: healthCheck.periodSeconds,
|
|
failureThreshold: healthCheck.failureThreshold,
|
|
},
|
|
tcp:: {
|
|
tcpSocket: {
|
|
port: port_map.getPort(healthCheck.port),
|
|
},
|
|
successThreshold: healthCheck.successThreshold,
|
|
initialDelaySeconds: healthCheck.initialDelaySeconds,
|
|
periodSeconds: healthCheck.periodSeconds,
|
|
failureThreshold: healthCheck.failureThreshold,
|
|
},
|
|
},
|
|
getDefaultReadinessCheck:: defaultReadinessCheck,
|
|
getDefaultStartupProbe:: defaultStartupProbe,
|
|
getDefaultLivenessCheck:: if (isMicrometerPrometheusEnabled && !port_map.hasPort(exposedPorts, 'metrics')) then error error_message else defaultLivenessCheck,
|
|
}
|