From f3412a739926c4e9bb80c7a6541740b6eb6c6320 Mon Sep 17 00:00:00 2001 From: Hang Yan Date: Sun, 15 Apr 2018 00:23:48 +0800 Subject: [PATCH] Add headless service type label Also remove the relation between restart and service create --- docs/user-guide.md | 4 +- pkg/loader/compose/utils.go | 7 +- pkg/transformer/kubernetes/k8sutils.go | 9 +- pkg/transformer/kubernetes/k8sutils_test.go | 1 + pkg/transformer/kubernetes/kubernetes.go | 18 +- pkg/transformer/openshift/openshift.go | 20 +- pkg/transformer/openshift/openshift_test.go | 3 +- script/test/cmd/tests.sh | 9 +- .../buildargs/output-os-template.json | 62 ---- .../change-in-volume/docker-compose.yml | 2 + .../output-k8s-empty-vols-template.json | 2 + .../change-in-volume/output-k8s-template.json | 2 + .../change-in-volume/output-os-template.json | 2 + script/test/fixtures/domain/output-k8s.json | 31 -- script/test/fixtures/domain/output-os.json | 31 -- .../entrypoint-command/docker-compose.yml | 2 + .../output-k8s-template.json | 2 + .../output-os-template.json | 2 + .../output-k8s-template.json | 310 ------------------ .../fixtures/examples/output-voting-k8s.json | 31 -- .../fixtures/examples/output-voting-os.json | 31 -- .../test/fixtures/group-add/output-k8s.json | 31 -- script/test/fixtures/group-add/output-os.json | 31 -- .../docker-compose-only-command.yaml | 2 + .../fixtures/healthcheck/docker-compose.yaml | 2 + .../healthcheck/output-k8s-template.json | 2 + .../output-only-command-k8s-template.json | 2 + .../output-only-command-os-template.json | 2 + .../healthcheck/output-os-template.json | 2 + .../placement/output-k8s-array-template.json | 31 -- .../placement/output-k8s-template.json | 31 -- .../placement/output-os-array-template.json | 31 -- .../placement/output-os-template.json | 31 -- .../output-k8s-restart-unless-stopped.json | 31 -- .../output-os-restart-unless-stopped.json | 31 -- .../service-name-change/docker-compose.yml | 2 + .../output-k8s-template.json | 2 + .../output-os-template.json | 2 + .../v3/docker-compose-deploy-mode.yaml | 2 + .../test/fixtures/v3/docker-compose-env.yaml | 2 + .../v3/docker-compose-memcpu-partial.yaml | 2 + .../fixtures/v3/docker-compose-memcpu.yaml | 2 + .../fixtures/v3/docker-compose-unset-env.yaml | 2 + .../fixtures/v3/docker-compose-volumes.yaml | 2 + .../v3/output-deploy-mode-k8s-template.json | 2 + .../v3/output-deploy-mode-os-template.json | 2 + script/test/fixtures/v3/output-env-k8s.json | 2 + script/test/fixtures/v3/output-env-subs.json | 31 -- .../fixtures/v3/output-k8s-full-example.json | 143 ++++++++ .../test/fixtures/v3/output-memcpu-k8s.json | 2 + .../v3/output-memcpu-partial-k8s.json | 2 + .../fixtures/v3/output-os-full-example.json | 143 ++++++++ .../fixtures/v3/output-unset-env-k8s.json | 2 + .../v3/output-volumes-k8s-template.json | 2 + 54 files changed, 389 insertions(+), 801 deletions(-) diff --git a/docs/user-guide.md b/docs/user-guide.md index 52397730..5416536c 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -297,12 +297,12 @@ The currently supported options are: | Key | Value | |----------------------|-------------------------------------| -| kompose.service.type | nodeport / clusterip / loadbalancer | +| kompose.service.type | nodeport / clusterip / loadbalancer / headless | | kompose.service.expose | true / hostname | | kompose.service.expose.tls-secret | secret name | | kompose.volume.size | kubernetes supported volume size | -**Note**: `kompose.service.type` label should be defined with `ports` only, otherwise `kompose` will fail. +**Note**: `kompose.service.type` label should be defined with `ports` only (except for headless service), otherwise `kompose` will fail. diff --git a/pkg/loader/compose/utils.go b/pkg/loader/compose/utils.go index d776fce0..c7bef56b 100644 --- a/pkg/loader/compose/utils.go +++ b/pkg/loader/compose/utils.go @@ -33,6 +33,9 @@ const ( LabelServiceExpose = "kompose.service.expose" // LabelServiceExposeTLSSecret provides the name of the TLS secret to use with the Kubernetes ingress controller LabelServiceExposeTLSSecret = "kompose.service.expose.tls-secret" + + // ServiceTypeHeadless... + ServiceTypeHeadless = "Headless" ) // load environment variables from compose file @@ -100,8 +103,10 @@ func handleServiceType(ServiceType string) (string, error) { return string(api.ServiceTypeNodePort), nil case "loadbalancer": return string(api.ServiceTypeLoadBalancer), nil + case "headless": + return ServiceTypeHeadless, nil default: - return "", errors.New("Unknown value " + ServiceType + " , supported values are 'NodePort, ClusterIP or LoadBalancer'") + return "", errors.New("Unknown value " + ServiceType + " , supported values are 'nodeport, clusterip, headless or loadbalancer'") } } diff --git a/pkg/transformer/kubernetes/k8sutils.go b/pkg/transformer/kubernetes/k8sutils.go index 5a69321e..fb8262ac 100644 --- a/pkg/transformer/kubernetes/k8sutils.go +++ b/pkg/transformer/kubernetes/k8sutils.go @@ -301,7 +301,12 @@ func (k *Kubernetes) CreateService(name string, service kobject.ServiceConfig, o servicePorts := k.ConfigServicePorts(name, service) svc.Spec.Ports = servicePorts - svc.Spec.Type = api.ServiceType(service.ServiceType) + if service.ServiceType == "Headless" { + svc.Spec.Type = api.ServiceTypeClusterIP + svc.Spec.ClusterIP = "None" + } else { + svc.Spec.Type = api.ServiceType(service.ServiceType) + } // Configure annotations annotations := transformer.ConfigAnnotations(service) @@ -311,7 +316,7 @@ func (k *Kubernetes) CreateService(name string, service kobject.ServiceConfig, o } // CreateHeadlessService creates a k8s headless service. -// Thi is used for docker-compose services without ports. For such services we can't create regular Kubernetes Service. +// This is used for docker-compose services without ports. For such services we can't create regular Kubernetes Service. // and without Service Pods can't find each other using DNS names. // Instead of regular Kubernetes Service we create Headless Service. DNS of such service points directly to Pod IP address. // You can find more about Headless Services in Kubernetes documentation https://kubernetes.io/docs/user-guide/services/#headless-services diff --git a/pkg/transformer/kubernetes/k8sutils_test.go b/pkg/transformer/kubernetes/k8sutils_test.go index 9f9bc9fa..3273a3c6 100644 --- a/pkg/transformer/kubernetes/k8sutils_test.go +++ b/pkg/transformer/kubernetes/k8sutils_test.go @@ -364,6 +364,7 @@ func TestServiceWithoutPort(t *testing.T) { service := kobject.ServiceConfig{ ContainerName: "name", Image: "image", + ServiceType: "Headless", } komposeObject := kobject.KomposeObject{ diff --git a/pkg/transformer/kubernetes/kubernetes.go b/pkg/transformer/kubernetes/kubernetes.go index 24535a36..24ca6294 100644 --- a/pkg/transformer/kubernetes/kubernetes.go +++ b/pkg/transformer/kubernetes/kubernetes.go @@ -725,15 +725,17 @@ func (k *Kubernetes) Transform(komposeObject kobject.KomposeObject, opt kobject. objects = append(objects, pod) } else { objects = k.CreateKubernetesObjects(name, service, opt) - // If ports not provided in configuration we will not make service - if k.PortsExist(name, service) { - svc := k.CreateService(name, service, objects) - objects = append(objects, svc) + } - if service.ExposeService != "" { - objects = append(objects, k.initIngress(name, service, svc.Spec.Ports[0].Port)) - } - } else { + if k.PortsExist(name, service) { + svc := k.CreateService(name, service, objects) + objects = append(objects, svc) + + if service.ExposeService != "" { + objects = append(objects, k.initIngress(name, service, svc.Spec.Ports[0].Port)) + } + } else { + if service.ServiceType == "Headless" { svc := k.CreateHeadlessService(name, service, objects) objects = append(objects, svc) } diff --git a/pkg/transformer/openshift/openshift.go b/pkg/transformer/openshift/openshift.go index 7d0b3983..fcc04e57 100644 --- a/pkg/transformer/openshift/openshift.go +++ b/pkg/transformer/openshift/openshift.go @@ -384,18 +384,18 @@ func (o *OpenShift) Transform(komposeObject kobject.KomposeObject, opt kobject.C log.Infof("Buildconfig using %s::%s as source.", buildRepo, buildBranch) } - // If ports not provided in configuration we will not make service - if o.PortsExist(name, service) { - svc := o.CreateService(name, service, objects) - objects = append(objects, svc) + } - if service.ExposeService != "" { - objects = append(objects, o.initRoute(name, service, svc.Spec.Ports[0].Port)) - } - } else { - svc := o.CreateHeadlessService(name, service, objects) - objects = append(objects, svc) + if o.PortsExist(name, service) { + svc := o.CreateService(name, service, objects) + objects = append(objects, svc) + + if service.ExposeService != "" { + objects = append(objects, o.initRoute(name, service, svc.Spec.Ports[0].Port)) } + } else if service.ServiceType == "Headless" { + svc := o.CreateHeadlessService(name, service, objects) + objects = append(objects, svc) } err := o.UpdateKubernetesObjects(name, service, opt, &objects) diff --git a/pkg/transformer/openshift/openshift_test.go b/pkg/transformer/openshift/openshift_test.go index ebf346b3..1073e9f7 100644 --- a/pkg/transformer/openshift/openshift_test.go +++ b/pkg/transformer/openshift/openshift_test.go @@ -347,11 +347,12 @@ func TestInitBuildConfig(t *testing.T) { } } -// TestServiceWithoutPort this tests if Headless Service is created for services without Port. +// TestServiceWithoutPort this tests if Headless Service is created for services without Port (with label) func TestServiceWithoutPort(t *testing.T) { service := kobject.ServiceConfig{ ContainerName: "name", Image: "image", + ServiceType: "Headless", } komposeObject := kobject.KomposeObject{ diff --git a/script/test/cmd/tests.sh b/script/test/cmd/tests.sh index cc558155..34998bf3 100755 --- a/script/test/cmd/tests.sh +++ b/script/test/cmd/tests.sh @@ -624,10 +624,14 @@ convert::expect_success "$cmd" "/tmp/output-os.json" # Test the "full example" from https://raw.githubusercontent.com/aanand/compose-file/master/loader/example1.env # Kubernetes -convert::expect_success_and_warning "kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-full-example.yaml" "$KOMPOSE_ROOT/script/test/fixtures/v3/output-k8s-full-example.json" +cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-full-example.yaml" +sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/v3/output-k8s-full-example.json" > /tmp/output-k8s.json +convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" # Openshift -convert::expect_success_and_warning "kompose convert --provider=openshift --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-full-example.yaml" "$KOMPOSE_ROOT/script/test/fixtures/v3/output-os-full-example.json" +cmd="kompose convert --provider=openshift --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-full-example.yaml" +sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/v3/output-os-full-example.json" > /tmp/output-os.json +convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" ### Test for docker-compose files present in Examples Directory @@ -688,6 +692,7 @@ convert::expect_success "$cmd" "/tmp/output-os.json" # voting # Kubernetes +# This test also contains headless service test (not create by default) cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/examples/docker-voting.yaml" sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/examples/output-voting-k8s.json > /tmp/output-k8s.json convert::expect_success "$cmd" "/tmp/output-k8s.json" diff --git a/script/test/fixtures/buildargs/output-os-template.json b/script/test/fixtures/buildargs/output-os-template.json index d154f79e..0067fe82 100644 --- a/script/test/fixtures/buildargs/output-os-template.json +++ b/script/test/fixtures/buildargs/output-os-template.json @@ -3,68 +3,6 @@ "apiVersion": "v1", "metadata": {}, "items": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "foo", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "foo" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "foo" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "foo1", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "foo1" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "foo1" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "DeploymentConfig", "apiVersion": "v1", diff --git a/script/test/fixtures/change-in-volume/docker-compose.yml b/script/test/fixtures/change-in-volume/docker-compose.yml index 58db102a..09d2276f 100644 --- a/script/test/fixtures/change-in-volume/docker-compose.yml +++ b/script/test/fixtures/change-in-volume/docker-compose.yml @@ -11,3 +11,5 @@ services: - redis redis: image: redis + labels: + kompose.service.type: headless diff --git a/script/test/fixtures/change-in-volume/output-k8s-empty-vols-template.json b/script/test/fixtures/change-in-volume/output-k8s-empty-vols-template.json index c28412e5..94602ed5 100644 --- a/script/test/fixtures/change-in-volume/output-k8s-empty-vols-template.json +++ b/script/test/fixtures/change-in-volume/output-k8s-empty-vols-template.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -75,6 +76,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/change-in-volume/output-k8s-template.json b/script/test/fixtures/change-in-volume/output-k8s-template.json index 04c5c622..44d19db3 100644 --- a/script/test/fixtures/change-in-volume/output-k8s-template.json +++ b/script/test/fixtures/change-in-volume/output-k8s-template.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -75,6 +76,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/change-in-volume/output-os-template.json b/script/test/fixtures/change-in-volume/output-os-template.json index bc134858..05d5c299 100644 --- a/script/test/fixtures/change-in-volume/output-os-template.json +++ b/script/test/fixtures/change-in-volume/output-os-template.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -75,6 +76,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/domain/output-k8s.json b/script/test/fixtures/domain/output-k8s.json index 8839a950..9a1d76fe 100644 --- a/script/test/fixtures/domain/output-k8s.json +++ b/script/test/fixtures/domain/output-k8s.json @@ -3,37 +3,6 @@ "apiVersion": "v1", "metadata": {}, "items": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "dns", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "dns" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "dns" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "Deployment", "apiVersion": "extensions/v1beta1", diff --git a/script/test/fixtures/domain/output-os.json b/script/test/fixtures/domain/output-os.json index 1192ae37..6f18377b 100644 --- a/script/test/fixtures/domain/output-os.json +++ b/script/test/fixtures/domain/output-os.json @@ -3,37 +3,6 @@ "apiVersion": "v1", "metadata": {}, "items": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "dns", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "dns" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "dns" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "DeploymentConfig", "apiVersion": "v1", diff --git a/script/test/fixtures/entrypoint-command/docker-compose.yml b/script/test/fixtures/entrypoint-command/docker-compose.yml index 7a6c3366..ba44d231 100644 --- a/script/test/fixtures/entrypoint-command/docker-compose.yml +++ b/script/test/fixtures/entrypoint-command/docker-compose.yml @@ -5,3 +5,5 @@ services: image: busybox entrypoint: echo command: foo + labels: + kompose.service.type: headless diff --git a/script/test/fixtures/entrypoint-command/output-k8s-template.json b/script/test/fixtures/entrypoint-command/output-k8s-template.json index 18fbd39c..51661eed 100644 --- a/script/test/fixtures/entrypoint-command/output-k8s-template.json +++ b/script/test/fixtures/entrypoint-command/output-k8s-template.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -45,6 +46,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/entrypoint-command/output-os-template.json b/script/test/fixtures/entrypoint-command/output-os-template.json index 307ce6dd..4cf92c27 100644 --- a/script/test/fixtures/entrypoint-command/output-os-template.json +++ b/script/test/fixtures/entrypoint-command/output-os-template.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -45,6 +46,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/envvars-separators/output-k8s-template.json b/script/test/fixtures/envvars-separators/output-k8s-template.json index fdec8001..c5d6ada0 100644 --- a/script/test/fixtures/envvars-separators/output-k8s-template.json +++ b/script/test/fixtures/envvars-separators/output-k8s-template.json @@ -33,285 +33,6 @@ "loadBalancer": {} } }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "hygieia-bitbucket-scm-collector", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "hygieia-bitbucket-scm-collector" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "hygieia-bitbucket-scm-collector" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "hygieia-chat-ops-collector", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "hygieia-chat-ops-collector" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "hygieia-chat-ops-collector" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "hygieia-github-scm-collector", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "hygieia-github-scm-collector" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "hygieia-github-scm-collector" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "hygieia-jenkins-build-collector", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "hygieia-jenkins-build-collector" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "hygieia-jenkins-build-collector" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "hygieia-jenkins-cucumber-test-collector", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "hygieia-jenkins-cucumber-test-collector" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "hygieia-jenkins-cucumber-test-collector" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "hygieia-jira-feature-collector", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "hygieia-jira-feature-collector" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "hygieia-jira-feature-collector" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "hygieia-sonar-codequality-collector", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "hygieia-sonar-codequality-collector" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "hygieia-sonar-codequality-collector" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "hygieia-subversion-scm-collector", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "hygieia-subversion-scm-collector" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "hygieia-subversion-scm-collector" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "hygieia-udeploy-collector", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "hygieia-udeploy-collector" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "hygieia-udeploy-collector" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "Service", "apiVersion": "v1", @@ -342,37 +63,6 @@ "loadBalancer": {} } }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "hygieia-versionone-collector", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "hygieia-versionone-collector" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "hygieia-versionone-collector" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "Service", "apiVersion": "v1", diff --git a/script/test/fixtures/examples/output-voting-k8s.json b/script/test/fixtures/examples/output-voting-k8s.json index 163c99e9..59d1c7a5 100644 --- a/script/test/fixtures/examples/output-voting-k8s.json +++ b/script/test/fixtures/examples/output-voting-k8s.json @@ -125,37 +125,6 @@ "loadBalancer": {} } }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "worker", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "worker" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "worker" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "Deployment", "apiVersion": "extensions/v1beta1", diff --git a/script/test/fixtures/examples/output-voting-os.json b/script/test/fixtures/examples/output-voting-os.json index 227bee65..1fb82e9a 100644 --- a/script/test/fixtures/examples/output-voting-os.json +++ b/script/test/fixtures/examples/output-voting-os.json @@ -125,37 +125,6 @@ "loadBalancer": {} } }, - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "worker", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "worker" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "worker" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "DeploymentConfig", "apiVersion": "v1", diff --git a/script/test/fixtures/group-add/output-k8s.json b/script/test/fixtures/group-add/output-k8s.json index 66f34e07..b74d2fdf 100644 --- a/script/test/fixtures/group-add/output-k8s.json +++ b/script/test/fixtures/group-add/output-k8s.json @@ -3,37 +3,6 @@ "apiVersion": "v1", "metadata": {}, "items": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "myservice", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "myservice" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "myservice" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "Deployment", "apiVersion": "extensions/v1beta1", diff --git a/script/test/fixtures/group-add/output-os.json b/script/test/fixtures/group-add/output-os.json index 090d3bde..273ecc93 100644 --- a/script/test/fixtures/group-add/output-os.json +++ b/script/test/fixtures/group-add/output-os.json @@ -3,37 +3,6 @@ "apiVersion": "v1", "metadata": {}, "items": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "myservice", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "myservice" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "myservice" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "DeploymentConfig", "apiVersion": "v1", diff --git a/script/test/fixtures/healthcheck/docker-compose-only-command.yaml b/script/test/fixtures/healthcheck/docker-compose-only-command.yaml index ee5cc0d1..73f22596 100644 --- a/script/test/fixtures/healthcheck/docker-compose-only-command.yaml +++ b/script/test/fixtures/healthcheck/docker-compose-only-command.yaml @@ -3,5 +3,7 @@ version: "3" services: redis: image: redis + labels: + kompose.service.type: headless healthcheck: test: echo "hello world" diff --git a/script/test/fixtures/healthcheck/docker-compose.yaml b/script/test/fixtures/healthcheck/docker-compose.yaml index 6ce92c4a..1a3b139c 100644 --- a/script/test/fixtures/healthcheck/docker-compose.yaml +++ b/script/test/fixtures/healthcheck/docker-compose.yaml @@ -3,6 +3,8 @@ version: "3" services: redis: image: redis + labels: + kompose.service.type: headless healthcheck: test: echo "hello world" interval: 10s diff --git a/script/test/fixtures/healthcheck/output-k8s-template.json b/script/test/fixtures/healthcheck/output-k8s-template.json index ee4965b9..dd86ae5c 100644 --- a/script/test/fixtures/healthcheck/output-k8s-template.json +++ b/script/test/fixtures/healthcheck/output-k8s-template.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -45,6 +46,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/healthcheck/output-only-command-k8s-template.json b/script/test/fixtures/healthcheck/output-only-command-k8s-template.json index 155e8756..b0412fd3 100644 --- a/script/test/fixtures/healthcheck/output-only-command-k8s-template.json +++ b/script/test/fixtures/healthcheck/output-only-command-k8s-template.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -45,6 +46,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/healthcheck/output-only-command-os-template.json b/script/test/fixtures/healthcheck/output-only-command-os-template.json index 7234f3ce..89213491 100644 --- a/script/test/fixtures/healthcheck/output-only-command-os-template.json +++ b/script/test/fixtures/healthcheck/output-only-command-os-template.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -45,6 +46,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/healthcheck/output-os-template.json b/script/test/fixtures/healthcheck/output-os-template.json index bfe21eb1..d7cb588f 100644 --- a/script/test/fixtures/healthcheck/output-os-template.json +++ b/script/test/fixtures/healthcheck/output-os-template.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -45,6 +46,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/placement/output-k8s-array-template.json b/script/test/fixtures/placement/output-k8s-array-template.json index 89db8079..84a8bbb9 100644 --- a/script/test/fixtures/placement/output-k8s-array-template.json +++ b/script/test/fixtures/placement/output-k8s-array-template.json @@ -3,37 +3,6 @@ "apiVersion": "v1", "metadata": {}, "items": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "db", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "db" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "db" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "Deployment", "apiVersion": "extensions/v1beta1", diff --git a/script/test/fixtures/placement/output-k8s-template.json b/script/test/fixtures/placement/output-k8s-template.json index 0b9506e1..57f07548 100644 --- a/script/test/fixtures/placement/output-k8s-template.json +++ b/script/test/fixtures/placement/output-k8s-template.json @@ -3,37 +3,6 @@ "apiVersion": "v1", "metadata": {}, "items": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "db", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "db" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "db" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "Deployment", "apiVersion": "extensions/v1beta1", diff --git a/script/test/fixtures/placement/output-os-array-template.json b/script/test/fixtures/placement/output-os-array-template.json index 65d00b4e..a85c95d6 100644 --- a/script/test/fixtures/placement/output-os-array-template.json +++ b/script/test/fixtures/placement/output-os-array-template.json @@ -3,37 +3,6 @@ "apiVersion": "v1", "metadata": {}, "items": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "db", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "db" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "db" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "DeploymentConfig", "apiVersion": "v1", diff --git a/script/test/fixtures/placement/output-os-template.json b/script/test/fixtures/placement/output-os-template.json index 466ff546..e44760b6 100644 --- a/script/test/fixtures/placement/output-os-template.json +++ b/script/test/fixtures/placement/output-os-template.json @@ -3,37 +3,6 @@ "apiVersion": "v1", "metadata": {}, "items": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "db", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "db" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "db" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "DeploymentConfig", "apiVersion": "v1", diff --git a/script/test/fixtures/restart-options/output-k8s-restart-unless-stopped.json b/script/test/fixtures/restart-options/output-k8s-restart-unless-stopped.json index c9b3e954..f7625940 100644 --- a/script/test/fixtures/restart-options/output-k8s-restart-unless-stopped.json +++ b/script/test/fixtures/restart-options/output-k8s-restart-unless-stopped.json @@ -3,37 +3,6 @@ "apiVersion": "v1", "metadata": {}, "items": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "foo", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "foo" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "foo" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "Deployment", "apiVersion": "extensions/v1beta1", diff --git a/script/test/fixtures/restart-options/output-os-restart-unless-stopped.json b/script/test/fixtures/restart-options/output-os-restart-unless-stopped.json index 32613c75..d9ba6798 100644 --- a/script/test/fixtures/restart-options/output-os-restart-unless-stopped.json +++ b/script/test/fixtures/restart-options/output-os-restart-unless-stopped.json @@ -3,37 +3,6 @@ "apiVersion": "v1", "metadata": {}, "items": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "foo", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "foo" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "foo" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "DeploymentConfig", "apiVersion": "v1", diff --git a/script/test/fixtures/service-name-change/docker-compose.yml b/script/test/fixtures/service-name-change/docker-compose.yml index deccb53a..ac2f0a8b 100644 --- a/script/test/fixtures/service-name-change/docker-compose.yml +++ b/script/test/fixtures/service-name-change/docker-compose.yml @@ -1,6 +1,8 @@ version: '2' services: mariadb: + labels: + kompose.service.type: headless image: 'bitnami/mariadb:latest' volumes: - 'mariadb-data:/bitnami/mariadb' diff --git a/script/test/fixtures/service-name-change/output-k8s-template.json b/script/test/fixtures/service-name-change/output-k8s-template.json index a58dcff8..e7c0a04b 100644 --- a/script/test/fixtures/service-name-change/output-k8s-template.json +++ b/script/test/fixtures/service-name-change/output-k8s-template.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -80,6 +81,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/service-name-change/output-os-template.json b/script/test/fixtures/service-name-change/output-os-template.json index 382ebd07..d3c8c841 100644 --- a/script/test/fixtures/service-name-change/output-os-template.json +++ b/script/test/fixtures/service-name-change/output-os-template.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -80,6 +81,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/v3/docker-compose-deploy-mode.yaml b/script/test/fixtures/v3/docker-compose-deploy-mode.yaml index 225a4ab9..75d836fd 100644 --- a/script/test/fixtures/v3/docker-compose-deploy-mode.yaml +++ b/script/test/fixtures/v3/docker-compose-deploy-mode.yaml @@ -2,6 +2,8 @@ version: "3" services: foo: + labels: + kompose.service.type: headless deploy: mode: global replicas: 6 diff --git a/script/test/fixtures/v3/docker-compose-env.yaml b/script/test/fixtures/v3/docker-compose-env.yaml index fd233c01..84d83110 100644 --- a/script/test/fixtures/v3/docker-compose-env.yaml +++ b/script/test/fixtures/v3/docker-compose-env.yaml @@ -1,6 +1,8 @@ version: '3' services: foo: + labels: + kompose.service.type: headless image: foo/bar:latest environment: FOO: foo diff --git a/script/test/fixtures/v3/docker-compose-memcpu-partial.yaml b/script/test/fixtures/v3/docker-compose-memcpu-partial.yaml index 7c9ac1bf..3a95c004 100644 --- a/script/test/fixtures/v3/docker-compose-memcpu-partial.yaml +++ b/script/test/fixtures/v3/docker-compose-memcpu-partial.yaml @@ -2,6 +2,8 @@ version: "3" services: foo: + labels: + kompose.service.type: headless deploy: resources: limits: diff --git a/script/test/fixtures/v3/docker-compose-memcpu.yaml b/script/test/fixtures/v3/docker-compose-memcpu.yaml index 98632c2b..70f63a10 100644 --- a/script/test/fixtures/v3/docker-compose-memcpu.yaml +++ b/script/test/fixtures/v3/docker-compose-memcpu.yaml @@ -2,6 +2,8 @@ version: "3" services: foo: + labels: + kompose.service.type: headless deploy: resources: limits: diff --git a/script/test/fixtures/v3/docker-compose-unset-env.yaml b/script/test/fixtures/v3/docker-compose-unset-env.yaml index e0434894..129ba32e 100644 --- a/script/test/fixtures/v3/docker-compose-unset-env.yaml +++ b/script/test/fixtures/v3/docker-compose-unset-env.yaml @@ -1,6 +1,8 @@ version: '3' services: foo: + labels: + kompose.service.type: headless image: foo/bar:latest environment: - BAR diff --git a/script/test/fixtures/v3/docker-compose-volumes.yaml b/script/test/fixtures/v3/docker-compose-volumes.yaml index 4cf547ac..d4350abb 100644 --- a/script/test/fixtures/v3/docker-compose-volumes.yaml +++ b/script/test/fixtures/v3/docker-compose-volumes.yaml @@ -3,6 +3,8 @@ version: "3" services: foobar: + labels: + kompose.service.type: headless image: foo/bar:latest volumes: - /tmp/foo/bar diff --git a/script/test/fixtures/v3/output-deploy-mode-k8s-template.json b/script/test/fixtures/v3/output-deploy-mode-k8s-template.json index 67e3c735..6d646512 100644 --- a/script/test/fixtures/v3/output-deploy-mode-k8s-template.json +++ b/script/test/fixtures/v3/output-deploy-mode-k8s-template.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -45,6 +46,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/v3/output-deploy-mode-os-template.json b/script/test/fixtures/v3/output-deploy-mode-os-template.json index 4fc0f438..57ea2aff 100644 --- a/script/test/fixtures/v3/output-deploy-mode-os-template.json +++ b/script/test/fixtures/v3/output-deploy-mode-os-template.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -45,6 +46,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/v3/output-env-k8s.json b/script/test/fixtures/v3/output-env-k8s.json index 40725a6a..8d9eeae0 100644 --- a/script/test/fixtures/v3/output-env-k8s.json +++ b/script/test/fixtures/v3/output-env-k8s.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -45,6 +46,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/v3/output-env-subs.json b/script/test/fixtures/v3/output-env-subs.json index 3ae095e7..0ff3312a 100644 --- a/script/test/fixtures/v3/output-env-subs.json +++ b/script/test/fixtures/v3/output-env-subs.json @@ -3,37 +3,6 @@ "apiVersion": "v1", "metadata": {}, "items": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "foo", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "foo" - }, - "annotations": { - "kompose.cmd": "%CMD%", - "kompose.version": "%VERSION%" - } - }, - "spec": { - "ports": [ - { - "name": "headless", - "port": 55555, - "targetPort": 0 - } - ], - "selector": { - "io.kompose.service": "foo" - }, - "clusterIP": "None" - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "Deployment", "apiVersion": "extensions/v1beta1", diff --git a/script/test/fixtures/v3/output-k8s-full-example.json b/script/test/fixtures/v3/output-k8s-full-example.json index a5541b69..aa62c86e 100644 --- a/script/test/fixtures/v3/output-k8s-full-example.json +++ b/script/test/fixtures/v3/output-k8s-full-example.json @@ -3,6 +3,149 @@ "apiVersion": "v1", "metadata": {}, "items": [ + { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "foo", + "creationTimestamp": null, + "labels": { + "io.kompose.service": "foo" + }, + "annotations": { + "com.example.description": "Accounting webapp", + "com.example.empty-label": "", + "com.example.number": "42", + "kompose.cmd": "%CMD%", + "kompose.version": "%VERSION%" + } + }, + "spec": { + "ports": [ + { + "name": "3000", + "port": 3000, + "targetPort": 3000 + }, + { + "name": "3000-TCP", + "port": 3000, + "targetPort": 3000 + }, + { + "name": "3001", + "port": 3001, + "targetPort": 3001 + }, + { + "name": "3002", + "port": 3002, + "targetPort": 3002 + }, + { + "name": "3003", + "port": 3003, + "targetPort": 3003 + }, + { + "name": "3004", + "port": 3004, + "targetPort": 3004 + }, + { + "name": "3005", + "port": 3005, + "targetPort": 3005 + }, + { + "name": "8000", + "port": 8000, + "targetPort": 8000 + }, + { + "name": "9090", + "port": 9090, + "targetPort": 8080 + }, + { + "name": "9091", + "port": 9091, + "targetPort": 8081 + }, + { + "name": "49100", + "port": 49100, + "targetPort": 22 + }, + { + "name": "8001", + "port": 8001, + "targetPort": 8001 + }, + { + "name": "5000", + "port": 5000, + "targetPort": 5000 + }, + { + "name": "5001", + "port": 5001, + "targetPort": 5001 + }, + { + "name": "5002", + "port": 5002, + "targetPort": 5002 + }, + { + "name": "5003", + "port": 5003, + "targetPort": 5003 + }, + { + "name": "5004", + "port": 5004, + "targetPort": 5004 + }, + { + "name": "5005", + "port": 5005, + "targetPort": 5005 + }, + { + "name": "5006", + "port": 5006, + "targetPort": 5006 + }, + { + "name": "5007", + "port": 5007, + "targetPort": 5007 + }, + { + "name": "5008", + "port": 5008, + "targetPort": 5008 + }, + { + "name": "5009", + "port": 5009, + "targetPort": 5009 + }, + { + "name": "5010", + "port": 5010, + "targetPort": 5010 + } + ], + "selector": { + "io.kompose.service": "foo" + } + }, + "status": { + "loadBalancer": {} + } + }, { "kind": "Pod", "apiVersion": "v1", diff --git a/script/test/fixtures/v3/output-memcpu-k8s.json b/script/test/fixtures/v3/output-memcpu-k8s.json index c6227b14..40b436dc 100644 --- a/script/test/fixtures/v3/output-memcpu-k8s.json +++ b/script/test/fixtures/v3/output-memcpu-k8s.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -45,6 +46,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/v3/output-memcpu-partial-k8s.json b/script/test/fixtures/v3/output-memcpu-partial-k8s.json index b333d2fb..164604d6 100644 --- a/script/test/fixtures/v3/output-memcpu-partial-k8s.json +++ b/script/test/fixtures/v3/output-memcpu-partial-k8s.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -45,6 +46,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/v3/output-os-full-example.json b/script/test/fixtures/v3/output-os-full-example.json index a5541b69..aa62c86e 100644 --- a/script/test/fixtures/v3/output-os-full-example.json +++ b/script/test/fixtures/v3/output-os-full-example.json @@ -3,6 +3,149 @@ "apiVersion": "v1", "metadata": {}, "items": [ + { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "foo", + "creationTimestamp": null, + "labels": { + "io.kompose.service": "foo" + }, + "annotations": { + "com.example.description": "Accounting webapp", + "com.example.empty-label": "", + "com.example.number": "42", + "kompose.cmd": "%CMD%", + "kompose.version": "%VERSION%" + } + }, + "spec": { + "ports": [ + { + "name": "3000", + "port": 3000, + "targetPort": 3000 + }, + { + "name": "3000-TCP", + "port": 3000, + "targetPort": 3000 + }, + { + "name": "3001", + "port": 3001, + "targetPort": 3001 + }, + { + "name": "3002", + "port": 3002, + "targetPort": 3002 + }, + { + "name": "3003", + "port": 3003, + "targetPort": 3003 + }, + { + "name": "3004", + "port": 3004, + "targetPort": 3004 + }, + { + "name": "3005", + "port": 3005, + "targetPort": 3005 + }, + { + "name": "8000", + "port": 8000, + "targetPort": 8000 + }, + { + "name": "9090", + "port": 9090, + "targetPort": 8080 + }, + { + "name": "9091", + "port": 9091, + "targetPort": 8081 + }, + { + "name": "49100", + "port": 49100, + "targetPort": 22 + }, + { + "name": "8001", + "port": 8001, + "targetPort": 8001 + }, + { + "name": "5000", + "port": 5000, + "targetPort": 5000 + }, + { + "name": "5001", + "port": 5001, + "targetPort": 5001 + }, + { + "name": "5002", + "port": 5002, + "targetPort": 5002 + }, + { + "name": "5003", + "port": 5003, + "targetPort": 5003 + }, + { + "name": "5004", + "port": 5004, + "targetPort": 5004 + }, + { + "name": "5005", + "port": 5005, + "targetPort": 5005 + }, + { + "name": "5006", + "port": 5006, + "targetPort": 5006 + }, + { + "name": "5007", + "port": 5007, + "targetPort": 5007 + }, + { + "name": "5008", + "port": 5008, + "targetPort": 5008 + }, + { + "name": "5009", + "port": 5009, + "targetPort": 5009 + }, + { + "name": "5010", + "port": 5010, + "targetPort": 5010 + } + ], + "selector": { + "io.kompose.service": "foo" + } + }, + "status": { + "loadBalancer": {} + } + }, { "kind": "Pod", "apiVersion": "v1", diff --git a/script/test/fixtures/v3/output-unset-env-k8s.json b/script/test/fixtures/v3/output-unset-env-k8s.json index 3a0f20ee..92c76c08 100644 --- a/script/test/fixtures/v3/output-unset-env-k8s.json +++ b/script/test/fixtures/v3/output-unset-env-k8s.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -45,6 +46,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, diff --git a/script/test/fixtures/v3/output-volumes-k8s-template.json b/script/test/fixtures/v3/output-volumes-k8s-template.json index f1822570..1507d1a4 100644 --- a/script/test/fixtures/v3/output-volumes-k8s-template.json +++ b/script/test/fixtures/v3/output-volumes-k8s-template.json @@ -14,6 +14,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } }, @@ -45,6 +46,7 @@ }, "annotations": { "kompose.cmd": "%CMD%", + "kompose.service.type": "headless", "kompose.version": "%VERSION%" } },