forked from LaconicNetwork/kompose
Support tcp/http liveness/readiness probe (#1449)
This commit is contained in:
parent
ce46a5ba01
commit
d55071e9d6
@ -167,13 +167,18 @@ The currently supported options are:
|
|||||||
| kompose.controller.type | deployment / daemonset / replicationcontroller |
|
| kompose.controller.type | deployment / daemonset / replicationcontroller |
|
||||||
| kompose.image-pull-policy | kubernetes pods imagePullPolicy |
|
| kompose.image-pull-policy | kubernetes pods imagePullPolicy |
|
||||||
| kompose.image-pull-secret | kubernetes secret name for imagePullSecrets |
|
| kompose.image-pull-secret | kubernetes secret name for imagePullSecrets |
|
||||||
|
| kompose.service.healthcheck.readiness.disable | kubernetes readiness disable |
|
||||||
| kompose.service.healthcheck.readiness.test | kubernetes readiness exec command |
|
| kompose.service.healthcheck.readiness.test | kubernetes readiness exec command |
|
||||||
|
| kompose.service.healthcheck.readiness.http_get_path | kubernetes readiness httpGet path |
|
||||||
|
| kompose.service.healthcheck.readiness.http_get_port | kubernetes readiness httpGet port |
|
||||||
|
| kompose.service.healthcheck.readiness.tcp_port | kubernetes readiness tcpSocket port |
|
||||||
| kompose.service.healthcheck.readiness.interval | kubernetes readiness interval value |
|
| kompose.service.healthcheck.readiness.interval | kubernetes readiness interval value |
|
||||||
| kompose.service.healthcheck.readiness.timeout | kubernetes readiness timeout value |
|
| kompose.service.healthcheck.readiness.timeout | kubernetes readiness timeout value |
|
||||||
| kompose.service.healthcheck.readiness.retries | kubernetes readiness retries value |
|
| kompose.service.healthcheck.readiness.retries | kubernetes readiness retries value |
|
||||||
| kompose.service.healthcheck.readiness.start_period | kubernetes readiness start_period |
|
| kompose.service.healthcheck.readiness.start_period | kubernetes readiness start_period |
|
||||||
| kompose.service.healthcheck.liveness.http_get_path | kubernetes liveness httpGet path |
|
| kompose.service.healthcheck.liveness.http_get_path | kubernetes liveness httpGet path |
|
||||||
| kompose.service.healthcheck.liveness.http_get_port | kubernetes liveness httpGet port |
|
| kompose.service.healthcheck.liveness.http_get_port | kubernetes liveness httpGet port |
|
||||||
|
| kompose.service.healthcheck.liveness.tcp_port | kubernetes liveness tcpSocket port |
|
||||||
|
|
||||||
**Note**: `kompose.service.type` label should be defined with `ports` only (except for headless service), otherwise `kompose` will fail.
|
**Note**: `kompose.service.type` label should be defined with `ports` only (except for headless service), otherwise `kompose` will fail.
|
||||||
|
|
||||||
|
|||||||
@ -165,7 +165,7 @@ type HealthChecks struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HealthCheck the healthcheck configuration for a service
|
// HealthCheck the healthcheck configuration for a service
|
||||||
// "StartPeriod" is not yet added to compose, see:
|
// "StartPeriod" was added to v3.4 of the compose, see:
|
||||||
// https://github.com/docker/cli/issues/116
|
// https://github.com/docker/cli/issues/116
|
||||||
type HealthCheck struct {
|
type HealthCheck struct {
|
||||||
Test []string
|
Test []string
|
||||||
@ -176,6 +176,7 @@ type HealthCheck struct {
|
|||||||
Disable bool
|
Disable bool
|
||||||
HTTPPath string
|
HTTPPath string
|
||||||
HTTPPort int32
|
HTTPPort int32
|
||||||
|
TCPPort int32
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnvVar holds the environment variable struct of a container
|
// EnvVar holds the environment variable struct of a container
|
||||||
|
|||||||
@ -41,61 +41,157 @@ func durationTypesPtr(value time.Duration) *types.Duration {
|
|||||||
|
|
||||||
func TestParseHealthCheck(t *testing.T) {
|
func TestParseHealthCheck(t *testing.T) {
|
||||||
helperValue := uint64(2)
|
helperValue := uint64(2)
|
||||||
check := types.HealthCheckConfig{
|
type input struct {
|
||||||
Test: []string{"CMD-SHELL", "echo", "foobar"},
|
healthCheck types.HealthCheckConfig
|
||||||
Timeout: durationTypesPtr(1 * time.Second),
|
labels types.Labels
|
||||||
Interval: durationTypesPtr(2 * time.Second),
|
}
|
||||||
Retries: &helperValue,
|
testCases := map[string]struct {
|
||||||
StartPeriod: durationTypesPtr(3 * time.Second),
|
input input
|
||||||
|
expected kobject.HealthCheck
|
||||||
|
}{
|
||||||
|
"Exec": {
|
||||||
|
input: input{
|
||||||
|
healthCheck: types.HealthCheckConfig{
|
||||||
|
Test: []string{"CMD-SHELL", "echo", "foobar"},
|
||||||
|
Timeout: durationTypesPtr(1 * time.Second),
|
||||||
|
Interval: durationTypesPtr(2 * time.Second),
|
||||||
|
Retries: &helperValue,
|
||||||
|
StartPeriod: durationTypesPtr(3 * time.Second),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// CMD-SHELL or SHELL is included Test within docker/cli, thus we remove the first value in Test
|
||||||
|
expected: kobject.HealthCheck{
|
||||||
|
Test: []string{"echo", "foobar"},
|
||||||
|
Timeout: 1,
|
||||||
|
Interval: 2,
|
||||||
|
Retries: 2,
|
||||||
|
StartPeriod: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"HTTPGet": {
|
||||||
|
input: input{
|
||||||
|
healthCheck: types.HealthCheckConfig{
|
||||||
|
Timeout: durationTypesPtr(1 * time.Second),
|
||||||
|
Interval: durationTypesPtr(2 * time.Second),
|
||||||
|
Retries: &helperValue,
|
||||||
|
StartPeriod: durationTypesPtr(3 * time.Second),
|
||||||
|
},
|
||||||
|
labels: types.Labels{
|
||||||
|
"kompose.service.healthcheck.liveness.http_get_path": "/health",
|
||||||
|
"kompose.service.healthcheck.liveness.http_get_port": "8080",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expected: kobject.HealthCheck{
|
||||||
|
HTTPPath: "/health",
|
||||||
|
HTTPPort: 8080,
|
||||||
|
Timeout: 1,
|
||||||
|
Interval: 2,
|
||||||
|
Retries: 2,
|
||||||
|
StartPeriod: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"TCPSocket": {
|
||||||
|
input: input{
|
||||||
|
healthCheck: types.HealthCheckConfig{
|
||||||
|
Timeout: durationTypesPtr(1 * time.Second),
|
||||||
|
Interval: durationTypesPtr(2 * time.Second),
|
||||||
|
Retries: &helperValue,
|
||||||
|
StartPeriod: durationTypesPtr(3 * time.Second),
|
||||||
|
},
|
||||||
|
labels: types.Labels{
|
||||||
|
"kompose.service.healthcheck.liveness.tcp_port": "8080",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expected: kobject.HealthCheck{
|
||||||
|
TCPPort: 8080,
|
||||||
|
Timeout: 1,
|
||||||
|
Interval: 2,
|
||||||
|
Retries: 2,
|
||||||
|
StartPeriod: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// CMD-SHELL or SHELL is included Test within docker/cli, thus we remove the first value in Test
|
for name, testCase := range testCases {
|
||||||
expected := kobject.HealthCheck{
|
t.Log("Test case:", name)
|
||||||
Test: []string{"echo", "foobar"},
|
output, err := parseHealthCheck(testCase.input.healthCheck, testCase.input.labels)
|
||||||
Timeout: 1,
|
if err != nil {
|
||||||
Interval: 2,
|
t.Errorf("Unable to convert HealthCheckConfig: %s", err)
|
||||||
Retries: 2,
|
}
|
||||||
StartPeriod: 3,
|
|
||||||
}
|
|
||||||
output, err := parseHealthCheck(check, nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unable to convert HealthCheckConfig: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(output, expected) {
|
if !reflect.DeepEqual(output, testCase.expected) {
|
||||||
t.Errorf("Structs are not equal, expected: %v, output: %v", expected, output)
|
t.Errorf("Structs are not equal, expected: %v, output: %v", testCase.expected, output)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseHttpHealthCheck(t *testing.T) {
|
func TestParseHealthCheckReadiness(t *testing.T) {
|
||||||
helperValue := uint64(2)
|
testCases := map[string]struct {
|
||||||
check := types.HealthCheckConfig{
|
input types.Labels
|
||||||
Timeout: durationTypesPtr(1 * time.Second),
|
expected kobject.HealthCheck
|
||||||
Interval: durationTypesPtr(2 * time.Second),
|
}{
|
||||||
Retries: &helperValue,
|
"Exec": {
|
||||||
StartPeriod: durationTypesPtr(3 * time.Second),
|
input: types.Labels{
|
||||||
}
|
"kompose.service.healthcheck.readiness.test": "echo foobar",
|
||||||
label := types.Labels{
|
"kompose.service.healthcheck.readiness.timeout": "1s",
|
||||||
HealthCheckLivenessHTTPGetPath: "ping",
|
"kompose.service.healthcheck.readiness.interval": "2s",
|
||||||
HealthCheckLivenessHTTPGetPort: "80",
|
"kompose.service.healthcheck.readiness.retries": "2",
|
||||||
|
"kompose.service.healthcheck.readiness.start_period": "3s",
|
||||||
|
},
|
||||||
|
expected: kobject.HealthCheck{
|
||||||
|
Test: []string{"echo", "foobar"},
|
||||||
|
Timeout: 1,
|
||||||
|
Interval: 2,
|
||||||
|
Retries: 2,
|
||||||
|
StartPeriod: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"HTTPGet": {
|
||||||
|
input: types.Labels{
|
||||||
|
"kompose.service.healthcheck.readiness.http_get_path": "/ready",
|
||||||
|
"kompose.service.healthcheck.readiness.http_get_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "2s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "2",
|
||||||
|
"kompose.service.healthcheck.readiness.start_period": "3s",
|
||||||
|
},
|
||||||
|
expected: kobject.HealthCheck{
|
||||||
|
HTTPPath: "/ready",
|
||||||
|
HTTPPort: 8080,
|
||||||
|
Timeout: 1,
|
||||||
|
Interval: 2,
|
||||||
|
Retries: 2,
|
||||||
|
StartPeriod: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"TCPSocket": {
|
||||||
|
input: types.Labels{
|
||||||
|
"kompose.service.healthcheck.readiness.tcp_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "2s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "2",
|
||||||
|
"kompose.service.healthcheck.readiness.start_period": "3s",
|
||||||
|
},
|
||||||
|
expected: kobject.HealthCheck{
|
||||||
|
TCPPort: 8080,
|
||||||
|
Timeout: 1,
|
||||||
|
Interval: 2,
|
||||||
|
Retries: 2,
|
||||||
|
StartPeriod: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// CMD-SHELL or SHELL is included Test within docker/cli, thus we remove the first value in Test
|
for name, testCase := range testCases {
|
||||||
expected := kobject.HealthCheck{
|
t.Log("Test case:", name)
|
||||||
HTTPPath: "ping",
|
output, err := parseHealthCheckReadiness(testCase.input)
|
||||||
HTTPPort: 80,
|
if err != nil {
|
||||||
Timeout: 1,
|
t.Errorf("Unable to convert HealthCheckConfig: %s", err)
|
||||||
Interval: 2,
|
}
|
||||||
Retries: 2,
|
|
||||||
StartPeriod: 3,
|
|
||||||
}
|
|
||||||
output, err := parseHealthCheck(check, label)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unable to convert HealthCheckConfig: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(output, expected) {
|
if !reflect.DeepEqual(output, testCase.expected) {
|
||||||
t.Errorf("Structs are not equal, expected: %v, output: %v", expected, output)
|
t.Errorf("Structs are not equal, expected: %v, output: %v", testCase.expected, output)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,10 +60,18 @@ const (
|
|||||||
HealthCheckReadinessRetries = "kompose.service.healthcheck.readiness.retries"
|
HealthCheckReadinessRetries = "kompose.service.healthcheck.readiness.retries"
|
||||||
// HealthCheckReadinessStartPeriod defines readiness health check start period
|
// HealthCheckReadinessStartPeriod defines readiness health check start period
|
||||||
HealthCheckReadinessStartPeriod = "kompose.service.healthcheck.readiness.start_period"
|
HealthCheckReadinessStartPeriod = "kompose.service.healthcheck.readiness.start_period"
|
||||||
|
// HealthCheckReadinessHTTPGetPath defines readiness health check HttpGet path
|
||||||
|
HealthCheckReadinessHTTPGetPath = "kompose.service.healthcheck.readiness.http_get_path"
|
||||||
|
// HealthCheckReadinessHTTPGetPort defines readiness health check HttpGet port
|
||||||
|
HealthCheckReadinessHTTPGetPort = "kompose.service.healthcheck.readiness.http_get_port"
|
||||||
|
// HealthCheckReadinessTCPPort defines readiness health check tcp port
|
||||||
|
HealthCheckReadinessTCPPort = "kompose.service.healthcheck.readiness.tcp_port"
|
||||||
// HealthCheckLivenessHTTPGetPath defines liveness health check HttpGet path
|
// HealthCheckLivenessHTTPGetPath defines liveness health check HttpGet path
|
||||||
HealthCheckLivenessHTTPGetPath = "kompose.service.healthcheck.liveness.http_get_path"
|
HealthCheckLivenessHTTPGetPath = "kompose.service.healthcheck.liveness.http_get_path"
|
||||||
// HealthCheckLivenessHTTPGetPort defines liveness health check HttpGet port
|
// HealthCheckLivenessHTTPGetPort defines liveness health check HttpGet port
|
||||||
HealthCheckLivenessHTTPGetPort = "kompose.service.healthcheck.liveness.http_get_port"
|
HealthCheckLivenessHTTPGetPort = "kompose.service.healthcheck.liveness.http_get_port"
|
||||||
|
// HealthCheckLivenessTCPPort defines liveness health check tcp port
|
||||||
|
HealthCheckLivenessTCPPort = "kompose.service.healthcheck.liveness.tcp_port"
|
||||||
|
|
||||||
// ServiceTypeHeadless ...
|
// ServiceTypeHeadless ...
|
||||||
ServiceTypeHeadless = "Headless"
|
ServiceTypeHeadless = "Headless"
|
||||||
|
|||||||
@ -245,9 +245,9 @@ func loadV3Ports(ports []types.ServicePortConfig, expose []string) []kobject.Por
|
|||||||
a Kubernetes-compatible format.
|
a Kubernetes-compatible format.
|
||||||
*/
|
*/
|
||||||
func parseHealthCheckReadiness(labels types.Labels) (kobject.HealthCheck, error) {
|
func parseHealthCheckReadiness(labels types.Labels) (kobject.HealthCheck, error) {
|
||||||
// initialize with CMD as default to not break at return (will be ignored if no test is informed)
|
var test []string
|
||||||
test := []string{"CMD"}
|
var httpPath string
|
||||||
var timeout, interval, retries, startPeriod int32
|
var httpPort, tcpPort, timeout, interval, retries, startPeriod int32
|
||||||
var disable bool
|
var disable bool
|
||||||
|
|
||||||
for key, value := range labels {
|
for key, value := range labels {
|
||||||
@ -258,6 +258,12 @@ func parseHealthCheckReadiness(labels types.Labels) (kobject.HealthCheck, error)
|
|||||||
if len(value) > 0 {
|
if len(value) > 0 {
|
||||||
test, _ = shlex.Split(value)
|
test, _ = shlex.Split(value)
|
||||||
}
|
}
|
||||||
|
case HealthCheckReadinessHTTPGetPath:
|
||||||
|
httpPath = value
|
||||||
|
case HealthCheckReadinessHTTPGetPort:
|
||||||
|
httpPort = cast.ToInt32(value)
|
||||||
|
case HealthCheckReadinessTCPPort:
|
||||||
|
tcpPort = cast.ToInt32(value)
|
||||||
case HealthCheckReadinessInterval:
|
case HealthCheckReadinessInterval:
|
||||||
parse, err := time.ParseDuration(value)
|
parse, err := time.ParseDuration(value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -281,17 +287,22 @@ func parseHealthCheckReadiness(labels types.Labels) (kobject.HealthCheck, error)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if test[0] == "NONE" {
|
if len(test) > 0 {
|
||||||
disable = true
|
if test[0] == "NONE" {
|
||||||
test = test[1:]
|
disable = true
|
||||||
}
|
test = test[1:]
|
||||||
if test[0] == "CMD" || test[0] == "CMD-SHELL" {
|
}
|
||||||
test = test[1:]
|
// Due to docker/cli adding "CMD-SHELL" to the struct, we remove the first element of composeHealthCheck.Test
|
||||||
|
if test[0] == "CMD" || test[0] == "CMD-SHELL" {
|
||||||
|
test = test[1:]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Due to docker/cli adding "CMD-SHELL" to the struct, we remove the first element of composeHealthCheck.Test
|
|
||||||
return kobject.HealthCheck{
|
return kobject.HealthCheck{
|
||||||
Test: test,
|
Test: test,
|
||||||
|
HTTPPath: httpPath,
|
||||||
|
HTTPPort: httpPort,
|
||||||
|
TCPPort: tcpPort,
|
||||||
Timeout: timeout,
|
Timeout: timeout,
|
||||||
Interval: interval,
|
Interval: interval,
|
||||||
Retries: retries,
|
Retries: retries,
|
||||||
@ -304,9 +315,8 @@ func parseHealthCheckReadiness(labels types.Labels) (kobject.HealthCheck, error)
|
|||||||
a Kubernetes-compatible format.
|
a Kubernetes-compatible format.
|
||||||
*/
|
*/
|
||||||
func parseHealthCheck(composeHealthCheck types.HealthCheckConfig, labels types.Labels) (kobject.HealthCheck, error) {
|
func parseHealthCheck(composeHealthCheck types.HealthCheckConfig, labels types.Labels) (kobject.HealthCheck, error) {
|
||||||
var timeout, interval, retries, startPeriod int32
|
var httpPort, tcpPort, timeout, interval, retries, startPeriod int32
|
||||||
var test []string
|
var test []string
|
||||||
var httpPort int32
|
|
||||||
var httpPath string
|
var httpPath string
|
||||||
|
|
||||||
// Here we convert the timeout from 1h30s (example) to 36030 seconds.
|
// Here we convert the timeout from 1h30s (example) to 36030 seconds.
|
||||||
@ -348,12 +358,15 @@ func parseHealthCheck(composeHealthCheck types.HealthCheckConfig, labels types.L
|
|||||||
httpPath = value
|
httpPath = value
|
||||||
case HealthCheckLivenessHTTPGetPort:
|
case HealthCheckLivenessHTTPGetPort:
|
||||||
httpPort = cast.ToInt32(value)
|
httpPort = cast.ToInt32(value)
|
||||||
|
case HealthCheckLivenessTCPPort:
|
||||||
|
tcpPort = cast.ToInt32(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Due to docker/cli adding "CMD-SHELL" to the struct, we remove the first element of composeHealthCheck.Test
|
// Due to docker/cli adding "CMD-SHELL" to the struct, we remove the first element of composeHealthCheck.Test
|
||||||
return kobject.HealthCheck{
|
return kobject.HealthCheck{
|
||||||
Test: test,
|
Test: test,
|
||||||
|
TCPPort: tcpPort,
|
||||||
HTTPPath: httpPath,
|
HTTPPath: httpPath,
|
||||||
HTTPPort: httpPort,
|
HTTPPort: httpPort,
|
||||||
Timeout: timeout,
|
Timeout: timeout,
|
||||||
@ -426,7 +439,7 @@ func dockerComposeToKomposeMapping(composeObject *types.Config) (kobject.Kompose
|
|||||||
|
|
||||||
// HealthCheck Readiness
|
// HealthCheck Readiness
|
||||||
var readiness, errReadiness = parseHealthCheckReadiness(*&composeServiceConfig.Labels)
|
var readiness, errReadiness = parseHealthCheckReadiness(*&composeServiceConfig.Labels)
|
||||||
if readiness.Test != nil && len(readiness.Test) > 0 && len(readiness.Test[0]) > 0 && !readiness.Disable {
|
if !readiness.Disable {
|
||||||
serviceConfig.HealthChecks.Readiness = readiness
|
serviceConfig.HealthChecks.Readiness = readiness
|
||||||
if errReadiness != nil {
|
if errReadiness != nil {
|
||||||
return kobject.KomposeObject{}, errors.Wrap(errReadiness, "Unable to parse health check")
|
return kobject.KomposeObject{}, errors.Wrap(errReadiness, "Unable to parse health check")
|
||||||
|
|||||||
@ -45,7 +45,6 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -534,62 +533,8 @@ func (k *Kubernetes) UpdateKubernetesObjects(name string, service kobject.Servic
|
|||||||
template.Spec.Volumes = append(template.Spec.Volumes, volumes...)
|
template.Spec.Volumes = append(template.Spec.Volumes, volumes...)
|
||||||
template.Spec.Affinity = ConfigAffinity(service)
|
template.Spec.Affinity = ConfigAffinity(service)
|
||||||
// Configure the HealthCheck
|
// Configure the HealthCheck
|
||||||
// We check to see if it's blank
|
template.Spec.Containers[0].LivenessProbe = configProbe(service.HealthChecks.Liveness)
|
||||||
if !reflect.DeepEqual(service.HealthChecks.Liveness, kobject.HealthCheck{}) {
|
template.Spec.Containers[0].ReadinessProbe = configProbe(service.HealthChecks.Readiness)
|
||||||
probe := api.Probe{}
|
|
||||||
|
|
||||||
if len(service.HealthChecks.Liveness.Test) > 0 {
|
|
||||||
probe.Handler = api.Handler{
|
|
||||||
Exec: &api.ExecAction{
|
|
||||||
Command: service.HealthChecks.Liveness.Test,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else if !reflect.ValueOf(service.HealthChecks.Liveness.HTTPPath).IsZero() &&
|
|
||||||
!reflect.ValueOf(service.HealthChecks.Liveness.HTTPPort).IsZero() {
|
|
||||||
probe.Handler = api.Handler{
|
|
||||||
HTTPGet: &api.HTTPGetAction{
|
|
||||||
Path: service.HealthChecks.Liveness.HTTPPath,
|
|
||||||
Port: intstr.FromInt(int(service.HealthChecks.Liveness.HTTPPort)),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return errors.New("Health check must contain a command")
|
|
||||||
}
|
|
||||||
|
|
||||||
probe.TimeoutSeconds = service.HealthChecks.Liveness.Timeout
|
|
||||||
probe.PeriodSeconds = service.HealthChecks.Liveness.Interval
|
|
||||||
probe.FailureThreshold = service.HealthChecks.Liveness.Retries
|
|
||||||
|
|
||||||
// See issue: https://github.com/docker/cli/issues/116
|
|
||||||
// StartPeriod has been added to docker/cli however, it is not yet added
|
|
||||||
// to compose. Once the feature has been implemented, this will automatically work
|
|
||||||
probe.InitialDelaySeconds = service.HealthChecks.Liveness.StartPeriod
|
|
||||||
|
|
||||||
template.Spec.Containers[0].LivenessProbe = &probe
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(service.HealthChecks.Readiness, kobject.HealthCheck{}) {
|
|
||||||
probeHealthCheckReadiness := api.Probe{}
|
|
||||||
if len(service.HealthChecks.Readiness.Test) > 0 {
|
|
||||||
probeHealthCheckReadiness.Handler = api.Handler{
|
|
||||||
Exec: &api.ExecAction{
|
|
||||||
Command: service.HealthChecks.Readiness.Test,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return errors.New("Health check must contain a command")
|
|
||||||
}
|
|
||||||
|
|
||||||
probeHealthCheckReadiness.TimeoutSeconds = service.HealthChecks.Readiness.Timeout
|
|
||||||
probeHealthCheckReadiness.PeriodSeconds = service.HealthChecks.Readiness.Interval
|
|
||||||
probeHealthCheckReadiness.FailureThreshold = service.HealthChecks.Readiness.Retries
|
|
||||||
|
|
||||||
// See issue: https://github.com/docker/cli/issues/116
|
|
||||||
// StartPeriod has been added to docker/cli however, it is not yet added
|
|
||||||
// to compose. Once the feature has been implemented, this will automatically work
|
|
||||||
probeHealthCheckReadiness.InitialDelaySeconds = service.HealthChecks.Readiness.StartPeriod
|
|
||||||
|
|
||||||
template.Spec.Containers[0].ReadinessProbe = &probeHealthCheckReadiness
|
|
||||||
}
|
|
||||||
|
|
||||||
if service.StopGracePeriod != "" {
|
if service.StopGracePeriod != "" {
|
||||||
template.Spec.TerminationGracePeriodSeconds, err = DurationStrToSecondsInt(service.StopGracePeriod)
|
template.Spec.TerminationGracePeriodSeconds, err = DurationStrToSecondsInt(service.StopGracePeriod)
|
||||||
|
|||||||
@ -352,41 +352,96 @@ func TestIsDir(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestServiceWithoutPort this tests if Headless Service is created for services without Port.
|
// TestServiceWithHealthCheck this tests if Headless Service is created for services with HealthCheck.
|
||||||
func TestServiceWithHealthCheck(t *testing.T) {
|
func TestServiceWithHealthCheck(t *testing.T) {
|
||||||
service := kobject.ServiceConfig{
|
testCases := map[string]struct {
|
||||||
ContainerName: "name",
|
service kobject.ServiceConfig
|
||||||
Image: "image",
|
}{
|
||||||
ServiceType: "Headless",
|
"Exec": {
|
||||||
HealthChecks: kobject.HealthChecks{
|
service: kobject.ServiceConfig{
|
||||||
Readiness: kobject.HealthCheck{
|
ContainerName: "name",
|
||||||
Test: []string{"arg1", "arg2"},
|
Image: "image",
|
||||||
Timeout: 10,
|
ServiceType: "Headless",
|
||||||
Interval: 5,
|
HealthChecks: kobject.HealthChecks{
|
||||||
Retries: 3,
|
Readiness: kobject.HealthCheck{
|
||||||
StartPeriod: 60,
|
Test: []string{"arg1", "arg2"},
|
||||||
|
Timeout: 10,
|
||||||
|
Interval: 5,
|
||||||
|
Retries: 3,
|
||||||
|
StartPeriod: 60,
|
||||||
|
},
|
||||||
|
Liveness: kobject.HealthCheck{
|
||||||
|
Test: []string{"arg1", "arg2"},
|
||||||
|
Timeout: 11,
|
||||||
|
Interval: 6,
|
||||||
|
Retries: 4,
|
||||||
|
StartPeriod: 61,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Liveness: kobject.HealthCheck{
|
},
|
||||||
Test: []string{"arg1", "arg2"},
|
"HTTPGet": {
|
||||||
Timeout: 11,
|
service: kobject.ServiceConfig{
|
||||||
Interval: 6,
|
ContainerName: "name",
|
||||||
Retries: 4,
|
Image: "image",
|
||||||
StartPeriod: 61,
|
ServiceType: "Headless",
|
||||||
|
HealthChecks: kobject.HealthChecks{
|
||||||
|
Readiness: kobject.HealthCheck{
|
||||||
|
HTTPPath: "/health",
|
||||||
|
HTTPPort: 8080,
|
||||||
|
Timeout: 10,
|
||||||
|
Interval: 5,
|
||||||
|
Retries: 3,
|
||||||
|
StartPeriod: 60,
|
||||||
|
},
|
||||||
|
Liveness: kobject.HealthCheck{
|
||||||
|
HTTPPath: "/ready",
|
||||||
|
HTTPPort: 8080,
|
||||||
|
Timeout: 11,
|
||||||
|
Interval: 6,
|
||||||
|
Retries: 4,
|
||||||
|
StartPeriod: 61,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"TCPSocket": {
|
||||||
|
service: kobject.ServiceConfig{
|
||||||
|
ContainerName: "name",
|
||||||
|
Image: "image",
|
||||||
|
ServiceType: "Headless",
|
||||||
|
HealthChecks: kobject.HealthChecks{
|
||||||
|
Readiness: kobject.HealthCheck{
|
||||||
|
TCPPort: 8080,
|
||||||
|
Timeout: 10,
|
||||||
|
Interval: 5,
|
||||||
|
Retries: 3,
|
||||||
|
StartPeriod: 60,
|
||||||
|
},
|
||||||
|
Liveness: kobject.HealthCheck{
|
||||||
|
TCPPort: 8080,
|
||||||
|
Timeout: 11,
|
||||||
|
Interval: 6,
|
||||||
|
Retries: 4,
|
||||||
|
StartPeriod: 61,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
komposeObject := kobject.KomposeObject{
|
for _, testCase := range testCases {
|
||||||
ServiceConfigs: map[string]kobject.ServiceConfig{"app": service},
|
k := Kubernetes{}
|
||||||
}
|
komposeObject := kobject.KomposeObject{
|
||||||
k := Kubernetes{}
|
ServiceConfigs: map[string]kobject.ServiceConfig{"app": testCase.service},
|
||||||
|
}
|
||||||
objects, err := k.Transform(komposeObject, kobject.ConvertOptions{CreateD: true, Replicas: 1})
|
objects, err := k.Transform(komposeObject, kobject.ConvertOptions{CreateD: true, Replicas: 1})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(errors.Wrap(err, "k.Transform failed"))
|
t.Error(errors.Wrap(err, "k.Transform failed"))
|
||||||
}
|
}
|
||||||
if err := testutils.CheckForHealthCheckLivenessAndReadiness(objects); err != nil {
|
if err := testutils.CheckForHealthCheckLivenessAndReadiness(objects); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1363,8 +1363,6 @@ func (k *Kubernetes) Transform(komposeObject kobject.KomposeObject, opt kobject.
|
|||||||
ImagePullPolicy(name, service),
|
ImagePullPolicy(name, service),
|
||||||
RestartPolicy(name, service),
|
RestartPolicy(name, service),
|
||||||
SecurityContext(name, service),
|
SecurityContext(name, service),
|
||||||
LivenessProbe(service),
|
|
||||||
ReadinessProbe(service),
|
|
||||||
HostName(service),
|
HostName(service),
|
||||||
DomainName(service),
|
DomainName(service),
|
||||||
ResourcesLimits(service),
|
ResourcesLimits(service),
|
||||||
|
|||||||
@ -744,6 +744,84 @@ func TestServiceAccountNameOnMultipleContainers(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestHealthCheckOnMultipleContainers(t *testing.T) {
|
||||||
|
groupName := "pod_group"
|
||||||
|
|
||||||
|
createHealthCheck := func(TCPPort int32) kobject.HealthCheck {
|
||||||
|
return kobject.HealthCheck{
|
||||||
|
TCPPort: TCPPort,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
createConfig := func(name string, livenessTCPPort, readinessTCPPort int32) kobject.ServiceConfig {
|
||||||
|
config := newSimpleServiceConfig()
|
||||||
|
config.Labels = map[string]string{compose.LabelServiceGroup: groupName}
|
||||||
|
config.Name = name
|
||||||
|
config.ContainerName = name
|
||||||
|
config.HealthChecks.Liveness = createHealthCheck(livenessTCPPort)
|
||||||
|
config.HealthChecks.Readiness = createHealthCheck(readinessTCPPort)
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
|
testCases := map[string]struct {
|
||||||
|
komposeObject kobject.KomposeObject
|
||||||
|
opt kobject.ConvertOptions
|
||||||
|
expectedContainers map[string]api.Container
|
||||||
|
}{
|
||||||
|
"Converted multiple containers to Deployments": {
|
||||||
|
kobject.KomposeObject{
|
||||||
|
ServiceConfigs: map[string]kobject.ServiceConfig{
|
||||||
|
"app1": createConfig("app1", 8081, 9091),
|
||||||
|
"app2": createConfig("app2", 8082, 9092),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
kobject.ConvertOptions{ServiceGroupMode: "label", CreateD: true},
|
||||||
|
map[string]api.Container{
|
||||||
|
"app1": {
|
||||||
|
LivenessProbe: configProbe(createHealthCheck(8081)),
|
||||||
|
ReadinessProbe: configProbe(createHealthCheck(9091)),
|
||||||
|
},
|
||||||
|
"app2": {
|
||||||
|
LivenessProbe: configProbe(createHealthCheck(8082)),
|
||||||
|
ReadinessProbe: configProbe(createHealthCheck(9092)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for name, test := range testCases {
|
||||||
|
t.Log("Test case:", name)
|
||||||
|
k := Kubernetes{}
|
||||||
|
// Run Transform
|
||||||
|
objs, err := k.Transform(test.komposeObject, test.opt)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(errors.Wrap(err, "k.Transform failed"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check results
|
||||||
|
for _, obj := range objs {
|
||||||
|
if deployment, ok := obj.(*appsv1.Deployment); ok {
|
||||||
|
if len(deployment.Spec.Template.Spec.Containers) != len(test.expectedContainers) {
|
||||||
|
t.Errorf("Containers len is not equal, expected %d, got %d",
|
||||||
|
len(deployment.Spec.Template.Spec.Containers), len(test.expectedContainers))
|
||||||
|
}
|
||||||
|
for _, result := range deployment.Spec.Template.Spec.Containers {
|
||||||
|
expected, ok := test.expectedContainers[result.Name]
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("Container %s doesn't expected", result.Name)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(result.LivenessProbe, expected.LivenessProbe) {
|
||||||
|
t.Errorf("Container %s: LivenessProbe expected %v returned, got %v", result.Name, expected.LivenessProbe, result.LivenessProbe)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(result.ReadinessProbe, expected.ReadinessProbe) {
|
||||||
|
t.Errorf("Container %s: ReadinessProbe expected %v returned, got %v", result.Name, expected.ReadinessProbe, result.ReadinessProbe)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCreatePVC(t *testing.T) {
|
func TestCreatePVC(t *testing.T) {
|
||||||
storageClassName := "custom-storage-class-name"
|
storageClassName := "custom-storage-class-name"
|
||||||
k := Kubernetes{}
|
k := Kubernetes{}
|
||||||
|
|||||||
@ -34,14 +34,16 @@ func AddContainer(service kobject.ServiceConfig, opt kobject.ConvertOptions) Pod
|
|||||||
}
|
}
|
||||||
|
|
||||||
podSpec.Containers = append(podSpec.Containers, api.Container{
|
podSpec.Containers = append(podSpec.Containers, api.Container{
|
||||||
Name: name,
|
Name: name,
|
||||||
Image: image,
|
Image: image,
|
||||||
Env: envs,
|
Env: envs,
|
||||||
Command: service.Command,
|
Command: service.Command,
|
||||||
Args: service.Args,
|
Args: service.Args,
|
||||||
WorkingDir: service.WorkingDir,
|
WorkingDir: service.WorkingDir,
|
||||||
Stdin: service.Stdin,
|
Stdin: service.Stdin,
|
||||||
TTY: service.Tty,
|
TTY: service.Tty,
|
||||||
|
LivenessProbe: configProbe(service.HealthChecks.Liveness),
|
||||||
|
ReadinessProbe: configProbe(service.HealthChecks.Readiness),
|
||||||
})
|
})
|
||||||
|
|
||||||
podSpec.Affinity = ConfigAffinity(service)
|
podSpec.Affinity = ConfigAffinity(service)
|
||||||
@ -258,75 +260,44 @@ func DomainName(service kobject.ServiceConfig) PodSpecOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func LivenessProbe(service kobject.ServiceConfig) PodSpecOption {
|
func configProbe(healthCheck kobject.HealthCheck) *api.Probe {
|
||||||
return func(podSpec *PodSpec) {
|
probe := api.Probe{}
|
||||||
// Configure the HealthCheck
|
// We check to see if it's blank or disable
|
||||||
// We check to see if it's blank
|
if reflect.DeepEqual(healthCheck, kobject.HealthCheck{}) || healthCheck.Disable {
|
||||||
if !reflect.DeepEqual(service.HealthChecks.Liveness, kobject.HealthCheck{}) {
|
return nil
|
||||||
probe := api.Probe{}
|
|
||||||
|
|
||||||
if len(service.HealthChecks.Liveness.Test) > 0 {
|
|
||||||
probe.Handler = api.Handler{
|
|
||||||
Exec: &api.ExecAction{
|
|
||||||
Command: service.HealthChecks.Liveness.Test,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else if !reflect.ValueOf(service.HealthChecks.Liveness.HTTPPath).IsZero() &&
|
|
||||||
!reflect.ValueOf(service.HealthChecks.Liveness.HTTPPort).IsZero() {
|
|
||||||
probe.Handler = api.Handler{
|
|
||||||
HTTPGet: &api.HTTPGetAction{
|
|
||||||
Path: service.HealthChecks.Liveness.HTTPPath,
|
|
||||||
Port: intstr.FromInt(int(service.HealthChecks.Liveness.HTTPPort)),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
panic(errors.New("Health check must contain a command"))
|
|
||||||
}
|
|
||||||
|
|
||||||
probe.TimeoutSeconds = service.HealthChecks.Liveness.Timeout
|
|
||||||
probe.PeriodSeconds = service.HealthChecks.Liveness.Interval
|
|
||||||
probe.FailureThreshold = service.HealthChecks.Liveness.Retries
|
|
||||||
|
|
||||||
// See issue: https://github.com/docker/cli/issues/116
|
|
||||||
// StartPeriod has been added to docker/cli however, it is not yet added
|
|
||||||
// to compose. Once the feature has been implemented, this will automatically work
|
|
||||||
probe.InitialDelaySeconds = service.HealthChecks.Liveness.StartPeriod
|
|
||||||
|
|
||||||
for i := range podSpec.Containers {
|
|
||||||
podSpec.Containers[i].LivenessProbe = &probe
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func ReadinessProbe(service kobject.ServiceConfig) PodSpecOption {
|
if len(healthCheck.Test) > 0 {
|
||||||
return func(podSpec *PodSpec) {
|
probe.Handler = api.Handler{
|
||||||
if !reflect.DeepEqual(service.HealthChecks.Readiness, kobject.HealthCheck{}) {
|
Exec: &api.ExecAction{
|
||||||
probeHealthCheckReadiness := api.Probe{}
|
Command: healthCheck.Test,
|
||||||
if len(service.HealthChecks.Readiness.Test) > 0 {
|
},
|
||||||
probeHealthCheckReadiness.Handler = api.Handler{
|
|
||||||
Exec: &api.ExecAction{
|
|
||||||
Command: service.HealthChecks.Readiness.Test,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
panic(errors.New("Health check must contain a command"))
|
|
||||||
}
|
|
||||||
|
|
||||||
probeHealthCheckReadiness.TimeoutSeconds = service.HealthChecks.Readiness.Timeout
|
|
||||||
probeHealthCheckReadiness.PeriodSeconds = service.HealthChecks.Readiness.Interval
|
|
||||||
probeHealthCheckReadiness.FailureThreshold = service.HealthChecks.Readiness.Retries
|
|
||||||
|
|
||||||
// See issue: https://github.com/docker/cli/issues/116
|
|
||||||
// StartPeriod has been added to docker/cli however, it is not yet added
|
|
||||||
// to compose. Once the feature has been implemented, this will automatically work
|
|
||||||
probeHealthCheckReadiness.InitialDelaySeconds = service.HealthChecks.Readiness.StartPeriod
|
|
||||||
|
|
||||||
for i := range podSpec.Containers {
|
|
||||||
podSpec.Containers[i].ReadinessProbe = &probeHealthCheckReadiness
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else if !reflect.ValueOf(healthCheck.HTTPPath).IsZero() && !reflect.ValueOf(healthCheck.HTTPPort).IsZero() {
|
||||||
|
probe.Handler = api.Handler{
|
||||||
|
HTTPGet: &api.HTTPGetAction{
|
||||||
|
Path: healthCheck.HTTPPath,
|
||||||
|
Port: intstr.FromInt(int(healthCheck.HTTPPort)),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else if !reflect.ValueOf(healthCheck.TCPPort).IsZero() {
|
||||||
|
probe.Handler = api.Handler{
|
||||||
|
TCPSocket: &api.TCPSocketAction{
|
||||||
|
Port: intstr.FromInt(int(healthCheck.TCPPort)),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
panic(errors.New("Health check must contain a command"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
probe.TimeoutSeconds = healthCheck.Timeout
|
||||||
|
probe.PeriodSeconds = healthCheck.Interval
|
||||||
|
probe.FailureThreshold = healthCheck.Retries
|
||||||
|
|
||||||
|
// See issue: https://github.com/docker/cli/issues/116
|
||||||
|
// StartPeriod has been added to v3.4 of the compose
|
||||||
|
probe.InitialDelaySeconds = healthCheck.StartPeriod
|
||||||
|
return &probe
|
||||||
}
|
}
|
||||||
|
|
||||||
func ServiceAccountName(serviceAccountName string) PodSpecOption {
|
func ServiceAccountName(serviceAccountName string) PodSpecOption {
|
||||||
|
|||||||
@ -171,3 +171,11 @@ k8s_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-files/output-k8s.json"
|
|||||||
ocp_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-files/output-ocp.json"
|
ocp_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-files/output-ocp.json"
|
||||||
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
|
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
|
||||||
convert::expect_success "$ocp_cmd" "$ocp_output"
|
convert::expect_success "$ocp_cmd" "$ocp_output"
|
||||||
|
|
||||||
|
# test health check
|
||||||
|
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/healthcheck/docker-compose-healthcheck.yaml convert --stdout -j --service-group-mode=label --with-kompose-annotation=false"
|
||||||
|
os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/healthcheck/docker-compose-healthcheck.yaml convert --stdout -j --service-group-mode=label --with-kompose-annotation=false"
|
||||||
|
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/healthcheck/output-healthcheck-k8s.json"
|
||||||
|
os_output="$KOMPOSE_ROOT/script/test/fixtures/healthcheck/output-healthcheck-os.json"
|
||||||
|
convert::expect_success "$k8s_cmd" "$k8s_output"
|
||||||
|
convert::expect_success "$os_cmd" "$os_output"
|
||||||
69
script/test/fixtures/healthcheck/docker-compose-healthcheck.yaml
vendored
Normal file
69
script/test/fixtures/healthcheck/docker-compose-healthcheck.yaml
vendored
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
version: "3.3"
|
||||||
|
services:
|
||||||
|
# test exec
|
||||||
|
redis:
|
||||||
|
image: redis
|
||||||
|
ports:
|
||||||
|
- "6379"
|
||||||
|
healthcheck:
|
||||||
|
test: echo "liveness"
|
||||||
|
interval: 10s
|
||||||
|
timeout: 1s
|
||||||
|
retries: 5
|
||||||
|
labels:
|
||||||
|
kompose.service.healthcheck.readiness.test: echo "liveness"
|
||||||
|
kompose.service.healthcheck.readiness.interval: 10s
|
||||||
|
kompose.service.healthcheck.readiness.timeout: 1s
|
||||||
|
kompose.service.healthcheck.readiness.retries: 5
|
||||||
|
|
||||||
|
# test http get
|
||||||
|
postgresql:
|
||||||
|
image: postgresql
|
||||||
|
ports:
|
||||||
|
- "5432"
|
||||||
|
healthcheck:
|
||||||
|
interval: 10s
|
||||||
|
timeout: 1s
|
||||||
|
retries: 5
|
||||||
|
labels:
|
||||||
|
kompose.service.healthcheck.liveness.http_get_path: /health
|
||||||
|
kompose.service.healthcheck.liveness.http_get_port: 8080
|
||||||
|
kompose.service.healthcheck.readiness.http_get_path: /ready
|
||||||
|
kompose.service.healthcheck.readiness.http_get_port: 8080
|
||||||
|
kompose.service.healthcheck.readiness.interval: 10s
|
||||||
|
kompose.service.healthcheck.readiness.timeout: 1s
|
||||||
|
kompose.service.healthcheck.readiness.retries: 5
|
||||||
|
|
||||||
|
# test tcp socket
|
||||||
|
mongo:
|
||||||
|
image: mongo
|
||||||
|
ports:
|
||||||
|
- "27017"
|
||||||
|
healthcheck:
|
||||||
|
interval: 10s
|
||||||
|
timeout: 1s
|
||||||
|
retries: 5
|
||||||
|
labels:
|
||||||
|
kompose.service.group: "my-group"
|
||||||
|
kompose.service.healthcheck.liveness.tcp_port: 8080
|
||||||
|
kompose.service.healthcheck.readiness.tcp_port: 9090
|
||||||
|
kompose.service.healthcheck.readiness.interval: 10s
|
||||||
|
kompose.service.healthcheck.readiness.timeout: 1s
|
||||||
|
kompose.service.healthcheck.readiness.retries: 5
|
||||||
|
|
||||||
|
# test multiple service merge
|
||||||
|
mysql:
|
||||||
|
image: mysql
|
||||||
|
ports:
|
||||||
|
- "3306"
|
||||||
|
healthcheck:
|
||||||
|
interval: 11s
|
||||||
|
timeout: 2s
|
||||||
|
retries: 6
|
||||||
|
labels:
|
||||||
|
kompose.service.group: "my-group"
|
||||||
|
kompose.service.healthcheck.liveness.tcp_port: 8081
|
||||||
|
kompose.service.healthcheck.readiness.tcp_port: 9091
|
||||||
|
kompose.service.healthcheck.readiness.interval: 11s
|
||||||
|
kompose.service.healthcheck.readiness.timeout: 2s
|
||||||
|
kompose.service.healthcheck.readiness.retries: 6
|
||||||
401
script/test/fixtures/healthcheck/output-healthcheck-k8s.json
vendored
Normal file
401
script/test/fixtures/healthcheck/output-healthcheck-k8s.json
vendored
Normal file
@ -0,0 +1,401 @@
|
|||||||
|
{
|
||||||
|
"kind": "List",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {},
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"kind": "Service",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "mongo",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "my-group"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.group": "my-group",
|
||||||
|
"kompose.service.healthcheck.liveness.tcp_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "10s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "5",
|
||||||
|
"kompose.service.healthcheck.readiness.tcp_port": "9090",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"name": "27017",
|
||||||
|
"port": 27017,
|
||||||
|
"targetPort": 27017
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"selector": {
|
||||||
|
"io.kompose.service": "my-group"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"loadBalancer": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Service",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "mysql",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "my-group"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.group": "my-group",
|
||||||
|
"kompose.service.healthcheck.liveness.tcp_port": "8081",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "11s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "6",
|
||||||
|
"kompose.service.healthcheck.readiness.tcp_port": "9091",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "2s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"name": "3306",
|
||||||
|
"port": 3306,
|
||||||
|
"targetPort": 3306
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"selector": {
|
||||||
|
"io.kompose.service": "my-group"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"loadBalancer": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Service",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "postgresql",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "postgresql"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.healthcheck.liveness.http_get_path": "/health",
|
||||||
|
"kompose.service.healthcheck.liveness.http_get_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.http_get_path": "/ready",
|
||||||
|
"kompose.service.healthcheck.readiness.http_get_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "10s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "5",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"name": "5432",
|
||||||
|
"port": 5432,
|
||||||
|
"targetPort": 5432
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"selector": {
|
||||||
|
"io.kompose.service": "postgresql"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"loadBalancer": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Service",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "redis",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "redis"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "10s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "5",
|
||||||
|
"kompose.service.healthcheck.readiness.test": "echo \"liveness\"",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"name": "6379",
|
||||||
|
"port": 6379,
|
||||||
|
"targetPort": 6379
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"selector": {
|
||||||
|
"io.kompose.service": "redis"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"loadBalancer": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Deployment",
|
||||||
|
"apiVersion": "apps/v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "my-group",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "my-group"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.group": "my-group",
|
||||||
|
"kompose.service.healthcheck.liveness.tcp_port": "8081",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "11s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "6",
|
||||||
|
"kompose.service.healthcheck.readiness.tcp_port": "9091",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "2s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"replicas": 1,
|
||||||
|
"selector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.service": "my-group"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"template": {
|
||||||
|
"metadata": {
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "my-group"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.group": "my-group",
|
||||||
|
"kompose.service.healthcheck.liveness.tcp_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "10s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "5",
|
||||||
|
"kompose.service.healthcheck.readiness.tcp_port": "9090",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"containers": [
|
||||||
|
{
|
||||||
|
"name": "mongo",
|
||||||
|
"image": "mongo",
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"containerPort": 27017
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resources": {},
|
||||||
|
"livenessProbe": {
|
||||||
|
"tcpSocket": {
|
||||||
|
"port": 8080
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 1,
|
||||||
|
"periodSeconds": 10,
|
||||||
|
"failureThreshold": 5
|
||||||
|
},
|
||||||
|
"readinessProbe": {
|
||||||
|
"tcpSocket": {
|
||||||
|
"port": 9090
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 1,
|
||||||
|
"periodSeconds": 10,
|
||||||
|
"failureThreshold": 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "mysql",
|
||||||
|
"image": "mysql",
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"containerPort": 3306
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resources": {},
|
||||||
|
"livenessProbe": {
|
||||||
|
"tcpSocket": {
|
||||||
|
"port": 8081
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 2,
|
||||||
|
"periodSeconds": 11,
|
||||||
|
"failureThreshold": 6
|
||||||
|
},
|
||||||
|
"readinessProbe": {
|
||||||
|
"tcpSocket": {
|
||||||
|
"port": 9091
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 2,
|
||||||
|
"periodSeconds": 11,
|
||||||
|
"failureThreshold": 6
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"restartPolicy": "Always"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"strategy": {}
|
||||||
|
},
|
||||||
|
"status": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Deployment",
|
||||||
|
"apiVersion": "apps/v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "postgresql",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "postgresql"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.healthcheck.liveness.http_get_path": "/health",
|
||||||
|
"kompose.service.healthcheck.liveness.http_get_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.http_get_path": "/ready",
|
||||||
|
"kompose.service.healthcheck.readiness.http_get_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "10s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "5",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"replicas": 1,
|
||||||
|
"selector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.service": "postgresql"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"template": {
|
||||||
|
"metadata": {
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "postgresql"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.healthcheck.liveness.http_get_path": "/health",
|
||||||
|
"kompose.service.healthcheck.liveness.http_get_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.http_get_path": "/ready",
|
||||||
|
"kompose.service.healthcheck.readiness.http_get_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "10s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "5",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"containers": [
|
||||||
|
{
|
||||||
|
"name": "postgresql",
|
||||||
|
"image": "postgresql",
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"containerPort": 5432
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resources": {},
|
||||||
|
"livenessProbe": {
|
||||||
|
"httpGet": {
|
||||||
|
"path": "/health",
|
||||||
|
"port": 8080
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 1,
|
||||||
|
"periodSeconds": 10,
|
||||||
|
"failureThreshold": 5
|
||||||
|
},
|
||||||
|
"readinessProbe": {
|
||||||
|
"httpGet": {
|
||||||
|
"path": "/ready",
|
||||||
|
"port": 8080
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 1,
|
||||||
|
"periodSeconds": 10,
|
||||||
|
"failureThreshold": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"restartPolicy": "Always"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"strategy": {}
|
||||||
|
},
|
||||||
|
"status": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Deployment",
|
||||||
|
"apiVersion": "apps/v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "redis",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "redis"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "10s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "5",
|
||||||
|
"kompose.service.healthcheck.readiness.test": "echo \"liveness\"",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"replicas": 1,
|
||||||
|
"selector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"io.kompose.service": "redis"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"template": {
|
||||||
|
"metadata": {
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "redis"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "10s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "5",
|
||||||
|
"kompose.service.healthcheck.readiness.test": "echo \"liveness\"",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"containers": [
|
||||||
|
{
|
||||||
|
"name": "redis",
|
||||||
|
"image": "redis",
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"containerPort": 6379
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resources": {},
|
||||||
|
"livenessProbe": {
|
||||||
|
"exec": {
|
||||||
|
"command": [
|
||||||
|
"echo \"liveness\""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 1,
|
||||||
|
"periodSeconds": 10,
|
||||||
|
"failureThreshold": 5
|
||||||
|
},
|
||||||
|
"readinessProbe": {
|
||||||
|
"exec": {
|
||||||
|
"command": [
|
||||||
|
"echo",
|
||||||
|
"liveness"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 1,
|
||||||
|
"periodSeconds": 10,
|
||||||
|
"failureThreshold": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"restartPolicy": "Always"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"strategy": {}
|
||||||
|
},
|
||||||
|
"status": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
660
script/test/fixtures/healthcheck/output-healthcheck-os.json
vendored
Normal file
660
script/test/fixtures/healthcheck/output-healthcheck-os.json
vendored
Normal file
@ -0,0 +1,660 @@
|
|||||||
|
{
|
||||||
|
"kind": "List",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {},
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"kind": "Service",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "mongo",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "mongo"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.group": "my-group",
|
||||||
|
"kompose.service.healthcheck.liveness.tcp_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "10s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "5",
|
||||||
|
"kompose.service.healthcheck.readiness.tcp_port": "9090",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"name": "27017",
|
||||||
|
"port": 27017,
|
||||||
|
"targetPort": 27017
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"selector": {
|
||||||
|
"io.kompose.service": "mongo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"loadBalancer": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Service",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "mysql",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "mysql"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.group": "my-group",
|
||||||
|
"kompose.service.healthcheck.liveness.tcp_port": "8081",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "11s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "6",
|
||||||
|
"kompose.service.healthcheck.readiness.tcp_port": "9091",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "2s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"name": "3306",
|
||||||
|
"port": 3306,
|
||||||
|
"targetPort": 3306
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"selector": {
|
||||||
|
"io.kompose.service": "mysql"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"loadBalancer": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Service",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "postgresql",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "postgresql"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.healthcheck.liveness.http_get_path": "/health",
|
||||||
|
"kompose.service.healthcheck.liveness.http_get_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.http_get_path": "/ready",
|
||||||
|
"kompose.service.healthcheck.readiness.http_get_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "10s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "5",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"name": "5432",
|
||||||
|
"port": 5432,
|
||||||
|
"targetPort": 5432
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"selector": {
|
||||||
|
"io.kompose.service": "postgresql"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"loadBalancer": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "Service",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "redis",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "redis"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "10s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "5",
|
||||||
|
"kompose.service.healthcheck.readiness.test": "echo \"liveness\"",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"name": "6379",
|
||||||
|
"port": 6379,
|
||||||
|
"targetPort": 6379
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"selector": {
|
||||||
|
"io.kompose.service": "redis"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"loadBalancer": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "DeploymentConfig",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "mongo",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "mongo"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.group": "my-group",
|
||||||
|
"kompose.service.healthcheck.liveness.tcp_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "10s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "5",
|
||||||
|
"kompose.service.healthcheck.readiness.tcp_port": "9090",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"strategy": {
|
||||||
|
"resources": {}
|
||||||
|
},
|
||||||
|
"triggers": [
|
||||||
|
{
|
||||||
|
"type": "ConfigChange"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ImageChange",
|
||||||
|
"imageChangeParams": {
|
||||||
|
"automatic": true,
|
||||||
|
"containerNames": [
|
||||||
|
"mongo"
|
||||||
|
],
|
||||||
|
"from": {
|
||||||
|
"kind": "ImageStreamTag",
|
||||||
|
"name": "mongo:latest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"replicas": 1,
|
||||||
|
"test": false,
|
||||||
|
"selector": {
|
||||||
|
"io.kompose.service": "mongo"
|
||||||
|
},
|
||||||
|
"template": {
|
||||||
|
"metadata": {
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "mongo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"containers": [
|
||||||
|
{
|
||||||
|
"name": "mongo",
|
||||||
|
"image": " ",
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"containerPort": 27017
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resources": {},
|
||||||
|
"livenessProbe": {
|
||||||
|
"tcpSocket": {
|
||||||
|
"port": 8080
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 1,
|
||||||
|
"periodSeconds": 10,
|
||||||
|
"failureThreshold": 5
|
||||||
|
},
|
||||||
|
"readinessProbe": {
|
||||||
|
"tcpSocket": {
|
||||||
|
"port": 9090
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 1,
|
||||||
|
"periodSeconds": 10,
|
||||||
|
"failureThreshold": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"restartPolicy": "Always"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"latestVersion": 0,
|
||||||
|
"observedGeneration": 0,
|
||||||
|
"replicas": 0,
|
||||||
|
"updatedReplicas": 0,
|
||||||
|
"availableReplicas": 0,
|
||||||
|
"unavailableReplicas": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "ImageStream",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "mongo",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "mongo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"lookupPolicy": {
|
||||||
|
"local": false
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"annotations": null,
|
||||||
|
"from": {
|
||||||
|
"kind": "DockerImage",
|
||||||
|
"name": "mongo"
|
||||||
|
},
|
||||||
|
"generation": null,
|
||||||
|
"importPolicy": {},
|
||||||
|
"referencePolicy": {
|
||||||
|
"type": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"dockerImageRepository": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "DeploymentConfig",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "mysql",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "mysql"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.group": "my-group",
|
||||||
|
"kompose.service.healthcheck.liveness.tcp_port": "8081",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "11s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "6",
|
||||||
|
"kompose.service.healthcheck.readiness.tcp_port": "9091",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "2s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"strategy": {
|
||||||
|
"resources": {}
|
||||||
|
},
|
||||||
|
"triggers": [
|
||||||
|
{
|
||||||
|
"type": "ConfigChange"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ImageChange",
|
||||||
|
"imageChangeParams": {
|
||||||
|
"automatic": true,
|
||||||
|
"containerNames": [
|
||||||
|
"mysql"
|
||||||
|
],
|
||||||
|
"from": {
|
||||||
|
"kind": "ImageStreamTag",
|
||||||
|
"name": "mysql:latest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"replicas": 1,
|
||||||
|
"test": false,
|
||||||
|
"selector": {
|
||||||
|
"io.kompose.service": "mysql"
|
||||||
|
},
|
||||||
|
"template": {
|
||||||
|
"metadata": {
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "mysql"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"containers": [
|
||||||
|
{
|
||||||
|
"name": "mysql",
|
||||||
|
"image": " ",
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"containerPort": 3306
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resources": {},
|
||||||
|
"livenessProbe": {
|
||||||
|
"tcpSocket": {
|
||||||
|
"port": 8081
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 2,
|
||||||
|
"periodSeconds": 11,
|
||||||
|
"failureThreshold": 6
|
||||||
|
},
|
||||||
|
"readinessProbe": {
|
||||||
|
"tcpSocket": {
|
||||||
|
"port": 9091
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 2,
|
||||||
|
"periodSeconds": 11,
|
||||||
|
"failureThreshold": 6
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"restartPolicy": "Always"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"latestVersion": 0,
|
||||||
|
"observedGeneration": 0,
|
||||||
|
"replicas": 0,
|
||||||
|
"updatedReplicas": 0,
|
||||||
|
"availableReplicas": 0,
|
||||||
|
"unavailableReplicas": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "ImageStream",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "mysql",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "mysql"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"lookupPolicy": {
|
||||||
|
"local": false
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"annotations": null,
|
||||||
|
"from": {
|
||||||
|
"kind": "DockerImage",
|
||||||
|
"name": "mysql"
|
||||||
|
},
|
||||||
|
"generation": null,
|
||||||
|
"importPolicy": {},
|
||||||
|
"referencePolicy": {
|
||||||
|
"type": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"dockerImageRepository": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "DeploymentConfig",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "postgresql",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "postgresql"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.healthcheck.liveness.http_get_path": "/health",
|
||||||
|
"kompose.service.healthcheck.liveness.http_get_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.http_get_path": "/ready",
|
||||||
|
"kompose.service.healthcheck.readiness.http_get_port": "8080",
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "10s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "5",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"strategy": {
|
||||||
|
"resources": {}
|
||||||
|
},
|
||||||
|
"triggers": [
|
||||||
|
{
|
||||||
|
"type": "ConfigChange"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ImageChange",
|
||||||
|
"imageChangeParams": {
|
||||||
|
"automatic": true,
|
||||||
|
"containerNames": [
|
||||||
|
"postgresql"
|
||||||
|
],
|
||||||
|
"from": {
|
||||||
|
"kind": "ImageStreamTag",
|
||||||
|
"name": "postgresql:latest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"replicas": 1,
|
||||||
|
"test": false,
|
||||||
|
"selector": {
|
||||||
|
"io.kompose.service": "postgresql"
|
||||||
|
},
|
||||||
|
"template": {
|
||||||
|
"metadata": {
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "postgresql"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"containers": [
|
||||||
|
{
|
||||||
|
"name": "postgresql",
|
||||||
|
"image": " ",
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"containerPort": 5432
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resources": {},
|
||||||
|
"livenessProbe": {
|
||||||
|
"httpGet": {
|
||||||
|
"path": "/health",
|
||||||
|
"port": 8080
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 1,
|
||||||
|
"periodSeconds": 10,
|
||||||
|
"failureThreshold": 5
|
||||||
|
},
|
||||||
|
"readinessProbe": {
|
||||||
|
"httpGet": {
|
||||||
|
"path": "/ready",
|
||||||
|
"port": 8080
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 1,
|
||||||
|
"periodSeconds": 10,
|
||||||
|
"failureThreshold": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"restartPolicy": "Always"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"latestVersion": 0,
|
||||||
|
"observedGeneration": 0,
|
||||||
|
"replicas": 0,
|
||||||
|
"updatedReplicas": 0,
|
||||||
|
"availableReplicas": 0,
|
||||||
|
"unavailableReplicas": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "ImageStream",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "postgresql",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "postgresql"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"lookupPolicy": {
|
||||||
|
"local": false
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"annotations": null,
|
||||||
|
"from": {
|
||||||
|
"kind": "DockerImage",
|
||||||
|
"name": "postgresql"
|
||||||
|
},
|
||||||
|
"generation": null,
|
||||||
|
"importPolicy": {},
|
||||||
|
"referencePolicy": {
|
||||||
|
"type": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"dockerImageRepository": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "DeploymentConfig",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "redis",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "redis"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"kompose.service.healthcheck.readiness.interval": "10s",
|
||||||
|
"kompose.service.healthcheck.readiness.retries": "5",
|
||||||
|
"kompose.service.healthcheck.readiness.test": "echo \"liveness\"",
|
||||||
|
"kompose.service.healthcheck.readiness.timeout": "1s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"strategy": {
|
||||||
|
"resources": {}
|
||||||
|
},
|
||||||
|
"triggers": [
|
||||||
|
{
|
||||||
|
"type": "ConfigChange"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ImageChange",
|
||||||
|
"imageChangeParams": {
|
||||||
|
"automatic": true,
|
||||||
|
"containerNames": [
|
||||||
|
"redis"
|
||||||
|
],
|
||||||
|
"from": {
|
||||||
|
"kind": "ImageStreamTag",
|
||||||
|
"name": "redis:latest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"replicas": 1,
|
||||||
|
"test": false,
|
||||||
|
"selector": {
|
||||||
|
"io.kompose.service": "redis"
|
||||||
|
},
|
||||||
|
"template": {
|
||||||
|
"metadata": {
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "redis"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"containers": [
|
||||||
|
{
|
||||||
|
"name": "redis",
|
||||||
|
"image": " ",
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"containerPort": 6379
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"resources": {},
|
||||||
|
"livenessProbe": {
|
||||||
|
"exec": {
|
||||||
|
"command": [
|
||||||
|
"echo \"liveness\""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 1,
|
||||||
|
"periodSeconds": 10,
|
||||||
|
"failureThreshold": 5
|
||||||
|
},
|
||||||
|
"readinessProbe": {
|
||||||
|
"exec": {
|
||||||
|
"command": [
|
||||||
|
"echo",
|
||||||
|
"liveness"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"timeoutSeconds": 1,
|
||||||
|
"periodSeconds": 10,
|
||||||
|
"failureThreshold": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"restartPolicy": "Always"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"latestVersion": 0,
|
||||||
|
"observedGeneration": 0,
|
||||||
|
"replicas": 0,
|
||||||
|
"updatedReplicas": 0,
|
||||||
|
"availableReplicas": 0,
|
||||||
|
"unavailableReplicas": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "ImageStream",
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"metadata": {
|
||||||
|
"name": "redis",
|
||||||
|
"creationTimestamp": null,
|
||||||
|
"labels": {
|
||||||
|
"io.kompose.service": "redis"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"lookupPolicy": {
|
||||||
|
"local": false
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"annotations": null,
|
||||||
|
"from": {
|
||||||
|
"kind": "DockerImage",
|
||||||
|
"name": "redis"
|
||||||
|
},
|
||||||
|
"generation": null,
|
||||||
|
"importPolicy": {},
|
||||||
|
"referencePolicy": {
|
||||||
|
"type": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"dockerImageRepository": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user