diff --git a/cmd/template_autogen_ingress_test.go b/cmd/template_autogen_ingress_test.go index f75bea5a..2f1e646e 100644 --- a/cmd/template_autogen_ingress_test.go +++ b/cmd/template_autogen_ingress_test.go @@ -213,7 +213,10 @@ func TestAutogeneratedIngressGeneration(t *testing.T) { want: "internal/testdata/node/autogen-templates/ingress-10", }, { - name: "test13 autogenerated route development service type override", + name: "test-development-service-type-override-a", + description: `this test should fail because the replacement type has no persistent label in the associated docker-compose file + realistically, this is not something that should be done on an already deployed service due to changing + service types not being properly supported`, args: testdata.GetSeedData( testdata.TestData{ ProjectName: "example-project", @@ -230,7 +233,32 @@ func TestAutogeneratedIngressGeneration(t *testing.T) { }, }, true), templatePath: "testoutput", - want: "internal/testdata/node/autogen-templates/ingress-11", + emptyDir: true, + want: "", + wantErr: true, + }, + { + name: "test-development-service-type-override-b", + description: `this test should pass because the replacement service type is just a basic type + realistically, this is not something that should be done on an already deployed service due to changing + service types not being properly supported`, + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + EnvironmentType: "development", + LagoonYAML: "internal/testdata/node/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + { + Name: "LAGOON_SERVICE_TYPES", + Value: "node:basic", + Scope: "build", + }, + }, + }, true), + templatePath: "testoutput", + want: "internal/testdata/node/autogen-templates/test-development-service-type-override", }, { name: "test14 autogenerated route development no service type override", diff --git a/cmd/template_lagoonservices_test.go b/cmd/template_lagoonservices_test.go index 786d3eb0..b0d8d2dd 100644 --- a/cmd/template_lagoonservices_test.go +++ b/cmd/template_lagoonservices_test.go @@ -480,6 +480,68 @@ func TestTemplateLagoonServices(t *testing.T) { templatePath: "testoutput", want: "internal/testdata/basic/service-templates/test-basic-spot-affinity", }, + { + name: "test-basic-persistent-name", + description: "tests a basic deployment with a persistent name", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "internal/testdata/basic/lagoon.persistent-name.yml", + ImageReferences: map[string]string{ + "basic": "harbor.example/example-project/main/basic@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + }, + }, true), + templatePath: "testoutput", + want: "internal/testdata/basic/service-templates/test-basic-persistent-name", + }, + { + name: "test-basic-persistent-names", + description: "tests a basic deployment with two services with persistent name", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "internal/testdata/basic/lagoon.persistent-name-2.yml", + ImageReferences: map[string]string{ + "basic": "harbor.example/example-project/main/basic@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + "basic2": "harbor.example/example-project/main/basic2@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + }, + }, true), + templatePath: "testoutput", + want: "internal/testdata/basic/service-templates/test-basic-persistent-names", + }, + { + name: "test-complex-persistent-names", + description: "tests a complex deployment with two services with persistent name", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "internal/testdata/complex/lagoon.persistent-name.yml", + ImageReferences: map[string]string{ + "cli": "harbor.example/example-project/main/cli@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + "gotenberg": "harbor.example/example-project/main/gotenberg@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + "nginx": "harbor.example/example-project/main/nginx@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + "opensearch": "harbor.example/example-project/main/opensearch@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + "php": "harbor.example/example-project/main/php@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + "rabbitmq": "harbor.example/example-project/main/rabbitmq@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + "redis": "harbor.example/example-project/main/redis@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + "redis-persist": "harbor.example/example-project/main/redis-persist@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + "redis-session": "harbor.example/example-project/main/redis-session@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + "queue-worker-entity-index": "harbor.example/example-project/main/queue-worker-entity-index@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + "queue-worker-priority-high": "harbor.example/example-project/main/queue-worker-priority-high@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + "queue-worker-priority-instant": "harbor.example/example-project/main/queue-worker-priority-instant@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + "queue-worker-priority-low": "harbor.example/example-project/main/queue-worker-priority-low@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + "queue-worker-priority-medium": "harbor.example/example-project/main/queue-worker-priority-medium@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8", + }, + }, true), + templatePath: "testoutput", + want: "internal/testdata/complex/service-templates/test-complex-persistent-names", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/internal/generator/buildvalues.go b/internal/generator/buildvalues.go index bc1a20c9..697cbd64 100644 --- a/internal/generator/buildvalues.go +++ b/internal/generator/buildvalues.go @@ -199,6 +199,7 @@ type ServiceValues struct { IsDBaaS bool `json:"isDBaaS"` IsSingle bool `json:"isSingle"` AdditionalVolumes []ServiceVolume `json:"additonalVolumes,omitempty"` + CreateDefaultVolume bool `json:"createDefaultVolume"` } type ImageBuild struct { diff --git a/internal/generator/generator.go b/internal/generator/generator.go index 0809f129..728a5e5e 100644 --- a/internal/generator/generator.go +++ b/internal/generator/generator.go @@ -424,6 +424,12 @@ func NewGenerator( return nil, err } + // strip out duplicate default volumes + err = flagDefaultVolumeCreation(&buildValues) + if err != nil { + return nil, err + } + if imageCacheBuildArgsJSON != "" { err = json.Unmarshal([]byte(imageCacheBuildArgsJSON), &buildValues.ImageCacheBuildArguments) if err != nil { diff --git a/internal/generator/services.go b/internal/generator/services.go index 1732e779..ed0e25d2 100644 --- a/internal/generator/services.go +++ b/internal/generator/services.go @@ -247,61 +247,6 @@ func composeToServiceValues( lagoonOverrideName = composeService } - // check if the service has any persistent labels, this is the path that the volume will be mounted to - servicePersistentPath := lagoon.CheckDockerComposeLagoonLabel(composeServiceValues.Labels, "lagoon.persistent") - if servicePersistentPath == "" { - // if there is no persistent path, check if the service type has a default path - if val, ok := servicetypes.ServiceTypes[lagoonType]; ok { - servicePersistentPath = val.Volumes.PersistentVolumePath - // check if the service type provides or consumes a default persistent volume - if (val.ProvidesPersistentVolume || val.ConsumesPersistentVolume) && servicePersistentPath == "" { - return nil, fmt.Errorf("label lagoon.persistent not defined for service %s, no valid mount path was found", composeService) - } - } - } - servicePersistentName := lagoon.CheckDockerComposeLagoonLabel(composeServiceValues.Labels, "lagoon.persistent.name") - if servicePersistentName == "" && servicePersistentPath != "" { - // if there is a persistent path defined, then set the persistent name to be the compose service if no persistent name is provided - // persistent name is used by joined services like nginx/php or cli or worker pods to mount another service volume - servicePersistentName = lagoonOverrideName - } - servicePersistentSize := lagoon.CheckDockerComposeLagoonLabel(composeServiceValues.Labels, "lagoon.persistent.size") - if servicePersistentSize == "" { - // if there is no persistent size, check if the service type has a default size allocated - if val, ok := servicetypes.ServiceTypes[lagoonType]; ok { - servicePersistentSize = val.Volumes.PersistentVolumeSize - // check if the service type provides persistent volume, and that a size was detected - if val.ProvidesPersistentVolume && servicePersistentSize == "" { - return nil, fmt.Errorf("label lagoon.persistent.size not defined for service %s, no valid size was found", composeService) - } - } - } - if servicePersistentSize != "" { - // check the provided size is a valid resource size for kubernetes - _, err := ValidateResourceSize(servicePersistentSize) - if err != nil { - return nil, fmt.Errorf("provided persistent volume size for %s is not valid: %v", servicePersistentName, err) - } - } - - // if any `lagoon.base.image` labels are set, we note them for docker pulling - // this allows us to refresh the docker-host's cache in cases where an image - // may have an update without a change in tag (i.e. "latest" tagged images) - baseimage := lagoon.CheckDockerComposeLagoonLabel(composeServiceValues.Labels, "lagoon.base.image") - if baseimage != "" { - baseImageWithTag, errs := determineRefreshImage(composeService, baseimage, buildValues.EnvironmentVariables) - if len(errs) > 0 { - for idx, err := range errs { - if idx+1 == len(errs) { - return nil, err - } else { - fmt.Println(err) - } - } - } - buildValues.ForcePullImages = append(buildValues.ForcePullImages, baseImageWithTag) - } - // if there are overrides defined in the lagoon API `LAGOON_SERVICE_TYPES` // handle those here if buildValues.ServiceTypeOverrides != nil { @@ -388,6 +333,61 @@ func composeToServiceValues( } } + // check if the service has any persistent labels, this is the path that the volume will be mounted to + servicePersistentPath := lagoon.CheckDockerComposeLagoonLabel(composeServiceValues.Labels, "lagoon.persistent") + if servicePersistentPath == "" { + // if there is no persistent path, check if the service type has a default path + if val, ok := servicetypes.ServiceTypes[lagoonType]; ok { + servicePersistentPath = val.Volumes.PersistentVolumePath + // check if the service type provides or consumes a default persistent volume + if (val.ProvidesPersistentVolume || val.ConsumesPersistentVolume) && servicePersistentPath == "" { + return nil, fmt.Errorf("label lagoon.persistent not defined for service %s, no valid mount path was found", composeService) + } + } + } + servicePersistentName := lagoon.CheckDockerComposeLagoonLabel(composeServiceValues.Labels, "lagoon.persistent.name") + if servicePersistentName == "" && servicePersistentPath != "" { + // if there is a persistent path defined, then set the persistent name to be the compose service if no persistent name is provided + // persistent name is used by joined services like nginx/php or cli or worker pods to mount another service volume + servicePersistentName = lagoonOverrideName + } + servicePersistentSize := lagoon.CheckDockerComposeLagoonLabel(composeServiceValues.Labels, "lagoon.persistent.size") + if servicePersistentSize == "" { + // if there is no persistent size, check if the service type has a default size allocated + if val, ok := servicetypes.ServiceTypes[lagoonType]; ok { + servicePersistentSize = val.Volumes.PersistentVolumeSize + // check if the service type provides persistent volume, and that a size was detected + if val.ProvidesPersistentVolume && servicePersistentSize == "" { + return nil, fmt.Errorf("label lagoon.persistent.size not defined for service %s, no valid size was found", composeService) + } + } + } + if servicePersistentSize != "" { + // check the provided size is a valid resource size for kubernetes + _, err := ValidateResourceSize(servicePersistentSize) + if err != nil { + return nil, fmt.Errorf("provided persistent volume size for %s is not valid: %v", servicePersistentName, err) + } + } + + // if any `lagoon.base.image` labels are set, we note them for docker pulling + // this allows us to refresh the docker-host's cache in cases where an image + // may have an update without a change in tag (i.e. "latest" tagged images) + baseimage := lagoon.CheckDockerComposeLagoonLabel(composeServiceValues.Labels, "lagoon.base.image") + if baseimage != "" { + baseImageWithTag, errs := determineRefreshImage(composeService, baseimage, buildValues.EnvironmentVariables) + if len(errs) > 0 { + for idx, err := range errs { + if idx+1 == len(errs) { + return nil, err + } else { + fmt.Println(err) + } + } + } + buildValues.ForcePullImages = append(buildValues.ForcePullImages, baseImageWithTag) + } + // calculate if this service needs any additional volumes attached from the calculated build volumes // additional volumes can only be attached to certain serviceVolumes, err := calculateServiceVolumes(buildValues, lagoonType, servicePersistentName, composeServiceValues.Labels) diff --git a/internal/generator/services_test.go b/internal/generator/services_test.go index 94d84323..2cd53e3a 100644 --- a/internal/generator/services_test.go +++ b/internal/generator/services_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + "github.com/andreyvit/diff" composetypes "github.com/compose-spec/compose-go/types" "github.com/uselagoon/build-deploy-tool/internal/dbaasclient" "github.com/uselagoon/build-deploy-tool/internal/helpers" @@ -19,10 +20,11 @@ func Test_composeToServiceValues(t *testing.T) { composeServiceValues composetypes.ServiceConfig } tests := []struct { - name string - args args - want *ServiceValues - wantErr bool + name string + description string + args args + want *ServiceValues + wantErr bool }{ { name: "test1", @@ -201,7 +203,9 @@ func Test_composeToServiceValues(t *testing.T) { wantErr: true, }, { - name: "test4 - variable servicetypes type override", + name: "test-variable-servicetypes-type-override", + description: `this test should fail to change the nginx service from nginx-php to nginx-php-persistent + this is because there is no lagoon.persistent labels on the dockercompose service to suit this change`, args: args{ buildValues: &BuildValues{ Namespace: "example-project-main", @@ -231,10 +235,46 @@ func Test_composeToServiceValues(t *testing.T) { }, }, }, + want: nil, + wantErr: true, + }, + { + name: "test-variable-servicetypes-type-override-b", + description: `this test should pasee and change the nginx service from nginx to basic + this is because there is nothing really special between these two services besides the port`, + args: args{ + buildValues: &BuildValues{ + Namespace: "example-project-main", + Project: "example-project", + ImageRegistry: "harbor.example", + Environment: "main", + Branch: "main", + BuildType: "branch", + ServiceTypeOverrides: &lagoon.EnvironmentVariable{ + Name: "LAGOON_SERVICE_TYPES", + Value: "nginx:basic,mariadb:mariadb-dbaas", + }, + LagoonYAML: lagoon.YAML{ + Environments: lagoon.Environments{ + "main": lagoon.Environment{}, + }, + }, + }, + composeService: "nginx", + composeServiceValues: composetypes.ServiceConfig{ + Labels: composetypes.Labels{ + "lagoon.type": "nginx", + }, + Build: &composetypes.BuildConfig{ + Context: ".", + Dockerfile: "../testdata/basic/docker/basic.dockerfile", + }, + }, + }, want: &ServiceValues{ Name: "nginx", OverrideName: "nginx", - Type: "nginx-php-persistent", + Type: "basic", AutogeneratedRoutesEnabled: true, AutogeneratedRoutesTLSAcme: true, InPodCronjobs: []lagoon.Cronjob{}, @@ -245,7 +285,6 @@ func Test_composeToServiceValues(t *testing.T) { DockerFile: "../testdata/basic/docker/basic.dockerfile", BuildImage: "harbor.example/example-project/main/nginx:latest", }, - BackupsEnabled: true, }, }, { @@ -558,6 +597,9 @@ func Test_composeToServiceValues(t *testing.T) { Type: "mariadb-single", AutogeneratedRoutesEnabled: false, AutogeneratedRoutesTLSAcme: false, + PersistentVolumePath: "/var/lib/mysql", + PersistentVolumeName: "mariadb", + PersistentVolumeSize: "5Gi", DBaaSEnvironment: "development2", InPodCronjobs: []lagoon.Cronjob{}, NativeCronjobs: []lagoon.Cronjob{}, @@ -1252,10 +1294,10 @@ func Test_composeToServiceValues(t *testing.T) { t.Errorf("composeToServiceValues() error = %v, wantErr %v", err, tt.wantErr) return } - lValues, _ := json.Marshal(got) - wValues, _ := json.Marshal(tt.want) - if !reflect.DeepEqual(string(lValues), string(wValues)) { - t.Errorf("composeToServiceValues() = %v, want %v", string(lValues), string(wValues)) + f1, _ := json.MarshalIndent(got, "", " ") + r1, _ := json.MarshalIndent(tt.want, "", " ") + if !reflect.DeepEqual(f1, r1) { + t.Errorf("composeToServiceValues() = \n%v", diff.LineDiff(string(r1), string(f1))) } }) } diff --git a/internal/generator/volumes.go b/internal/generator/volumes.go index 00740d15..3b852c8d 100644 --- a/internal/generator/volumes.go +++ b/internal/generator/volumes.go @@ -124,3 +124,25 @@ func calculateServiceVolumes(buildValues *BuildValues, lagoonType, servicePersis return serviceVolumes, nil } + +// flagDefaultVolumeCreation checks services for duplicate default volumes and flags only the ones that need to be created +// this will ensure that a service type that provides a volume will create that volume +// even if the `lagoon.persistent.name` is different to the default name being the service name +// due to the way labels in docker-compose can be added to services for lagoon, this allows multiple types to mount one shared volume by name +// from one main service, across multiple services by using the `lagoon.persistent.name` value +func flagDefaultVolumeCreation( + buildValues *BuildValues, +) error { + vols := make(map[string]bool) + for idx, service := range buildValues.Services { + if sType, ok := servicetypes.ServiceTypes[service.Type]; ok && service.PersistentVolumeName != "" { + if _, ok := vols[service.PersistentVolumeName]; !ok && sType.ProvidesPersistentVolume { + // this volume is the one to be created by the first service that provides a persistent volume + service.CreateDefaultVolume = true + vols[service.PersistentVolumeName] = true + buildValues.Services[idx] = service + } + } + } + return nil +} diff --git a/internal/generator/volumes_test.go b/internal/generator/volumes_test.go new file mode 100644 index 00000000..645caef8 --- /dev/null +++ b/internal/generator/volumes_test.go @@ -0,0 +1,122 @@ +package generator + +import ( + "encoding/json" + "reflect" + "testing" + + "github.com/andreyvit/diff" + "github.com/uselagoon/build-deploy-tool/internal/lagoon" +) + +func Test_flagDefaultVolumeCreation(t *testing.T) { + type args struct { + } + tests := []struct { + name string + buildValues *BuildValues + want []ServiceValues + wantErr bool + }{ + { + name: "test1", + buildValues: &BuildValues{ + Services: []ServiceValues{ + { + Name: "nginx", + OverrideName: "nginx", + Type: "nginx-php-persistent", + AutogeneratedRoutesEnabled: true, + AutogeneratedRoutesTLSAcme: true, + InPodCronjobs: []lagoon.Cronjob{}, + NativeCronjobs: []lagoon.Cronjob{}, + PersistentVolumeSize: "5Gi", + ImageBuild: &ImageBuild{ + TemporaryImage: "example-project-main-nginx", + Context: ".", + DockerFile: "../testdata/basic/docker/basic.dockerfile", + BuildImage: "harbor.example/example-project/main/nginx:latest", + }, + PersistentVolumeName: "nginx", + PersistentVolumePath: "/app/docroot/sites/default/files/", + BackupsEnabled: true, + }, + }, + }, + want: []ServiceValues{ + { + Name: "nginx", + OverrideName: "nginx", + Type: "nginx-php-persistent", + AutogeneratedRoutesEnabled: true, + AutogeneratedRoutesTLSAcme: true, + InPodCronjobs: []lagoon.Cronjob{}, + NativeCronjobs: []lagoon.Cronjob{}, + PersistentVolumeSize: "5Gi", + ImageBuild: &ImageBuild{ + TemporaryImage: "example-project-main-nginx", + Context: ".", + DockerFile: "../testdata/basic/docker/basic.dockerfile", + BuildImage: "harbor.example/example-project/main/nginx:latest", + }, + PersistentVolumeName: "nginx", + PersistentVolumePath: "/app/docroot/sites/default/files/", + BackupsEnabled: true, + CreateDefaultVolume: true, + }, + }, + }, + { + name: "test2", + buildValues: &BuildValues{ + Services: []ServiceValues{ + { + Name: "basic", + OverrideName: "basic", + Type: "basic-persistent", + PersistentVolumeSize: "5Gi", + PersistentVolumeName: "basic-data", + PersistentVolumePath: "/basic-data/", + }, + { + Name: "basic2", + OverrideName: "basic2", + Type: "basic-persistent", + PersistentVolumeName: "basic-data", + PersistentVolumePath: "/basic-data/", + }, + }, + }, + want: []ServiceValues{ + { + Name: "basic", + OverrideName: "basic", + Type: "basic-persistent", + PersistentVolumeSize: "5Gi", + PersistentVolumeName: "basic-data", + PersistentVolumePath: "/basic-data/", + CreateDefaultVolume: true, + }, + { + Name: "basic2", + OverrideName: "basic2", + Type: "basic-persistent", + PersistentVolumeName: "basic-data", + PersistentVolumePath: "/basic-data/", + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := flagDefaultVolumeCreation(tt.buildValues); (err != nil) != tt.wantErr { + t.Errorf("flagDefaultVolumeCreation() error = %v, wantErr %v", err, tt.wantErr) + } + f1, _ := json.MarshalIndent(tt.buildValues.Services, "", " ") + r1, _ := json.MarshalIndent(tt.want, "", " ") + if !reflect.DeepEqual(f1, r1) { + t.Errorf("flagDefaultVolumeCreation() = \n%v", diff.LineDiff(string(r1), string(f1))) + } + }) + } +} diff --git a/internal/templating/services/templates_pvc.go b/internal/templating/services/templates_pvc.go index 7f0da966..83fcd14e 100644 --- a/internal/templating/services/templates_pvc.go +++ b/internal/templating/services/templates_pvc.go @@ -51,7 +51,7 @@ func GeneratePVCTemplate( // iterate over them and generate any kubernetes services for _, serviceValues := range checkedServices { if val, ok := servicetypes.ServiceTypes[serviceValues.Type]; ok { - if val.Volumes.PersistentVolumeSize != "" { + if serviceValues.CreateDefaultVolume { pvc, err := generateDefaultPVC(buildValues, serviceValues, val, labels, annotations) if err != nil { return nil, err @@ -92,14 +92,6 @@ func generateDefaultPVC(buildValues generator.BuildValues, val servicetypes.ServiceType, labels, annotations map[string]string, ) (*corev1.PersistentVolumeClaim, error) { - if serviceValues.PersistentVolumeName != "" { - if serviceValues.PersistentVolumeName != serviceValues.OverrideName { - // this service base volume is not needed because it is created by a different service - // lagoon legacy templates allowed due to a funny templating issue, for multiple "basic" types to mount one volume - // from one main service, across multiple services of the same type - return nil, nil - } - } serviceTypeValues := &servicetypes.ServiceType{} helpers.DeepCopy(val, serviceTypeValues) persistentVolumeSize := serviceTypeValues.Volumes.PersistentVolumeSize @@ -127,7 +119,7 @@ func generateDefaultPVC(buildValues generator.BuildValues, APIVersion: corev1.SchemeGroupVersion.Version, }, ObjectMeta: metav1.ObjectMeta{ - Name: serviceValues.OverrideName, + Name: serviceValues.PersistentVolumeName, }, } diff --git a/internal/templating/services/templates_pvc_test.go b/internal/templating/services/templates_pvc_test.go index e92731e4..811c522d 100644 --- a/internal/templating/services/templates_pvc_test.go +++ b/internal/templating/services/templates_pvc_test.go @@ -47,25 +47,33 @@ func TestGeneratePVCTemplate(t *testing.T) { ServicePort: 8080, }, { - Name: "myservice-persist", - OverrideName: "myservice-persist", - Type: "basic-persistent", - DBaaSEnvironment: "development", + Name: "myservice-persist", + OverrideName: "myservice-persist", + Type: "basic-persistent", + DBaaSEnvironment: "development", + PersistentVolumeName: "myservice-persist", + PersistentVolumeSize: "5Gi", + CreateDefaultVolume: true, }, { - Name: "myservice-persist-po", - OverrideName: "myservice-persist-po", - Type: "basic-persistent", - DBaaSEnvironment: "development", - ServicePort: 8080, + Name: "myservice-persist-po", + OverrideName: "myservice-persist-po", + Type: "basic-persistent", + DBaaSEnvironment: "development", + ServicePort: 8080, + PersistentVolumeName: "myservice-persist-po", + PersistentVolumeSize: "5Gi", + CreateDefaultVolume: true, }, { Name: "myservice-persist-po", OverrideName: "myservice-persist-po", Type: "basic-persistent", DBaaSEnvironment: "development", + PersistentVolumeName: "myservice-persist-po", ServicePort: 8080, PersistentVolumeSize: "100Gi", + CreateDefaultVolume: true, }, }, }, @@ -116,17 +124,22 @@ func TestGeneratePVCTemplate(t *testing.T) { Branch: "environment-name", Services: []generator.ServiceValues{ { - Name: "myservice", - OverrideName: "myservice", - Type: "elasticsearch", - DBaaSEnvironment: "development", + Name: "myservice", + OverrideName: "myservice", + Type: "elasticsearch", + DBaaSEnvironment: "development", + PersistentVolumeName: "myservice", + PersistentVolumeSize: "5Gi", + CreateDefaultVolume: true, }, { Name: "myservice-size", OverrideName: "myservice-size", Type: "elasticsearch", DBaaSEnvironment: "development", + PersistentVolumeName: "myservice-size", PersistentVolumeSize: "100Gi", + CreateDefaultVolume: true, }, }, }, @@ -147,17 +160,22 @@ func TestGeneratePVCTemplate(t *testing.T) { Branch: "environment-name", Services: []generator.ServiceValues{ { - Name: "myservice", - OverrideName: "myservice", - Type: "opensearch", - DBaaSEnvironment: "development", + Name: "myservice", + OverrideName: "myservice", + Type: "opensearch", + DBaaSEnvironment: "development", + PersistentVolumeName: "myservice", + PersistentVolumeSize: "5Gi", + CreateDefaultVolume: true, }, { Name: "myservice-size", OverrideName: "myservice-size", Type: "opensearch", DBaaSEnvironment: "development", + PersistentVolumeName: "myservice-size", PersistentVolumeSize: "100Gi", + CreateDefaultVolume: true, }, }, }, @@ -178,10 +196,13 @@ func TestGeneratePVCTemplate(t *testing.T) { Branch: "environment-name", Services: []generator.ServiceValues{ { - Name: "myservice", - OverrideName: "myservice", - Type: "postgres-single", - DBaaSEnvironment: "development", + Name: "myservice", + OverrideName: "myservice", + Type: "postgres-single", + DBaaSEnvironment: "development", + PersistentVolumeName: "myservice", + PersistentVolumeSize: "5Gi", + CreateDefaultVolume: true, }, }, }, @@ -203,10 +224,13 @@ func TestGeneratePVCTemplate(t *testing.T) { RWX2RWO: true, Services: []generator.ServiceValues{ { - Name: "myservice-persist", - OverrideName: "myservice-persist", - Type: "basic-persistent", - DBaaSEnvironment: "development", + Name: "myservice-persist", + OverrideName: "myservice-persist", + Type: "basic-persistent", + DBaaSEnvironment: "development", + PersistentVolumeName: "myservice-persist", + PersistentVolumeSize: "5Gi", + CreateDefaultVolume: true, }, }, }, diff --git a/internal/testdata/basic/docker-compose.persistent-name-2.yml b/internal/testdata/basic/docker-compose.persistent-name-2.yml new file mode 100644 index 00000000..bc854122 --- /dev/null +++ b/internal/testdata/basic/docker-compose.persistent-name-2.yml @@ -0,0 +1,30 @@ +version: '2' +services: + basic: + build: + context: internal/testdata/basic/docker + dockerfile: basic.dockerfile + labels: + lagoon.service.port: 5672 + lagoon.service.usecomposeports: true + lagoon.autogeneratedroute: false + lagoon.type: basic-persistent + lagoon.persistent: /var/lib/basic + lagoon.persistent.name: basic-data + ports: + - '5672' + - '15672:15672' + basic2: + build: + context: internal/testdata/basic/docker + dockerfile: basic.dockerfile + labels: + lagoon.service.port: 5672 + lagoon.service.usecomposeports: true + lagoon.autogeneratedroute: false + lagoon.type: basic-persistent + lagoon.persistent: /var/lib/basic + lagoon.persistent.name: basic-data + ports: + - '5672' + - '15672:15672' diff --git a/internal/testdata/basic/docker-compose.persistent-name.yml b/internal/testdata/basic/docker-compose.persistent-name.yml new file mode 100644 index 00000000..e315f840 --- /dev/null +++ b/internal/testdata/basic/docker-compose.persistent-name.yml @@ -0,0 +1,16 @@ +version: '2' +services: + basic: + build: + context: internal/testdata/basic/docker + dockerfile: basic.dockerfile + labels: + lagoon.service.port: 5672 + lagoon.service.usecomposeports: true + lagoon.autogeneratedroute: false + lagoon.type: basic-persistent + lagoon.persistent: /var/lib/basic + lagoon.persistent.name: basic-data + ports: + - '5672' + - '15672:15672' diff --git a/internal/testdata/basic/lagoon.persistent-name-2.yml b/internal/testdata/basic/lagoon.persistent-name-2.yml new file mode 100644 index 00000000..e7ffa8c7 --- /dev/null +++ b/internal/testdata/basic/lagoon.persistent-name-2.yml @@ -0,0 +1,10 @@ +docker-compose-yaml: internal/testdata/basic/docker-compose.persistent-name-2.yml + +environment_variables: + git_sha: "true" + +environments: + main: + routes: + - node: + - example.com diff --git a/internal/testdata/basic/lagoon.persistent-name.yml b/internal/testdata/basic/lagoon.persistent-name.yml new file mode 100644 index 00000000..b857e962 --- /dev/null +++ b/internal/testdata/basic/lagoon.persistent-name.yml @@ -0,0 +1,10 @@ +docker-compose-yaml: internal/testdata/basic/docker-compose.persistent-name.yml + +environment_variables: + git_sha: "true" + +environments: + main: + routes: + - node: + - example.com diff --git a/internal/testdata/basic/service-templates/test-basic-persistent-name/deployment-basic.yaml b/internal/testdata/basic/service-templates/test-basic-persistent-name/deployment-basic.yaml new file mode 100644 index 00000000..23ded318 --- /dev/null +++ b/internal/testdata/basic/service-templates/test-basic-persistent-name/deployment-basic.yaml @@ -0,0 +1,93 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: basic + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: basic + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + name: basic +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: basic + app.kubernetes.io/name: basic-persistent + strategy: {} + template: + metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: basic + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: basic + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: abcdefg123456 + - name: CRONJOBS + - name: SERVICE_NAME + value: basic + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/basic@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + livenessProbe: + initialDelaySeconds: 60 + tcpSocket: + port: 5672 + timeoutSeconds: 10 + name: basic + ports: + - containerPort: 5672 + name: tcp-5672 + protocol: TCP + - containerPort: 15672 + name: tcp-15672 + protocol: TCP + readinessProbe: + initialDelaySeconds: 1 + tcpSocket: + port: 5672 + timeoutSeconds: 1 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + volumeMounts: + - mountPath: /var/lib/basic + name: basic-data + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production + volumes: + - name: basic-data + persistentVolumeClaim: + claimName: basic-data +status: {} diff --git a/internal/testdata/basic/service-templates/test-basic-persistent-name/pvc-basic-data.yaml b/internal/testdata/basic/service-templates/test-basic-persistent-name/pvc-basic-data.yaml new file mode 100644 index 00000000..d30641a1 --- /dev/null +++ b/internal/testdata/basic/service-templates/test-basic-persistent-name/pvc-basic-data.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + annotations: + k8up.io/backup: "true" + k8up.syn.tools/backup: "true" + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: basic + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: basic + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + name: basic-data +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 5Gi + storageClassName: bulk +status: {} diff --git a/internal/testdata/basic/service-templates/test-basic-persistent-name/service-basic.yaml b/internal/testdata/basic/service-templates/test-basic-persistent-name/service-basic.yaml new file mode 100644 index 00000000..2dba6161 --- /dev/null +++ b/internal/testdata/basic/service-templates/test-basic-persistent-name/service-basic.yaml @@ -0,0 +1,35 @@ +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: basic + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: basic + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + name: basic +spec: + ports: + - name: tcp-5672 + port: 5672 + protocol: TCP + targetPort: tcp-5672 + - name: tcp-15672 + port: 15672 + protocol: TCP + targetPort: tcp-15672 + selector: + app.kubernetes.io/instance: basic + app.kubernetes.io/name: basic-persistent +status: + loadBalancer: {} diff --git a/internal/testdata/basic/service-templates/test-basic-persistent-names/deployment-basic.yaml b/internal/testdata/basic/service-templates/test-basic-persistent-names/deployment-basic.yaml new file mode 100644 index 00000000..23ded318 --- /dev/null +++ b/internal/testdata/basic/service-templates/test-basic-persistent-names/deployment-basic.yaml @@ -0,0 +1,93 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: basic + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: basic + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + name: basic +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: basic + app.kubernetes.io/name: basic-persistent + strategy: {} + template: + metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: basic + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: basic + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: abcdefg123456 + - name: CRONJOBS + - name: SERVICE_NAME + value: basic + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/basic@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + livenessProbe: + initialDelaySeconds: 60 + tcpSocket: + port: 5672 + timeoutSeconds: 10 + name: basic + ports: + - containerPort: 5672 + name: tcp-5672 + protocol: TCP + - containerPort: 15672 + name: tcp-15672 + protocol: TCP + readinessProbe: + initialDelaySeconds: 1 + tcpSocket: + port: 5672 + timeoutSeconds: 1 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + volumeMounts: + - mountPath: /var/lib/basic + name: basic-data + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production + volumes: + - name: basic-data + persistentVolumeClaim: + claimName: basic-data +status: {} diff --git a/internal/testdata/basic/service-templates/test-basic-persistent-names/deployment-basic2.yaml b/internal/testdata/basic/service-templates/test-basic-persistent-names/deployment-basic2.yaml new file mode 100644 index 00000000..2cbc166a --- /dev/null +++ b/internal/testdata/basic/service-templates/test-basic-persistent-names/deployment-basic2.yaml @@ -0,0 +1,93 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: basic2 + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: basic2 + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + name: basic2 +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: basic2 + app.kubernetes.io/name: basic-persistent + strategy: {} + template: + metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: basic2 + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: basic2 + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: abcdefg123456 + - name: CRONJOBS + - name: SERVICE_NAME + value: basic2 + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/basic2@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + livenessProbe: + initialDelaySeconds: 60 + tcpSocket: + port: 5672 + timeoutSeconds: 10 + name: basic + ports: + - containerPort: 5672 + name: tcp-5672 + protocol: TCP + - containerPort: 15672 + name: tcp-15672 + protocol: TCP + readinessProbe: + initialDelaySeconds: 1 + tcpSocket: + port: 5672 + timeoutSeconds: 1 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + volumeMounts: + - mountPath: /var/lib/basic + name: basic-data + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production + volumes: + - name: basic-data + persistentVolumeClaim: + claimName: basic-data +status: {} diff --git a/internal/testdata/basic/service-templates/test-basic-persistent-names/pvc-basic-data.yaml b/internal/testdata/basic/service-templates/test-basic-persistent-names/pvc-basic-data.yaml new file mode 100644 index 00000000..d30641a1 --- /dev/null +++ b/internal/testdata/basic/service-templates/test-basic-persistent-names/pvc-basic-data.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + annotations: + k8up.io/backup: "true" + k8up.syn.tools/backup: "true" + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: basic + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: basic + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + name: basic-data +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 5Gi + storageClassName: bulk +status: {} diff --git a/internal/testdata/basic/service-templates/test-basic-persistent-names/service-basic.yaml b/internal/testdata/basic/service-templates/test-basic-persistent-names/service-basic.yaml new file mode 100644 index 00000000..2dba6161 --- /dev/null +++ b/internal/testdata/basic/service-templates/test-basic-persistent-names/service-basic.yaml @@ -0,0 +1,35 @@ +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: basic + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: basic + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + name: basic +spec: + ports: + - name: tcp-5672 + port: 5672 + protocol: TCP + targetPort: tcp-5672 + - name: tcp-15672 + port: 15672 + protocol: TCP + targetPort: tcp-15672 + selector: + app.kubernetes.io/instance: basic + app.kubernetes.io/name: basic-persistent +status: + loadBalancer: {} diff --git a/internal/testdata/basic/service-templates/test-basic-persistent-names/service-basic2.yaml b/internal/testdata/basic/service-templates/test-basic-persistent-names/service-basic2.yaml new file mode 100644 index 00000000..507d2768 --- /dev/null +++ b/internal/testdata/basic/service-templates/test-basic-persistent-names/service-basic2.yaml @@ -0,0 +1,35 @@ +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: basic2 + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: basic2 + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + name: basic2 +spec: + ports: + - name: tcp-5672 + port: 5672 + protocol: TCP + targetPort: tcp-5672 + - name: tcp-15672 + port: 15672 + protocol: TCP + targetPort: tcp-15672 + selector: + app.kubernetes.io/instance: basic2 + app.kubernetes.io/name: basic-persistent +status: + loadBalancer: {} diff --git a/internal/testdata/complex/docker-compose.persistent-name.yml b/internal/testdata/complex/docker-compose.persistent-name.yml new file mode 100644 index 00000000..142ebbc8 --- /dev/null +++ b/internal/testdata/complex/docker-compose.persistent-name.yml @@ -0,0 +1,265 @@ +x-lagoon-project: + # Lagoon project name (leave `&lagoon-project` when you edit this) + &lagoon-project default + +x-volumes: + &default-volumes + # Define all volumes you would like to have real-time mounted into the docker containers + volumes: + - .:/app:delegated + +x-environment: + &default-environment + LAGOON_PROJECT: *lagoon-project + # Route that should be used locally + # Uncomment if you like to have the system behave like in production + #LAGOON_ENVIRONMENT_TYPE: production + REDIS_PERSIST_URL: 'redis://redis-persist:6379' + REDIS_SESSION_URL: 'redis://redis-session:6379' + REDIS_URL: 'redis://redis:6379' + RABBITMQ_DEFAULT_USER: "default" + RABBITMQ_DEFAULT_PASS: "${RABBITMQ_DEFAULT_PASS:-default}" + MESSENGER_TRANSPORT_DSN: "amqp://${RABBITMQ_DEFAULT_USER}:${RABBITMQ_DEFAULT_PASS}@rabbitmq:5672/" + # Uncomment to enable xdebug and then restart via `docker-compose up -d` + # XDEBUG_ENABLE: "true" + +services: + + cli: # cli container, will be used for executing composer and any local commands (drush, drupal, etc.) + build: + context: . + dockerfile: internal/testdata/complex/docker/cli.dockerfile + args: + - "COMPOSER_AUTH=${COMPOSER_AUTH}" + image: *lagoon-project # this image will be reused as `CLI_IMAGE` in subsequent Docker builds + labels: + # Lagoon Labels + lagoon.type: cli-persistent + lagoon.persistent.name: nginx # mount the persistent storage of nginx into this container + lagoon.persistent: /app/files # location where the persistent storage should be mounted + << : *default-volumes # loads the defined volumes from the top + volumes_from: # mount the ssh-agent from the pygmy or cachalot ssh-agent + - container:amazeeio-ssh-agent + depends_on: + - redis-persist + - mariadb + environment: + << : *default-environment # loads the defined environment variables from the top + + nginx: + build: + context: . + dockerfile: internal/testdata/complex/docker/nginx.dockerfile + args: + CLI_IMAGE: *lagoon-project # Inject the name of the cli image + labels: + lagoon.type: nginx-php-persistent + lagoon.persistent: /app/files # define where the persistent storage should be mounted too + << : *default-volumes # loads the defined volumes from the top + depends_on: + - cli # basically just tells docker-compose to build the cli first + environment: + << : *default-environment # loads the defined environment variables from the top + networks: + - amazeeio-network + - default + + php: + build: + context: . + dockerfile: internal/testdata/complex/docker/php.dockerfile + args: + CLI_IMAGE: *lagoon-project + labels: + lagoon.type: nginx-php-persistent + lagoon.name: nginx # we want this service be part of the nginx pod in Lagoon + lagoon.persistent: /app/files # define where the persistent storage should be mounted too + << : *default-volumes # loads the defined volumes from the top + depends_on: + - cli # basically just tells docker-compose to build the cli first + environment: + << : *default-environment # loads the defined environment variables from the to + + queue-worker-entity-index: + build: + context: . + dockerfile: internal/testdata/complex/docker/generic.dockerfile + args: + CLI_IMAGE: *lagoon-project + labels: + lagoon.type: worker-persistent + lagoon.persistent.name: nginx # mount the persistent storage of nginx into this container + lagoon.persistent: /app/files # location where the persistent storage should be mounted + <<: *default-volumes # loads the defined volumes from the top + depends_on: + - rabbitmq # We kind of do need rabbitmq to run before we start listening + - cli # basically just tells docker-compose to build the cli first + environment: + <<: *default-environment # loads the defined environment variables from the top + + queue-worker-priority-instant: + build: + context: . + dockerfile: internal/testdata/complex/docker/generic.dockerfile + args: + CLI_IMAGE: *lagoon-project + labels: + lagoon.type: worker-persistent + lagoon.persistent.name: nginx # mount the persistent storage of nginx into this container + lagoon.persistent: /app/files # location where the persistent storage should be mounted + <<: *default-volumes # loads the defined volumes from the top + depends_on: + - rabbitmq # We kind of do need rabbitmq to run before we start listening + - cli # basically just tells docker-compose to build the cli first + environment: + <<: *default-environment # loads the defined environment variables from the top + + queue-worker-priority-high: + build: + context: . + dockerfile: internal/testdata/complex/docker/generic.dockerfile + args: + CLI_IMAGE: *lagoon-project + labels: + lagoon.type: worker-persistent + lagoon.persistent.name: nginx # mount the persistent storage of nginx into this container + lagoon.persistent: /app/files # location where the persistent storage should be mounted + <<: *default-volumes # loads the defined volumes from the top + depends_on: + - rabbitmq # We kind of do need rabbitmq to run before we start listening + - cli # basically just tells docker-compose to build the cli first + environment: + <<: *default-environment # loads the defined environment variables from the top + + queue-worker-priority-medium: + build: + context: . + dockerfile: internal/testdata/complex/docker/generic.dockerfile + args: + CLI_IMAGE: *lagoon-project + labels: + lagoon.type: worker-persistent + lagoon.persistent.name: nginx # mount the persistent storage of nginx into this container + lagoon.persistent: /app/files # location where the persistent storage should be mounted + <<: *default-volumes # loads the defined volumes from the top + depends_on: + - rabbitmq # We kind of do need rabbitmq to run before we start listening + - cli # basically just tells docker-compose to build the cli first + environment: + <<: *default-environment # loads the defined environment variables from the top + + queue-worker-priority-low: + build: + context: . + dockerfile: internal/testdata/complex/docker/generic.dockerfile + args: + CLI_IMAGE: *lagoon-project + labels: + lagoon.type: worker-persistent + lagoon.persistent.name: nginx # mount the persistent storage of nginx into this container + lagoon.persistent: /app/files # location where the persistent storage should be mounted + <<: *default-volumes # loads the defined volumes from the top + depends_on: + - rabbitmq # We kind of do need rabbitmq to run before we start listening + - cli # basically just tells docker-compose to build the cli first + environment: + <<: *default-environment # loads the defined environment variables from the top + + mariadb: + image: uselagoon/mariadb-10.5 + labels: + lagoon.type: mariadb + ports: + - "3306" # exposes the port 3306 with a random local port, find it with `docker-compose port mariadb 3306` + environment: + << : *default-environment + + redis: + build: + context: . + dockerfile: internal/testdata/complex/docker/generic.dockerfile + labels: + lagoon.type: redis + environment: + <<: *default-environment + + redis-persist: + build: + context: . + dockerfile: internal/testdata/complex/docker/generic.dockerfile + labels: + lagoon.type: redis-persistent + # Should be at least 3x the size of allocated RAM + # See https://docs.redis.com/latest/rs/installing-upgrading/install/plan-deployment/hardware-requirements/ + lagoon.persistent.size: 15Gi + environment: + <<: *default-environment + + redis-product-info: + build: + context: . + dockerfile: internal/testdata/complex/docker/generic.dockerfile + labels: + lagoon.name: redis-product-info + # This service type is set to redis-persistent for master and production in .lagoon.yml + lagoon.type: none + # Should be at least 3x the size of allocated RAM + # See https://docs.redis.com/latest/rs/installing-upgrading/install/plan-deployment/hardware-requirements/ + lagoon.persistent.size: 4Gi + environment: + <<: *default-environment + + redis-session: + build: + context: . + dockerfile: internal/testdata/complex/docker/generic.dockerfile + labels: + lagoon.name: redis-session + lagoon.type: redis-persistent + # Should be at least 3x the size of allocated RAM + # See https://docs.redis.com/latest/rs/installing-upgrading/install/plan-deployment/hardware-requirements/ + lagoon.persistent.size: 4Gi + environment: + <<: *default-environment + + rabbitmq: + image: uselagoon/rabbitmq + labels: + lagoon.service.port: 5672 + lagoon.service.usecomposeports: true + lagoon.autogeneratedroute: false + lagoon.type: basic-persistent + lagoon.persistent: /var/lib/rabbitmq + lagoon.persistent.name: rabbitmq-data + # Note: 5Gi is the default size for persistent storage + lagoon.persistent.size: 1Gi + environment: + <<: *default-environment + ports: + - '5672' + - '15672:15672' + + gotenberg: + build: + context: . + dockerfile: internal/testdata/complex/docker/generic.dockerfile + labels: + lagoon.type: basic + lagoon.autogeneratedroute: false + ports: + - '3000' + environment: + <<: *default-environment + + opensearch: + image: uselagoon/opensearch-2 + labels: + lagoon.type: opensearch + # Note: 5Gi is the default size for persistent storage + lagoon.persistent.size: 4Gi + environment: + <<: *default-environment + +networks: + amazeeio-network: + external: true \ No newline at end of file diff --git a/internal/testdata/complex/docker/generic.dockerfile b/internal/testdata/complex/docker/generic.dockerfile new file mode 100644 index 00000000..15571fab --- /dev/null +++ b/internal/testdata/complex/docker/generic.dockerfile @@ -0,0 +1 @@ +FROM uselagoon/fake-generic:latest diff --git a/internal/testdata/complex/lagoon.persistent-name.yml b/internal/testdata/complex/lagoon.persistent-name.yml new file mode 100644 index 00000000..411f8414 --- /dev/null +++ b/internal/testdata/complex/lagoon.persistent-name.yml @@ -0,0 +1,7 @@ +docker-compose-yaml: internal/testdata/complex/docker-compose.persistent-name.yml + +environments: + main: + routes: + - node: + - example.com diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-cli.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-cli.yaml new file mode 100644 index 00000000..814b9be2 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-cli.yaml @@ -0,0 +1,97 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: cli + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: cli-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: cli + lagoon.sh/service-type: cli-persistent + lagoon.sh/template: cli-persistent-0.1.0 + name: cli +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: cli + app.kubernetes.io/name: cli-persistent + strategy: {} + template: + metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: cli + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: cli-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: cli + lagoon.sh/service-type: cli-persistent + lagoon.sh/template: cli-persistent-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: "0000000000000000000000000000000000000000" + - name: CRONJOBS + - name: SERVICE_NAME + value: cli + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/cli@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + name: cli + readinessProbe: + exec: + command: + - /bin/sh + - -c + - if [ -x /bin/entrypoint-readiness ]; then /bin/entrypoint-readiness; + fi + failureThreshold: 3 + initialDelaySeconds: 5 + periodSeconds: 2 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + volumeMounts: + - mountPath: /var/run/secrets/lagoon/sshkey/ + name: lagoon-sshkey + readOnly: true + - mountPath: /app/files/php + name: nginx-twig + - mountPath: /app/files + name: nginx + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production + volumes: + - name: lagoon-sshkey + secret: + defaultMode: 420 + secretName: lagoon-sshkey + - emptyDir: {} + name: nginx-twig + - name: nginx + persistentVolumeClaim: + claimName: nginx +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-gotenberg.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-gotenberg.yaml new file mode 100644 index 00000000..1c5d9448 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-gotenberg.yaml @@ -0,0 +1,83 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: gotenberg + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: gotenberg + lagoon.sh/service-type: basic + lagoon.sh/template: basic-0.1.0 + name: gotenberg +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: gotenberg + app.kubernetes.io/name: basic + strategy: {} + template: + metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: gotenberg + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: gotenberg + lagoon.sh/service-type: basic + lagoon.sh/template: basic-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: "0000000000000000000000000000000000000000" + - name: CRONJOBS + - name: SERVICE_NAME + value: gotenberg + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/gotenberg@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + livenessProbe: + initialDelaySeconds: 60 + tcpSocket: + port: 3000 + timeoutSeconds: 10 + name: basic + ports: + - containerPort: 3000 + name: http + protocol: TCP + readinessProbe: + initialDelaySeconds: 1 + tcpSocket: + port: 3000 + timeoutSeconds: 1 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-nginx.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-nginx.yaml new file mode 100644 index 00000000..b3bebcce --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-nginx.yaml @@ -0,0 +1,134 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: nginx + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: nginx-php-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: nginx + lagoon.sh/service-type: nginx-php-persistent + lagoon.sh/template: nginx-php-persistent-0.1.0 + name: nginx +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: nginx + app.kubernetes.io/name: nginx-php-persistent + strategy: {} + template: + metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: nginx + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: nginx-php-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: nginx + lagoon.sh/service-type: nginx-php-persistent + lagoon.sh/template: nginx-php-persistent-0.1.0 + spec: + containers: + - env: + - name: NGINX_FASTCGI_PASS + value: 127.0.0.1 + - name: LAGOON_GIT_SHA + value: "0000000000000000000000000000000000000000" + - name: CRONJOBS + - name: SERVICE_NAME + value: nginx + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/nginx@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + livenessProbe: + failureThreshold: 5 + httpGet: + path: /nginx_status + port: 50000 + initialDelaySeconds: 900 + timeoutSeconds: 3 + name: nginx + ports: + - containerPort: 8080 + name: http + protocol: TCP + readinessProbe: + httpGet: + path: /nginx_status + port: 50000 + initialDelaySeconds: 1 + timeoutSeconds: 3 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + volumeMounts: + - mountPath: /app/files + name: nginx + - env: + - name: NGINX_FASTCGI_PASS + value: 127.0.0.1 + - name: LAGOON_GIT_SHA + value: "0000000000000000000000000000000000000000" + - name: SERVICE_NAME + value: nginx + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/php@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + livenessProbe: + initialDelaySeconds: 60 + periodSeconds: 10 + tcpSocket: + port: 9000 + name: php + ports: + - containerPort: 9000 + name: php + protocol: TCP + readinessProbe: + initialDelaySeconds: 2 + periodSeconds: 10 + tcpSocket: + port: 9000 + resources: + requests: + cpu: 10m + memory: 100Mi + securityContext: {} + volumeMounts: + - mountPath: /app/files + name: nginx + - mountPath: /app/files/php + name: nginx-twig + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production + volumes: + - name: nginx + persistentVolumeClaim: + claimName: nginx + - emptyDir: {} + name: nginx-twig +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-opensearch.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-opensearch.yaml new file mode 100644 index 00000000..a5c9e32e --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-opensearch.yaml @@ -0,0 +1,114 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: opensearch + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: opensearch-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: opensearch + lagoon.sh/service-type: opensearch-persistent + lagoon.sh/template: opensearch-persistent-0.1.0 + name: opensearch +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: opensearch + app.kubernetes.io/name: opensearch-persistent + strategy: + type: Recreate + template: + metadata: + annotations: + k8up.syn.tools/backupcommand: /bin/sh -c "tar -cf - -C /usr/share/opensearch/data + ." + k8up.syn.tools/file-extension: .opensearch.tar + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: opensearch + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: opensearch-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: opensearch + lagoon.sh/service-type: opensearch-persistent + lagoon.sh/template: opensearch-persistent-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: "0000000000000000000000000000000000000000" + - name: CRONJOBS + - name: SERVICE_NAME + value: opensearch + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/opensearch@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + livenessProbe: + httpGet: + path: /_cluster/health?local=true + port: 9200 + initialDelaySeconds: 120 + name: opensearch + ports: + - containerPort: 9200 + name: 9200-tcp + protocol: TCP + readinessProbe: + httpGet: + path: /_cluster/health?local=true + port: 9200 + initialDelaySeconds: 20 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + volumeMounts: + - mountPath: /usr/share/opensearch/data + name: opensearch + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + initContainers: + - command: + - sh + - -c + - |- + set -xe + DESIRED="262144" + CURRENT=$(sysctl -n vm.max_map_count) + if [ "$DESIRED" -gt "$CURRENT" ]; then + sysctl -w vm.max_map_count=$DESIRED + fi + image: library/busybox:latest + imagePullPolicy: IfNotPresent + name: set-max-map-count + resources: {} + securityContext: + privileged: true + runAsUser: 0 + priorityClassName: lagoon-priority-production + securityContext: + fsGroup: 0 + volumes: + - name: opensearch + persistentVolumeClaim: + claimName: opensearch +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-entity-index.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-entity-index.yaml new file mode 100644 index 00000000..6390a099 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-entity-index.yaml @@ -0,0 +1,93 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: queue-worker-entity-index + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: worker-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: queue-worker-entity-index + lagoon.sh/service-type: worker-persistent + lagoon.sh/template: worker-persistent-0.1.0 + name: queue-worker-entity-index +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: queue-worker-entity-index + app.kubernetes.io/name: worker-persistent + strategy: {} + template: + metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: queue-worker-entity-index + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: worker-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: queue-worker-entity-index + lagoon.sh/service-type: worker-persistent + lagoon.sh/template: worker-persistent-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: "0000000000000000000000000000000000000000" + - name: CRONJOBS + - name: SERVICE_NAME + value: queue-worker-entity-index + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/queue-worker-entity-index@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + name: worker + readinessProbe: + exec: + command: + - /bin/sh + - -c + - if [ -x /bin/entrypoint-readiness ]; then /bin/entrypoint-readiness; + fi + failureThreshold: 3 + initialDelaySeconds: 5 + periodSeconds: 2 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + volumeMounts: + - mountPath: /var/run/secrets/lagoon/sshkey/ + name: lagoon-sshkey + readOnly: true + - mountPath: /app/files + name: nginx + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production + volumes: + - name: lagoon-sshkey + secret: + defaultMode: 420 + secretName: lagoon-sshkey + - name: nginx + persistentVolumeClaim: + claimName: nginx +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-priority-high.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-priority-high.yaml new file mode 100644 index 00000000..5d9f03f0 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-priority-high.yaml @@ -0,0 +1,93 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: queue-worker-priority-high + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: worker-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: queue-worker-priority-high + lagoon.sh/service-type: worker-persistent + lagoon.sh/template: worker-persistent-0.1.0 + name: queue-worker-priority-high +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: queue-worker-priority-high + app.kubernetes.io/name: worker-persistent + strategy: {} + template: + metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: queue-worker-priority-high + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: worker-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: queue-worker-priority-high + lagoon.sh/service-type: worker-persistent + lagoon.sh/template: worker-persistent-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: "0000000000000000000000000000000000000000" + - name: CRONJOBS + - name: SERVICE_NAME + value: queue-worker-priority-high + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/queue-worker-priority-high@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + name: worker + readinessProbe: + exec: + command: + - /bin/sh + - -c + - if [ -x /bin/entrypoint-readiness ]; then /bin/entrypoint-readiness; + fi + failureThreshold: 3 + initialDelaySeconds: 5 + periodSeconds: 2 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + volumeMounts: + - mountPath: /var/run/secrets/lagoon/sshkey/ + name: lagoon-sshkey + readOnly: true + - mountPath: /app/files + name: nginx + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production + volumes: + - name: lagoon-sshkey + secret: + defaultMode: 420 + secretName: lagoon-sshkey + - name: nginx + persistentVolumeClaim: + claimName: nginx +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-priority-instant.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-priority-instant.yaml new file mode 100644 index 00000000..9a0b6db2 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-priority-instant.yaml @@ -0,0 +1,93 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: queue-worker-priority-instant + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: worker-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: queue-worker-priority-instant + lagoon.sh/service-type: worker-persistent + lagoon.sh/template: worker-persistent-0.1.0 + name: queue-worker-priority-instant +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: queue-worker-priority-instant + app.kubernetes.io/name: worker-persistent + strategy: {} + template: + metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: queue-worker-priority-instant + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: worker-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: queue-worker-priority-instant + lagoon.sh/service-type: worker-persistent + lagoon.sh/template: worker-persistent-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: "0000000000000000000000000000000000000000" + - name: CRONJOBS + - name: SERVICE_NAME + value: queue-worker-priority-instant + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/queue-worker-priority-instant@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + name: worker + readinessProbe: + exec: + command: + - /bin/sh + - -c + - if [ -x /bin/entrypoint-readiness ]; then /bin/entrypoint-readiness; + fi + failureThreshold: 3 + initialDelaySeconds: 5 + periodSeconds: 2 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + volumeMounts: + - mountPath: /var/run/secrets/lagoon/sshkey/ + name: lagoon-sshkey + readOnly: true + - mountPath: /app/files + name: nginx + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production + volumes: + - name: lagoon-sshkey + secret: + defaultMode: 420 + secretName: lagoon-sshkey + - name: nginx + persistentVolumeClaim: + claimName: nginx +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-priority-low.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-priority-low.yaml new file mode 100644 index 00000000..10feb306 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-priority-low.yaml @@ -0,0 +1,93 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: queue-worker-priority-low + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: worker-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: queue-worker-priority-low + lagoon.sh/service-type: worker-persistent + lagoon.sh/template: worker-persistent-0.1.0 + name: queue-worker-priority-low +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: queue-worker-priority-low + app.kubernetes.io/name: worker-persistent + strategy: {} + template: + metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: queue-worker-priority-low + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: worker-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: queue-worker-priority-low + lagoon.sh/service-type: worker-persistent + lagoon.sh/template: worker-persistent-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: "0000000000000000000000000000000000000000" + - name: CRONJOBS + - name: SERVICE_NAME + value: queue-worker-priority-low + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/queue-worker-priority-low@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + name: worker + readinessProbe: + exec: + command: + - /bin/sh + - -c + - if [ -x /bin/entrypoint-readiness ]; then /bin/entrypoint-readiness; + fi + failureThreshold: 3 + initialDelaySeconds: 5 + periodSeconds: 2 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + volumeMounts: + - mountPath: /var/run/secrets/lagoon/sshkey/ + name: lagoon-sshkey + readOnly: true + - mountPath: /app/files + name: nginx + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production + volumes: + - name: lagoon-sshkey + secret: + defaultMode: 420 + secretName: lagoon-sshkey + - name: nginx + persistentVolumeClaim: + claimName: nginx +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-priority-medium.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-priority-medium.yaml new file mode 100644 index 00000000..f070cd75 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-queue-worker-priority-medium.yaml @@ -0,0 +1,93 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: queue-worker-priority-medium + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: worker-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: queue-worker-priority-medium + lagoon.sh/service-type: worker-persistent + lagoon.sh/template: worker-persistent-0.1.0 + name: queue-worker-priority-medium +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: queue-worker-priority-medium + app.kubernetes.io/name: worker-persistent + strategy: {} + template: + metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: queue-worker-priority-medium + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: worker-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: queue-worker-priority-medium + lagoon.sh/service-type: worker-persistent + lagoon.sh/template: worker-persistent-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: "0000000000000000000000000000000000000000" + - name: CRONJOBS + - name: SERVICE_NAME + value: queue-worker-priority-medium + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/queue-worker-priority-medium@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + name: worker + readinessProbe: + exec: + command: + - /bin/sh + - -c + - if [ -x /bin/entrypoint-readiness ]; then /bin/entrypoint-readiness; + fi + failureThreshold: 3 + initialDelaySeconds: 5 + periodSeconds: 2 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + volumeMounts: + - mountPath: /var/run/secrets/lagoon/sshkey/ + name: lagoon-sshkey + readOnly: true + - mountPath: /app/files + name: nginx + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production + volumes: + - name: lagoon-sshkey + secret: + defaultMode: 420 + secretName: lagoon-sshkey + - name: nginx + persistentVolumeClaim: + claimName: nginx +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-rabbitmq.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-rabbitmq.yaml new file mode 100644 index 00000000..8975f817 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-rabbitmq.yaml @@ -0,0 +1,93 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: rabbitmq + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: rabbitmq + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + name: rabbitmq +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: rabbitmq + app.kubernetes.io/name: basic-persistent + strategy: {} + template: + metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: rabbitmq + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: rabbitmq + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: "0000000000000000000000000000000000000000" + - name: CRONJOBS + - name: SERVICE_NAME + value: rabbitmq + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/rabbitmq@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + livenessProbe: + initialDelaySeconds: 60 + tcpSocket: + port: 5672 + timeoutSeconds: 10 + name: basic + ports: + - containerPort: 5672 + name: tcp-5672 + protocol: TCP + - containerPort: 15672 + name: tcp-15672 + protocol: TCP + readinessProbe: + initialDelaySeconds: 1 + tcpSocket: + port: 5672 + timeoutSeconds: 1 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + volumeMounts: + - mountPath: /var/lib/rabbitmq + name: rabbitmq-data + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production + volumes: + - name: rabbitmq-data + persistentVolumeClaim: + claimName: rabbitmq-data +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-redis-persist.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-redis-persist.yaml new file mode 100644 index 00000000..3cadb864 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-redis-persist.yaml @@ -0,0 +1,94 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: redis-persist + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: redis-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: redis-persist + lagoon.sh/service-type: redis-persistent + lagoon.sh/template: redis-persistent-0.1.0 + name: redis-persist +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: redis-persist + app.kubernetes.io/name: redis-persistent + strategy: + type: Recreate + template: + metadata: + annotations: + k8up.syn.tools/backupcommand: /bin/sh -c "timeout 5400 tar -cf - -C /data + ." + k8up.syn.tools/file-extension: .redis-persist.tar + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: redis-persist + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: redis-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: redis-persist + lagoon.sh/service-type: redis-persistent + lagoon.sh/template: redis-persistent-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: "0000000000000000000000000000000000000000" + - name: CRONJOBS + - name: SERVICE_NAME + value: redis-persist + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/redis-persist@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + livenessProbe: + initialDelaySeconds: 120 + tcpSocket: + port: 6379 + timeoutSeconds: 1 + name: redis + ports: + - containerPort: 6379 + name: 6379-tcp + protocol: TCP + readinessProbe: + initialDelaySeconds: 1 + tcpSocket: + port: 6379 + timeoutSeconds: 1 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + volumeMounts: + - mountPath: /data + name: redis-persist + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production + volumes: + - name: redis-persist + persistentVolumeClaim: + claimName: redis-persist +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-redis-session.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-redis-session.yaml new file mode 100644 index 00000000..4801af1f --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-redis-session.yaml @@ -0,0 +1,94 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: redis-session + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: redis-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: redis-session + lagoon.sh/service-type: redis-persistent + lagoon.sh/template: redis-persistent-0.1.0 + name: redis-session +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: redis-session + app.kubernetes.io/name: redis-persistent + strategy: + type: Recreate + template: + metadata: + annotations: + k8up.syn.tools/backupcommand: /bin/sh -c "timeout 5400 tar -cf - -C /data + ." + k8up.syn.tools/file-extension: .redis-session.tar + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: redis-session + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: redis-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: redis-session + lagoon.sh/service-type: redis-persistent + lagoon.sh/template: redis-persistent-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: "0000000000000000000000000000000000000000" + - name: CRONJOBS + - name: SERVICE_NAME + value: redis-session + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/redis-session@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + livenessProbe: + initialDelaySeconds: 120 + tcpSocket: + port: 6379 + timeoutSeconds: 1 + name: redis + ports: + - containerPort: 6379 + name: 6379-tcp + protocol: TCP + readinessProbe: + initialDelaySeconds: 1 + tcpSocket: + port: 6379 + timeoutSeconds: 1 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + volumeMounts: + - mountPath: /data + name: redis-session + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production + volumes: + - name: redis-session + persistentVolumeClaim: + claimName: redis-session +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-redis.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-redis.yaml new file mode 100644 index 00000000..667e1a96 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/deployment-redis.yaml @@ -0,0 +1,83 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: redis + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: redis + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: redis + lagoon.sh/service-type: redis + lagoon.sh/template: redis-0.1.0 + name: redis +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: redis + app.kubernetes.io/name: redis + strategy: {} + template: + metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/configMapSha: abcdefg1234567890 + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: redis + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: redis + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: redis + lagoon.sh/service-type: redis + lagoon.sh/template: redis-0.1.0 + spec: + containers: + - env: + - name: LAGOON_GIT_SHA + value: "0000000000000000000000000000000000000000" + - name: CRONJOBS + - name: SERVICE_NAME + value: redis + envFrom: + - configMapRef: + name: lagoon-env + image: harbor.example/example-project/main/redis@sha256:b2001babafaa8128fe89aa8fd11832cade59931d14c3de5b3ca32e2a010fbaa8 + imagePullPolicy: Always + livenessProbe: + initialDelaySeconds: 120 + tcpSocket: + port: 6379 + timeoutSeconds: 1 + name: redis + ports: + - containerPort: 6379 + name: 6379-tcp + protocol: TCP + readinessProbe: + initialDelaySeconds: 1 + tcpSocket: + port: 6379 + timeoutSeconds: 1 + resources: + requests: + cpu: 10m + memory: 10Mi + securityContext: {} + enableServiceLinks: false + imagePullSecrets: + - name: lagoon-internal-registry-secret + priorityClassName: lagoon-priority-production +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-nginx.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-nginx.yaml new file mode 100644 index 00000000..c9f25a61 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-nginx.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + annotations: + k8up.io/backup: "true" + k8up.syn.tools/backup: "true" + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: nginx + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: nginx-php-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: nginx + lagoon.sh/service-type: nginx-php-persistent + lagoon.sh/template: nginx-php-persistent-0.1.0 + name: nginx +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 5Gi + storageClassName: bulk +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-opensearch.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-opensearch.yaml new file mode 100644 index 00000000..cd0921f5 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-opensearch.yaml @@ -0,0 +1,29 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + annotations: + k8up.io/backup: "false" + k8up.syn.tools/backup: "false" + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: opensearch + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: opensearch-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: opensearch + lagoon.sh/service-type: opensearch-persistent + lagoon.sh/template: opensearch-persistent-0.1.0 + name: opensearch +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 4Gi +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-rabbitmq-data.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-rabbitmq-data.yaml new file mode 100644 index 00000000..4e9a5299 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-rabbitmq-data.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + annotations: + k8up.io/backup: "true" + k8up.syn.tools/backup: "true" + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: rabbitmq + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: rabbitmq + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + name: rabbitmq-data +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 1Gi + storageClassName: bulk +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-redis-persist.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-redis-persist.yaml new file mode 100644 index 00000000..cdbe5c1a --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-redis-persist.yaml @@ -0,0 +1,29 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + annotations: + k8up.io/backup: "false" + k8up.syn.tools/backup: "false" + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: redis-persist + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: redis-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: redis-persist + lagoon.sh/service-type: redis-persistent + lagoon.sh/template: redis-persistent-0.1.0 + name: redis-persist +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 15Gi +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-redis-session.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-redis-session.yaml new file mode 100644 index 00000000..4a997e36 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/pvc-redis-session.yaml @@ -0,0 +1,29 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + annotations: + k8up.io/backup: "false" + k8up.syn.tools/backup: "false" + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: redis-session + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: redis-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: redis-session + lagoon.sh/service-type: redis-persistent + lagoon.sh/template: redis-persistent-0.1.0 + name: redis-session +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 4Gi +status: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/service-gotenberg.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/service-gotenberg.yaml new file mode 100644 index 00000000..2e6fa1a5 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/service-gotenberg.yaml @@ -0,0 +1,31 @@ +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: gotenberg + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: gotenberg + lagoon.sh/service-type: basic + lagoon.sh/template: basic-0.1.0 + name: gotenberg +spec: + ports: + - name: http + port: 3000 + protocol: TCP + targetPort: http + selector: + app.kubernetes.io/instance: gotenberg + app.kubernetes.io/name: basic +status: + loadBalancer: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/service-nginx.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/service-nginx.yaml new file mode 100644 index 00000000..57cb9386 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/service-nginx.yaml @@ -0,0 +1,31 @@ +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: nginx + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: nginx-php-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: nginx + lagoon.sh/service-type: nginx-php-persistent + lagoon.sh/template: nginx-php-persistent-0.1.0 + name: nginx +spec: + ports: + - name: http + port: 8080 + protocol: TCP + targetPort: http + selector: + app.kubernetes.io/instance: nginx + app.kubernetes.io/name: nginx-php-persistent +status: + loadBalancer: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/service-opensearch.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/service-opensearch.yaml new file mode 100644 index 00000000..de247c4b --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/service-opensearch.yaml @@ -0,0 +1,31 @@ +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: opensearch + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: opensearch-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: opensearch + lagoon.sh/service-type: opensearch-persistent + lagoon.sh/template: opensearch-persistent-0.1.0 + name: opensearch +spec: + ports: + - name: 9200-tcp + port: 9200 + protocol: TCP + targetPort: 9200 + selector: + app.kubernetes.io/instance: opensearch + app.kubernetes.io/name: opensearch-persistent +status: + loadBalancer: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/service-rabbitmq.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/service-rabbitmq.yaml new file mode 100644 index 00000000..414efee9 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/service-rabbitmq.yaml @@ -0,0 +1,35 @@ +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: rabbitmq + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: basic-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: rabbitmq + lagoon.sh/service-type: basic-persistent + lagoon.sh/template: basic-persistent-0.1.0 + name: rabbitmq +spec: + ports: + - name: tcp-5672 + port: 5672 + protocol: TCP + targetPort: tcp-5672 + - name: tcp-15672 + port: 15672 + protocol: TCP + targetPort: tcp-15672 + selector: + app.kubernetes.io/instance: rabbitmq + app.kubernetes.io/name: basic-persistent +status: + loadBalancer: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/service-redis-persist.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/service-redis-persist.yaml new file mode 100644 index 00000000..ed6123d4 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/service-redis-persist.yaml @@ -0,0 +1,31 @@ +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: redis-persist + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: redis-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: redis-persist + lagoon.sh/service-type: redis-persistent + lagoon.sh/template: redis-persistent-0.1.0 + name: redis-persist +spec: + ports: + - name: 6379-tcp + port: 6379 + protocol: TCP + targetPort: 6379 + selector: + app.kubernetes.io/instance: redis-persist + app.kubernetes.io/name: redis-persistent +status: + loadBalancer: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/service-redis-session.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/service-redis-session.yaml new file mode 100644 index 00000000..24ca931e --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/service-redis-session.yaml @@ -0,0 +1,31 @@ +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: redis-session + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: redis-persistent + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: redis-session + lagoon.sh/service-type: redis-persistent + lagoon.sh/template: redis-persistent-0.1.0 + name: redis-session +spec: + ports: + - name: 6379-tcp + port: 6379 + protocol: TCP + targetPort: 6379 + selector: + app.kubernetes.io/instance: redis-session + app.kubernetes.io/name: redis-persistent +status: + loadBalancer: {} diff --git a/internal/testdata/complex/service-templates/test-complex-persistent-names/service-redis.yaml b/internal/testdata/complex/service-templates/test-complex-persistent-names/service-redis.yaml new file mode 100644 index 00000000..e0c26762 --- /dev/null +++ b/internal/testdata/complex/service-templates/test-complex-persistent-names/service-redis.yaml @@ -0,0 +1,31 @@ +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: redis + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: redis + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: redis + lagoon.sh/service-type: redis + lagoon.sh/template: redis-0.1.0 + name: redis +spec: + ports: + - name: 6379-tcp + port: 6379 + protocol: TCP + targetPort: 6379 + selector: + app.kubernetes.io/instance: redis + app.kubernetes.io/name: redis +status: + loadBalancer: {} diff --git a/internal/testdata/node/autogen-templates/ingress-11/node.yaml b/internal/testdata/node/autogen-templates/test-development-service-type-override/node.yaml similarity index 96% rename from internal/testdata/node/autogen-templates/ingress-11/node.yaml rename to internal/testdata/node/autogen-templates/test-development-service-type-override/node.yaml index 2ed1318f..34cf6fe4 100644 --- a/internal/testdata/node/autogen-templates/ingress-11/node.yaml +++ b/internal/testdata/node/autogen-templates/test-development-service-type-override/node.yaml @@ -23,7 +23,7 @@ metadata: lagoon.sh/environmentType: development lagoon.sh/project: example-project lagoon.sh/service: node - lagoon.sh/service-type: node-persistent + lagoon.sh/service-type: basic lagoon.sh/template: autogenerated-ingress-0.1.0 name: node spec: