diff --git a/cmd/identify_dbaas.go b/cmd/identify_dbaas.go new file mode 100644 index 00000000..26009d1c --- /dev/null +++ b/cmd/identify_dbaas.go @@ -0,0 +1,46 @@ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" + generator "github.com/uselagoon/build-deploy-tool/internal/generator" +) + +// this is an intermediate helper command while transitioning from bash to go +// eventually this won't be required +var dbaasIdentify = &cobra.Command{ + Use: "dbaas", + Aliases: []string{"db", "d"}, + Short: "Identify if any dbaas consumers are created", + RunE: func(cmd *cobra.Command, args []string) error { + generator, err := generator.GenerateInput(*rootCmd, false) + if err != nil { + return err + } + dbaasConsumers, err := IdentifyDBaaSConsumers(generator) + if err != nil { + return err + } + for _, dbc := range dbaasConsumers { + fmt.Println(dbc) + } + return nil + }, +} + +func IdentifyDBaaSConsumers(g generator.GeneratorInput) ([]string, error) { + lagoonBuild, err := generator.NewGenerator( + g, + ) + if err != nil { + return nil, err + } + ret := []string{} + for _, svc := range lagoonBuild.BuildValues.Services { + if svc.IsDBaaS { + ret = append(ret, fmt.Sprintf("%s:%s", svc.Name, svc.Type)) + } + } + return ret, nil +} diff --git a/cmd/identify_dbaas_test.go b/cmd/identify_dbaas_test.go new file mode 100644 index 00000000..932d4a77 --- /dev/null +++ b/cmd/identify_dbaas_test.go @@ -0,0 +1,162 @@ +package cmd + +import ( + "os" + "reflect" + "testing" + + "github.com/uselagoon/build-deploy-tool/internal/dbaasclient" + "github.com/uselagoon/build-deploy-tool/internal/helpers" + "github.com/uselagoon/build-deploy-tool/internal/lagoon" + "github.com/uselagoon/build-deploy-tool/internal/testdata" +) + +// these tests uses the same files as the dbaas templates +func TestIdentifyDBaaSConsumers(t *testing.T) { + type args struct { + name string + alertContact string + statusPageID string + projectName string + environmentName string + branch string + prNumber string + prHeadBranch string + prBaseBranch string + environmentType string + buildType string + activeEnvironment string + standbyEnvironment string + cacheNoCache string + serviceID string + secretPrefix string + projectVars string + envVars string + lagoonVersion string + lagoonYAML string + valuesFilePath string + templatePath string + } + tests := []struct { + name string + args testdata.TestData + vars []helpers.EnvironmentVariable + templatePath string + want []string + wantErr bool + }{ + { + name: "test1 - mariadb to mariadb-dbaas only", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/complex/lagoon.yml", + }, true), + templatePath: "testdata/output", + want: []string{ + "mariadb:mariadb-dbaas", + }, + }, + { + name: "test2 - mariadb to mariadb-shared which converts to mariadb-dbaas", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/complex/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + {Name: "LAGOON_SERVICE_TYPES", Value: "mariadb:mariadb-shared", Scope: "build"}, + }, + }, true), + templatePath: "testdata/output", + want: []string{ + "mariadb:mariadb-dbaas", + }, + }, + { + name: "test3 - override provider to non-existent should result in failing dbaas check and a single pod no dbaas found", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/complex/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + {Name: "LAGOON_DBAAS_ENVIRONMENT_TYPES", Value: "mariadb:development2", Scope: "build"}, + }, + }, true), + templatePath: "testdata/output", + want: []string{}, + }, + { + name: "test4 - mariadb-single to mariadb-dbaas (using mariadb-shared to mariadb-dbaas conversion)", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/complex/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + {Name: "LAGOON_SERVICE_TYPES", Value: "mariadb:mariadb-shared", Scope: "build"}, + }, + }, true), + templatePath: "testdata/output", + want: []string{ + "mariadb:mariadb-dbaas", + }, + }, + { + name: "test5 - multiple mariadb", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/complex/lagoon.multidb.yml", + }, true), + templatePath: "testdata/output", + want: []string{ + "mariadb:mariadb-dbaas", + "mariadb2:mariadb-dbaas", + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + savedTemplates := tt.templatePath + generator, err := testdata.SetupEnvironment(*rootCmd, savedTemplates, tt.args) + if err != nil { + t.Errorf("%v", err) + } + for _, envVar := range tt.vars { + err = os.Setenv(envVar.Name, envVar.Value) + if err != nil { + t.Errorf("%v", err) + } + } + + // setup the fake dbaas server + ts := dbaasclient.TestDBaaSHTTPServer() + defer ts.Close() + err = os.Setenv("DBAAS_OPERATOR_HTTP", ts.URL) + if err != nil { + t.Errorf("%v", err) + } + + got, err := IdentifyDBaaSConsumers(generator) + if (err != nil) != tt.wantErr { + t.Errorf("IdentifyDBaaSConsumers() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("IdentifyDBaaSConsumers() = %v, want %v", got, tt.want) + } + t.Cleanup(func() { + helpers.UnsetEnvVars(tt.vars) + }) + }) + } +} diff --git a/cmd/identify_ingress.go b/cmd/identify_ingress.go index a3e93849..e21dc3f0 100644 --- a/cmd/identify_ingress.go +++ b/cmd/identify_ingress.go @@ -120,5 +120,6 @@ func CreatedIngressIdentification(g generator.GeneratorInput) ([]string, []strin func init() { identifyCmd.AddCommand(primaryIngressIdentify) identifyCmd.AddCommand(ingressIdentify) + identifyCmd.AddCommand(dbaasIdentify) identifyCmd.AddCommand(autogenIngressIdentify) } diff --git a/cmd/template_dbaas.go b/cmd/template_dbaas.go index 421f7cae..a63bbbd8 100644 --- a/cmd/template_dbaas.go +++ b/cmd/template_dbaas.go @@ -38,6 +38,9 @@ func DBaaSTemplateGeneration(g generator.GeneratorInput, return fmt.Errorf("couldn't generate template: %v", err) } helpers.WriteTemplateFile(fmt.Sprintf("%s/%s.yaml", savedTemplates, "dbaas"), templateYAML) + if g.Debug { + fmt.Println(fmt.Sprintf("Templating dbaas consumers to %s", fmt.Sprintf("%s/%s.yaml", savedTemplates, "dbaas"))) + } return nil } diff --git a/cmd/template_dbaas_test.go b/cmd/template_dbaas_test.go index bff3765b..6569098f 100644 --- a/cmd/template_dbaas_test.go +++ b/cmd/template_dbaas_test.go @@ -9,6 +9,7 @@ import ( "github.com/uselagoon/build-deploy-tool/internal/dbaasclient" "github.com/uselagoon/build-deploy-tool/internal/helpers" + "github.com/uselagoon/build-deploy-tool/internal/lagoon" "github.com/uselagoon/build-deploy-tool/internal/testdata" ) @@ -32,6 +33,60 @@ func TestDBaaSTemplateGeneration(t *testing.T) { templatePath: "testdata/output", want: "../internal/testdata/complex/dbaas-templates/dbaas-1", }, + { + name: "test2 - mariadb-single to mariadb-dbaas (using mariadb-shared to mariadb-dbaas conversion)", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/complex/lagoon.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + {Name: "LAGOON_SERVICE_TYPES", Value: "mariadb:mariadb-shared", Scope: "build"}, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/complex/dbaas-templates/dbaas-2", + }, + { + name: "test3 - multiple mariadb", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/complex/lagoon.multidb.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/complex/dbaas-templates/dbaas-3", + }, + { + name: "test4 - mongo", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.mongo.yml", + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/dbaas-templates/dbaas-1", + }, + { + name: "test5 - mongo override (the mongo should not generate because it has a mongodb-single override)", + args: testdata.GetSeedData( + testdata.TestData{ + ProjectName: "example-project", + EnvironmentName: "main", + Branch: "main", + LagoonYAML: "../internal/testdata/node/lagoon.mongo.yml", + ProjectVariables: []lagoon.EnvironmentVariable{ + {Name: "LAGOON_SERVICE_TYPES", Value: "mongo:mongodb-single", Scope: "build"}, + }, + }, true), + templatePath: "testdata/output", + want: "../internal/testdata/node/dbaas-templates/dbaas-2", + }, } 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 aa11815b..acdb9580 100644 --- a/internal/generator/buildvalues.go +++ b/internal/generator/buildvalues.go @@ -74,7 +74,6 @@ type ServiceValues struct { AutogeneratedRoutesTLSAcme bool `json:"autogeneratedRoutesTLSAcme"` AutogeneratedRouteDomain string `json:"autogeneratedRouteDomain"` ShortAutogeneratedRouteDomain string `json:"shortAutogeneratedRouteDomain"` - DBaaSEnvironment string `json:"dbaasEnvironment"` NativeCronjobs map[string]CronjobValues `json:"nativeCronjobs"` InPodCronjobs string `json:"inPodCronjobs"` ImageName string `json:"imageName"` @@ -92,6 +91,8 @@ type ServiceValues struct { CronjobTolerations *[]corev1.Toleration `json:"cronjobTolerations"` CronjobAffinity *corev1.Affinity `json:"cronjobAffinity"` DBaasReadReplica bool `json:"dBaasReadReplica"` + DBaaSEnvironment string `json:"dbaasEnvironment"` + IsDBaaS bool `json:"isDBaaS"` BackupsEnabled bool `json:"backupsEnabled"` } diff --git a/internal/generator/services.go b/internal/generator/services.go index acdd84e9..e382d4ac 100644 --- a/internal/generator/services.go +++ b/internal/generator/services.go @@ -17,6 +17,7 @@ var oldServiceMap = map[string]string{ "postgres-shared": "postgres-dbaas", "mongo-shared": "mongodb-dbaas", "python-ckandatapusher": "python", + "mongo": "mongodb", } // these are lagoon types that support autogenerated routes @@ -35,6 +36,16 @@ var supportedAutogeneratedTypes = []string{ "python", } +// these are lagoon types that support autogenerated routes +var supportedDBTypes = []string{ + "mariadb", + "mariadb-dbaas", + "postgres", + "postgres-dbaas", + "mongodb", + "mongodb-dbaas", +} + // these are lagoon types that come with resources requiring backups var typesWithBackups = []string{ "basic-persistent", @@ -57,35 +68,35 @@ var typesWithBackups = []string{ // just some default values for services var defaultServiceValues = map[string]map[string]string{ - "elasticsearch": map[string]string{ + "elasticsearch": { "persistentPath": "/usr/share/elasticsearch/data", "persistentSize": "5Gi", }, - "opensearch": map[string]string{ + "opensearch": { "persistentPath": "/usr/share/opensearch/data", "persistentSize": "5Gi", }, - "mariadb-single": map[string]string{ + "mariadb-single": { "persistentPath": "/var/lib/mysql", "persistentSize": "5Gi", }, - "postgres-single": map[string]string{ + "postgres-single": { "persistentPath": "/var/lib/postgresql/data", "persistentSize": "5Gi", }, - "mongodb-single": map[string]string{ + "mongodb-single": { "persistentPath": "/data/db", "persistentSize": "5Gi", }, - "varnish-persistent": map[string]string{ + "varnish-persistent": { "persistentPath": "/var/cache/varnish", "persistentSize": "5Gi", }, - "rabbitmq": map[string]string{ + "rabbitmq": { "persistentPath": "/var/lib/rabbitmq", "persistentSize": "5Gi", }, - "redis-persistent": map[string]string{ + "redis-persistent": { "persistentPath": "/data", "persistentSize": "5Gi", }, @@ -274,7 +285,10 @@ func composeToServiceValues( // handle dbaas operator checks here dbaasEnvironment := buildValues.EnvironmentType - if lagoonType == "mariadb" || lagoonType == "postgres" || lagoonType == "mongodb" { + svcIsDBaaS := false + if helpers.Contains(supportedDBTypes, lagoonType) { + // strip the dbaas off the supplied type for checking against providers, it gets added again later + lagoonType = strings.Split(lagoonType, "-dbaas")[0] err := buildValues.DBaaSClient.CheckHealth(buildValues.DBaaSOperatorEndpoint) if err != nil { // @TODO eventually this error should be handled and fail a build, with a flag to override https://github.com/uselagoon/build-deploy-tool/issues/56 @@ -321,6 +335,7 @@ func composeToServiceValues( // if the requested dbaas environment exists, then set the type to be the requested type with `-dbaas` if exists { lagoonType = fmt.Sprintf("%s-dbaas", lagoonType) + svcIsDBaaS = true } else { // otherwise fallback to -single (if DBaaSFallbackSingle is enabled, otherwise it will error out prior) lagoonType = fmt.Sprintf("%s-single", lagoonType) @@ -352,6 +367,7 @@ func composeToServiceValues( PersistentVolumePath: servicePersistentPath, PersistentVolumeName: servicePersistentName, PersistentVolumeSize: servicePersistentSize, + IsDBaaS: svcIsDBaaS, BackupsEnabled: backupsEnabled, } // check if the service has a service port override (this only applies to basic(-persistent)) diff --git a/internal/generator/services_test.go b/internal/generator/services_test.go index 61a8f936..40f28f0b 100644 --- a/internal/generator/services_test.go +++ b/internal/generator/services_test.go @@ -350,6 +350,7 @@ func Test_composeToServiceValues(t *testing.T) { AutogeneratedRoutesEnabled: false, AutogeneratedRoutesTLSAcme: false, DBaaSEnvironment: "development", + IsDBaaS: true, BackupsEnabled: true, }, }, @@ -433,6 +434,7 @@ func Test_composeToServiceValues(t *testing.T) { AutogeneratedRoutesEnabled: false, AutogeneratedRoutesTLSAcme: false, DBaaSEnvironment: "development", + IsDBaaS: true, BackupsEnabled: true, }, }, diff --git a/internal/templating/dbaas/template_dbaas_test.go b/internal/templating/dbaas/template_dbaas_test.go index 31774af0..3a696df1 100644 --- a/internal/templating/dbaas/template_dbaas_test.go +++ b/internal/templating/dbaas/template_dbaas_test.go @@ -92,6 +92,30 @@ func TestGenerateDBaaSTemplate(t *testing.T) { }, want: "test-resources/result-postgres-1.yaml", }, + { + name: "test4 - mongo", + args: args{ + lValues: generator.BuildValues{ + Project: "example-project", + Environment: "environment-with-really-really-reall-3fdb", + EnvironmentType: "production", + Namespace: "myexample-project-environment-with-really-really-reall-3fdb", + BuildType: "branch", + LagoonVersion: "v2.x.x", + Kubernetes: "generator.local", + Branch: "environment-with-really-really-reall-3fdb", + Services: []generator.ServiceValues{ + { + Name: "mongo", + OverrideName: "mongo", + Type: "mongodb-dbaas", + DBaaSEnvironment: "development", + }, + }, + }, + }, + want: "test-resources/result-mongodb-2.yaml", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/internal/templating/dbaas/test-resources/result-mongodb-2.yaml b/internal/templating/dbaas/test-resources/result-mongodb-2.yaml new file mode 100644 index 00000000..aec1f51b --- /dev/null +++ b/internal/templating/dbaas/test-resources/result-mongodb-2.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: mongodb.amazee.io/v1 +kind: MongoDBConsumer +metadata: + annotations: + lagoon.sh/branch: environment-with-really-really-reall-3fdb + lagoon.sh/version: v2.x.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: mongo + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: mongodb-dbaas + lagoon.sh/buildType: branch + lagoon.sh/environment: environment-with-really-really-reall-3fdb + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: mongo + lagoon.sh/service-type: mongodb-dbaas + lagoon.sh/template: mongodb-dbaas-0.1.0 + name: mongo +spec: + consumer: + auth: + tls: false + services: {} + environment: development + provider: + auth: + tls: false +status: {} diff --git a/internal/testdata/complex/dbaas-templates/dbaas-2/dbaas.yaml b/internal/testdata/complex/dbaas-templates/dbaas-2/dbaas.yaml new file mode 100644 index 00000000..7c206c80 --- /dev/null +++ b/internal/testdata/complex/dbaas-templates/dbaas-2/dbaas.yaml @@ -0,0 +1,26 @@ +--- +apiVersion: mariadb.amazee.io/v1 +kind: MariaDBConsumer +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: mariadb + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: mariadb-dbaas + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: mariadb + lagoon.sh/service-type: mariadb-dbaas + lagoon.sh/template: mariadb-dbaas-0.1.0 + name: mariadb +spec: + consumer: + services: {} + environment: production + provider: {} +status: {} diff --git a/internal/testdata/complex/dbaas-templates/dbaas-3/dbaas.yaml b/internal/testdata/complex/dbaas-templates/dbaas-3/dbaas.yaml new file mode 100644 index 00000000..b16ae4d4 --- /dev/null +++ b/internal/testdata/complex/dbaas-templates/dbaas-3/dbaas.yaml @@ -0,0 +1,52 @@ +--- +apiVersion: mariadb.amazee.io/v1 +kind: MariaDBConsumer +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: mariadb + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: mariadb-dbaas + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: mariadb + lagoon.sh/service-type: mariadb-dbaas + lagoon.sh/template: mariadb-dbaas-0.1.0 + name: mariadb +spec: + consumer: + services: {} + environment: production + provider: {} +status: {} +--- +apiVersion: mariadb.amazee.io/v1 +kind: MariaDBConsumer +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: mariadb2 + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: mariadb-dbaas + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: mariadb2 + lagoon.sh/service-type: mariadb-dbaas + lagoon.sh/template: mariadb-dbaas-0.1.0 + name: mariadb2 +spec: + consumer: + services: {} + environment: production + provider: {} +status: {} diff --git a/internal/testdata/complex/docker-compose.multi-db.yml b/internal/testdata/complex/docker-compose.multi-db.yml new file mode 100644 index 00000000..afd3fcf6 --- /dev/null +++ b/internal/testdata/complex/docker-compose.multi-db.yml @@ -0,0 +1,132 @@ +version: '2.3' + +x-volumes: + &default-volumes + # Define all volumes you would like to have real-time mounted into the docker containers + volumes: + - .:/app:delegated ### Local overrides to mount host filesystem. Automatically removed in CI and PROD. + - files:/app/web/sites/default/files + +x-environment: + &default-environment + # Route that should be used locally, if you are using pygmy, this route *must* end with .docker.amazee.io + LAGOON_ROUTE: &default-url http://${COMPOSE_PROJECT_NAME:-drupal9-example-advanced}.docker.amazee.io + # Uncomment if you like to have the system behave like in production + #LAGOON_ENVIRONMENT_TYPE: production + # Uncomment to enable xdebug and then restart via `docker-compose up -d` + #XDEBUG_ENABLE: "true" + +x-user: + &default-user + # The default user under which the containers should run. Change this if you are on linux and run with another user than id `1000` + user: '1000' + +volumes: + files: + {} + +services: + + cli: # cli container, will be used for executing composer and any local commands (drush, drupal, etc.) + build: + context: . + dockerfile: lagoon/cli.dockerfile + image: &cli-image ${COMPOSE_PROJECT_NAME:-drupal9-example-advanced}-cli # 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/web/sites/default/files/ # location where the persistent storage should be mounted + lando.type: php-cli-drupal + << : *default-volumes # loads the defined volumes from the top + user: root + volumes_from: ### mount the ssh-agent from the pygmy or cachalot ssh-agent. Automatically removed in CI. + - container:amazeeio-ssh-agent ### Local overrides to mount host SSH keys. Automatically removed in CI. + environment: + << : *default-environment # loads the defined environment variables from the top + + nginx: + build: + context: . + dockerfile: lagoon/nginx.dockerfile + args: + CLI_IMAGE: *cli-image # Inject the name of the cli image + labels: + lagoon.type: nginx-php-persistent + lagoon.persistent: /app/web/sites/default/files/ # define where the persistent storage should be mounted too + lando.type: nginx-drupal + << : *default-volumes # loads the defined volumes from the top + << : *default-user # uses the defined user from 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 + LAGOON_LOCALDEV_URL: *default-url + networks: + - amazeeio-network + - default + + php: + build: + context: . + dockerfile: lagoon/php.dockerfile + args: + CLI_IMAGE: *cli-image + labels: + lagoon.type: nginx-php-persistent + lagoon.name: nginx # we want this service be part of the nginx pod in Lagoon + lagoon.persistent: /app/web/sites/default/files/ # define where the persistent storage should be mounted too + lando.type: php-fpm + << : *default-volumes # loads the defined volumes from the top + << : *default-user # uses the defined user from 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 + + mariadb: + image: uselagoon/mariadb-10.5-drupal:latest + labels: + lagoon.type: mariadb + lando.type: mariadb-drupal + ports: + - "3306" # exposes the port 3306 with a random local port, find it with `docker-compose port mariadb 3306` + << : *default-user # uses the defined user from top + environment: + << : *default-environment + + mariadb2: + image: uselagoon/mariadb-10.5-drupal:latest + labels: + lagoon.type: mariadb + lando.type: mariadb-drupal + ports: + - "3306" # exposes the port 3306 with a random local port, find it with `docker-compose port mariadb 3306` + << : *default-user # uses the defined user from top + environment: + << : *default-environment + + redis: + image: uselagoon/redis-5:latest + labels: + lagoon.type: redis + lando.type: redis + ports: + - "6379" # exposes the port 6379 with a random local port, find it with `docker-compose port redis 6379` + << : *default-user # uses the defined user from top + environment: + << : *default-environment + + solr: + image: uselagoon/solr-7.7-drupal:latest + labels: + lagoon.type: solr + lando.type: solr-drupal + ports: + - "8983" # exposes the port 8983 with a random local port, find it with `docker-compose port solr 8983` + environment: + << : *default-environment + +networks: + amazeeio-network: + external: true \ No newline at end of file diff --git a/internal/testdata/complex/lagoon.multidb.yml b/internal/testdata/complex/lagoon.multidb.yml new file mode 100644 index 00000000..0bbc4ee3 --- /dev/null +++ b/internal/testdata/complex/lagoon.multidb.yml @@ -0,0 +1,10 @@ +docker-compose-yaml: ../internal/testdata/complex/docker-compose.multi-db.yml + +environment_variables: + git_sha: "true" + +environments: + main: + routes: + - node: + - example.com diff --git a/internal/testdata/node/dbaas-templates/dbaas-1/dbaas.yaml b/internal/testdata/node/dbaas-templates/dbaas-1/dbaas.yaml new file mode 100644 index 00000000..8835d7dd --- /dev/null +++ b/internal/testdata/node/dbaas-templates/dbaas-1/dbaas.yaml @@ -0,0 +1,90 @@ +--- +apiVersion: mongodb.amazee.io/v1 +kind: MongoDBConsumer +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: mongo + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: mongodb-dbaas + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: mongo + lagoon.sh/service-type: mongodb-dbaas + lagoon.sh/template: mongodb-dbaas-0.1.0 + name: mongo +spec: + consumer: + auth: + tls: false + services: {} + environment: production + provider: + auth: + tls: false +status: {} +--- +apiVersion: mongodb.amazee.io/v1 +kind: MongoDBConsumer +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: mongo2 + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: mongodb-dbaas + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: mongo2 + lagoon.sh/service-type: mongodb-dbaas + lagoon.sh/template: mongodb-dbaas-0.1.0 + name: mongo2 +spec: + consumer: + auth: + tls: false + services: {} + environment: production + provider: + auth: + tls: false +status: {} +--- +apiVersion: mongodb.amazee.io/v1 +kind: MongoDBConsumer +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: mongo3 + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: mongodb-dbaas + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: mongo3 + lagoon.sh/service-type: mongodb-dbaas + lagoon.sh/template: mongodb-dbaas-0.1.0 + name: mongo3 +spec: + consumer: + auth: + tls: false + services: {} + environment: production + provider: + auth: + tls: false +status: {} diff --git a/internal/testdata/node/dbaas-templates/dbaas-2/dbaas.yaml b/internal/testdata/node/dbaas-templates/dbaas-2/dbaas.yaml new file mode 100644 index 00000000..c42f53ca --- /dev/null +++ b/internal/testdata/node/dbaas-templates/dbaas-2/dbaas.yaml @@ -0,0 +1,60 @@ +--- +apiVersion: mongodb.amazee.io/v1 +kind: MongoDBConsumer +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: mongo2 + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: mongodb-dbaas + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: mongo2 + lagoon.sh/service-type: mongodb-dbaas + lagoon.sh/template: mongodb-dbaas-0.1.0 + name: mongo2 +spec: + consumer: + auth: + tls: false + services: {} + environment: production + provider: + auth: + tls: false +status: {} +--- +apiVersion: mongodb.amazee.io/v1 +kind: MongoDBConsumer +metadata: + annotations: + lagoon.sh/branch: main + lagoon.sh/version: v2.7.x + creationTimestamp: null + labels: + app.kubernetes.io/instance: mongo3 + app.kubernetes.io/managed-by: build-deploy-tool + app.kubernetes.io/name: mongodb-dbaas + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: example-project + lagoon.sh/service: mongo3 + lagoon.sh/service-type: mongodb-dbaas + lagoon.sh/template: mongodb-dbaas-0.1.0 + name: mongo3 +spec: + consumer: + auth: + tls: false + services: {} + environment: production + provider: + auth: + tls: false +status: {} diff --git a/internal/testdata/node/docker-compose.mongo.yml b/internal/testdata/node/docker-compose.mongo.yml new file mode 100644 index 00000000..0a4cf494 --- /dev/null +++ b/internal/testdata/node/docker-compose.mongo.yml @@ -0,0 +1,55 @@ +version: '2' +services: + node: + networks: + - amazeeio-network + - default + build: + context: . + dockerfile: node.dockerfile + labels: + lagoon.type: node + volumes: + - .:/app:delegated + environment: + - LAGOON_LOCALDEV_HTTP_PORT=3000 + - LAGOON_ROUTE=http://node.docker.amazee.io + + mongo: + image: fake/mongo:latest + labels: + lagoon.type: mongo + ports: + - "27100" # exposes the port 9200 with a random local port, find it with `docker-compose port opensearch 9200` + volumes: + - data:/mongo/data + + mongo2: + image: fake/mongo:latest + labels: + lagoon.type: mongodb + ports: + - "27100" # exposes the port 9200 with a random local port, find it with `docker-compose port opensearch 9200` + volumes: + - data2:/mongo/data + + mongo3: + image: fake/mongo:latest + labels: + lagoon.type: mongo-shared + ports: + - "27100" # exposes the port 9200 with a random local port, find it with `docker-compose port opensearch 9200` + volumes: + - data3:/mongo/data + +networks: + amazeeio-network: + external: true + +volumes: + data: + {} + data2: + {} + data3: + {} \ No newline at end of file diff --git a/internal/testdata/node/lagoon.mongo.yml b/internal/testdata/node/lagoon.mongo.yml new file mode 100644 index 00000000..c33fd315 --- /dev/null +++ b/internal/testdata/node/lagoon.mongo.yml @@ -0,0 +1,70 @@ +docker-compose-yaml: ../internal/testdata/node/docker-compose.mongo.yml + + +environment_variables: + git_sha: "true" + +environments: + main: + routes: + - node: + - example.com + + autogendisabled: + autogenerateRoutes: false + routes: + - node: + - example.com + + tworoutes: + routes: + - node: + - example.com + - www.example.com + + branch/routes: + routes: + - node: + - customdomain-will-be-main-domain.com + - customdomain-will-be-not-be-main-domain.com + + ingressclass: + routes: + - node: + - example.com: + ingressClass: "custom-ingress" + hsts: + routes: + - node: + - example.com: + hstsEnabled: true + hstsMaxAge: 10000 + + hsts2: + routes: + - node: + - example.com: + hstsEnabled: true + hstsMaxAge: 10000 + hstsIncludeSubdomains: true + hstsPreload: true + + pr-4841: + routes: + - nginx: + - performance.example.com + + alternativename: + routes: + - node: + - example.com: + alternativenames: + - www.example.com + - en.example.com + + wildcard: + routes: + - node: + - example.com: + tls-acme: false + wildcard: true \ No newline at end of file diff --git a/legacy/build-deploy-docker-compose.sh b/legacy/build-deploy-docker-compose.sh index 8ba74be5..692adb0c 100755 --- a/legacy/build-deploy-docker-compose.sh +++ b/legacy/build-deploy-docker-compose.sh @@ -335,15 +335,11 @@ DEPLOY_TYPE=$(cat .lagoon.yml | shyaml get-value environments.${BRANCH//./\\.}.d # Load all Services that are defined COMPOSE_SERVICES=($(cat $DOCKER_COMPOSE_YAML | shyaml keys services)) -# Default shared mariadb service broker -MARIADB_SHARED_DEFAULT_CLASS="lagoon-dbaas-mariadb-apb" -MONGODB_SHARED_DEFAULT_CLASS="lagoon-maas-mongodb-apb" # Figure out which services should we handle SERVICE_TYPES=() IMAGES=() NATIVE_CRONJOB_CLEANUP_ARRAY=() -DBAAS=() declare -A MAP_DEPLOYMENT_SERVICETYPE_TO_IMAGENAME declare -A MAP_SERVICE_TYPE_TO_COMPOSE_SERVICE declare -A MAP_SERVICE_NAME_TO_IMAGENAME @@ -421,51 +417,6 @@ do done fi - # functions used to check dbaas providers - #### - function checkDBaaSHealth() { - response_code=$(curl --write-out "%{http_code}\n" --silent --output /dev/null "${DBAAS_OPERATOR_HTTP}/healthz") - if [ "$response_code" == "200" ]; then - return 0 - else - return 1 - fi - } - - function checkDBaaSProvider() { - response_json=$(curl --silent "${DBAAS_OPERATOR_HTTP}/$1/$2") - response_found=$(echo ${response_json} | jq -r '.result.found') - response_error=$(echo ${response_json} | jq -r '.error') - if [ "${response_error}" == "null" ]; then - return 0 - else - echo $response_error 1>&2 - return 1 - fi - } - - function getDBaaSEnvironment() { - dbaas_environment=$(cat $DOCKER_COMPOSE_YAML | shyaml get-value services.$COMPOSE_SERVICE.labels.lagoon\\.$1\\.environment "${ENVIRONMENT_TYPE}") - # Allow the dbaas shared servicebroker plan to be overriden by environment in .lagoon.yml - environment_dbaas_override=$(cat .lagoon.yml | shyaml get-value environments.${BRANCH//./\\.}.overrides.$SERVICE_NAME.$1\\.environment false) - if [ ! $environment_dbaas_override == "false" ]; then - dbaas_environment=$environment_dbaas_override - fi - # If we have a dbaas environment type override in the api, consume it here - if [ ! -z "$LAGOON_DBAAS_ENVIRONMENT_TYPES" ]; then - IFS=',' read -ra LAGOON_DBAAS_ENVIRONMENT_TYPES_SPLIT <<< "$LAGOON_DBAAS_ENVIRONMENT_TYPES" - for LAGOON_DBAAS_ENVIRONMENT_TYPE in "${LAGOON_DBAAS_ENVIRONMENT_TYPES_SPLIT[@]}" - do - IFS=':' read -ra LAGOON_DBAAS_ENVIRONMENT_TYPE_SPLIT <<< "$LAGOON_DBAAS_ENVIRONMENT_TYPE" - if [ "${LAGOON_DBAAS_ENVIRONMENT_TYPE_SPLIT[0]}" == "$SERVICE_NAME" ]; then - dbaas_environment=${LAGOON_DBAAS_ENVIRONMENT_TYPE_SPLIT[1]} - fi - done - fi - echo $dbaas_environment - } - #### - # Previous versions of Lagoon used "python-ckandatapusher", this should be mapped to "python" if [[ "$SERVICE_TYPE" == "python-ckandatapusher" ]]; then SERVICE_TYPE="python" @@ -479,119 +430,6 @@ do fi fi - # "mariadb" is a meta service, which allows lagoon to decide itself which of the services to use: - # - mariadb-single (a single mariadb pod) - # - mariadb-dbaas (use the dbaas shared operator) - if [ "$SERVICE_TYPE" == "mariadb" ]; then - # if there is already a service existing with the service_name we assume that for this project there has been a - # mariadb-single deployed (probably from the past where there was no mariadb-shared yet, or mariadb-dbaas) and use that one - if kubectl -n ${NAMESPACE} get service "$SERVICE_NAME" &> /dev/null; then - SERVICE_TYPE="mariadb-single" - elif checkDBaaSHealth; then - # check if the dbaas operator responds to a health check - # if it does, then check if the dbaas operator has a provider matching the provider type that is expected - if checkDBaaSProvider mariadb $(getDBaaSEnvironment mariadb-dbaas); then - SERVICE_TYPE="mariadb-dbaas" - else - SERVICE_TYPE="mariadb-single" - fi - elif [[ "${CAPABILITIES[@]}" =~ "mariadb.amazee.io/v1/MariaDBConsumer" ]] && ! checkDBaaSHealth ; then - # check if this cluster supports the default one, if not we assume that this cluster is not capable of shared mariadbs and we use a mariadb-single - # real basic check to see if the mariadbconsumer exists as a kind - SERVICE_TYPE="mariadb-dbaas" - else - SERVICE_TYPE="mariadb-single" - fi - - fi - - # Previous versions of Lagoon supported "mariadb-shared", this has been superseeded by "mariadb-dbaas" - if [[ "$SERVICE_TYPE" == "mariadb-shared" ]]; then - SERVICE_TYPE="mariadb-dbaas" - fi - - if [[ "$SERVICE_TYPE" == "mariadb-dbaas" ]]; then - # Default plan is the enviroment type - DBAAS_ENVIRONMENT=$(getDBaaSEnvironment mariadb-dbaas) - - MAP_SERVICE_NAME_TO_DBAAS_ENVIRONMENT["${SERVICE_NAME}"]="${DBAAS_ENVIRONMENT}" - fi - - # "postgres" is a meta service, which allows lagoon to decide itself which of the services to use: - # - postgres-single (a single postgres pod) - # - postgres-dbaas (use the dbaas shared operator) - if [ "$SERVICE_TYPE" == "postgres" ]; then - # if there is already a service existing with the service_name we assume that for this project there has been a - # postgres-single deployed (probably from the past where there was no postgres-shared yet, or postgres-dbaas) and use that one - if kubectl -n ${NAMESPACE} get service "$SERVICE_NAME" &> /dev/null; then - SERVICE_TYPE="postgres-single" - elif checkDBaaSHealth; then - # check if the dbaas operator responds to a health check - # if it does, then check if the dbaas operator has a provider matching the provider type that is expected - if checkDBaaSProvider postgres $(getDBaaSEnvironment postgres-dbaas); then - SERVICE_TYPE="postgres-dbaas" - else - SERVICE_TYPE="postgres-single" - fi - # heck if this cluster supports the default one, if not we assume that this cluster is not capable of shared PostgreSQL and we use a postgres-single - # real basic check to see if the postgreSQLConsumer exists as a kind - elif [[ "${CAPABILITIES[@]}" =~ "postgres.amazee.io/v1/PostgreSQLConsumer" ]] && ! checkDBaaSHealth; then - SERVICE_TYPE="postgres-dbaas" - else - SERVICE_TYPE="postgres-single" - fi - - fi - - # Previous versions of Lagoon supported "postgres-shared", this has been superseeded by "postgres-dbaas" - if [[ "$SERVICE_TYPE" == "postgres-shared" ]]; then - SERVICE_TYPE="postgres-dbaas" - fi - - if [[ "$SERVICE_TYPE" == "postgres-dbaas" ]]; then - # Default plan is the enviroment type - DBAAS_ENVIRONMENT=$(getDBaaSEnvironment postgres-dbaas) - - MAP_SERVICE_NAME_TO_DBAAS_ENVIRONMENT["${SERVICE_NAME}"]="${DBAAS_ENVIRONMENT}" - fi - - # "mongo" is a meta service, which allows lagoon to decide itself which of the services to use: - # - mongodb-single (a single mongodb pod) - # - mongodb-dbaas (use the dbaas shared operator) - if [ "$SERVICE_TYPE" == "mongo" ]; then - # if there is already a service existing with the service_name we assume that for this project there has been a - # mongodb-single deployed (probably from the past where there was no mongodb-shared yet, or mongodb-dbaas) and use that one - if kubectl -n ${NAMESPACE} get service "$SERVICE_NAME" &> /dev/null; then - SERVICE_TYPE="mongodb-single" - elif checkDBaaSHealth; then - # check if the dbaas operator responds to a health check - # if it does, then check if the dbaas operator has a provider matching the provider type that is expected - if checkDBaaSProvider mongodb $(getDBaaSEnvironment mongodb-dbaas); then - SERVICE_TYPE="mongodb-dbaas" - else - SERVICE_TYPE="mongodb-single" - fi - # heck if this cluster supports the default one, if not we assume that this cluster is not capable of shared MongoDB and we use a mongodb-single - # real basic check to see if the MongoDBConsumer exists as a kind - elif [[ "${CAPABILITIES[@]}" =~ "mongodb.amazee.io/v1/MongoDBConsumer" ]] && ! checkDBaaSHealth; then - SERVICE_TYPE="mongodb-dbaas" - else - SERVICE_TYPE="mongodb-single" - fi - - fi - - # Previous versions of Lagoon supported "mongo-shared", this has been superseeded by "mongodb-dbaas" - if [[ "$SERVICE_TYPE" == "mongo-shared" ]]; then - SERVICE_TYPE="mongodb-dbaas" - fi - - if [[ "$SERVICE_TYPE" == "mongodb-dbaas" ]]; then - DBAAS_ENVIRONMENT=$(getDBaaSEnvironment mongodb-dbaas) - - MAP_SERVICE_NAME_TO_DBAAS_ENVIRONMENT["${SERVICE_NAME}"]="${DBAAS_ENVIRONMENT}" - fi - if [ "$SERVICE_TYPE" == "none" ]; then continue fi @@ -1145,6 +983,7 @@ if [ ! -z "$LAGOON_ENVIRONMENT_VARIABLES" ]; then fi fi +# generate the autogenerated ingress if [ ! "$AUTOGEN_ROUTES_DISABLED" == true ]; then build-deploy-tool template autogenerated-ingress else @@ -1206,20 +1045,11 @@ do cat /kubectl-build-deploy/values.yaml helm template ${SERVICE_NAME} /kubectl-build-deploy/helmcharts/${SERVICE_TYPE} -s $HELM_SERVICE_TEMPLATE -f /kubectl-build-deploy/values.yaml "${SERVICE_OVERRIDES[@]}" "${HELM_ARGUMENTS[@]}" > $YAML_FOLDER/service-${SERVICE_NAME}.yaml fi - - HELM_DBAAS_TEMPLATE="templates/dbaas.yaml" - if [ -f /kubectl-build-deploy/helmcharts/${SERVICE_TYPE}/$HELM_DBAAS_TEMPLATE ]; then - # Load the requested class and plan for this service - DBAAS_ENVIRONMENT="${MAP_SERVICE_NAME_TO_DBAAS_ENVIRONMENT["${SERVICE_NAME}"]}" - yq3 write -i -- /kubectl-build-deploy/${SERVICE_NAME}-values.yaml 'environment' $DBAAS_ENVIRONMENT - if [ ! -z "$IMAGECACHE_REGISTRY" ]; then - yq3 write -i -- /kubectl-build-deploy/${SERVICE_NAME}-values.yaml 'imageCache' $IMAGECACHE_REGISTRY - fi - helm template ${SERVICE_NAME} /kubectl-build-deploy/helmcharts/${SERVICE_TYPE} -s $HELM_DBAAS_TEMPLATE -f /kubectl-build-deploy/values.yaml -f /kubectl-build-deploy/${SERVICE_NAME}-values.yaml "${HELM_ARGUMENTS[@]}" > $YAML_FOLDER/service-${SERVICE_NAME}.yaml - DBAAS+=("${SERVICE_NAME}:${SERVICE_TYPE}") - fi done +# generate the dbaas templates if any +build-deploy-tool template dbaas + set +x currentStepEnd="$(date +"%Y-%m-%d %H:%M:%S")" patchBuildStep "${buildStartTime}" "${previousStepEnd}" "${currentStepEnd}" "${NAMESPACE}" "serviceConfiguration2Complete" "Service Configuration Phase 2" "false" @@ -1465,13 +1295,16 @@ if [ "$BUILD_TYPE" == "pullrequest" ]; then -p "{\"data\":{\"LAGOON_PR_HEAD_BRANCH\":\"${PR_HEAD_BRANCH}\", \"LAGOON_PR_BASE_BRANCH\":\"${PR_BASE_BRANCH}\", \"LAGOON_PR_TITLE\":$(echo $PR_TITLE | jq -R)}}" fi -# loop through created DBAAS +# loop through created DBAAS templates +DBAAS=($(build-deploy-tool identify dbaas)) for DBAAS_ENTRY in "${DBAAS[@]}" do IFS=':' read -ra DBAAS_ENTRY_SPLIT <<< "$DBAAS_ENTRY" SERVICE_NAME=${DBAAS_ENTRY_SPLIT[0]} SERVICE_TYPE=${DBAAS_ENTRY_SPLIT[1]} + # remove the image from images to pull + unset IMAGES_PULL[$SERVICE_NAME] SERVICE_NAME_UPPERCASE=$(echo "$SERVICE_NAME" | tr '[:lower:]' '[:upper:]' | tr '-' '_') @@ -1870,6 +1703,17 @@ do SERVICE_ROLLOUT_TYPE=$ENVIRONMENT_SERVICE_ROLLOUT_TYPE fi + # check if this service is a dbaas service and transform the service_type accordingly + for DBAAS_ENTRY in "${DBAAS[@]}" + do + IFS=':' read -ra DBAAS_ENTRY_SPLIT <<< "$DBAAS_ENTRY" + DB_SERVICE_NAME=${DBAAS_ENTRY_SPLIT[0]} + DB_SERVICE_TYPE=${DBAAS_ENTRY_SPLIT[1]} + if [ $SERVICE_NAME == $DB_SERVICE_NAME ]; then + SERVICE_TYPE=$DB_SERVICE_TYPE + fi + done + if [ $SERVICE_TYPE == "mariadb-dbaas" ]; then echo "nothing to monitor for $SERVICE_TYPE" diff --git a/legacy/helmcharts/mariadb-dbaas/.helmignore b/legacy/helmcharts/mariadb-dbaas/.helmignore deleted file mode 100644 index 50af0317..00000000 --- a/legacy/helmcharts/mariadb-dbaas/.helmignore +++ /dev/null @@ -1,22 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/legacy/helmcharts/mariadb-dbaas/Chart.yaml b/legacy/helmcharts/mariadb-dbaas/Chart.yaml deleted file mode 100644 index 15abe278..00000000 --- a/legacy/helmcharts/mariadb-dbaas/Chart.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: v2 -name: mariadb-dbaas -description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -version: 0.1.0 \ No newline at end of file diff --git a/legacy/helmcharts/mariadb-dbaas/templates/_helpers.tpl b/legacy/helmcharts/mariadb-dbaas/templates/_helpers.tpl deleted file mode 100644 index 650bcc44..00000000 --- a/legacy/helmcharts/mariadb-dbaas/templates/_helpers.tpl +++ /dev/null @@ -1,79 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "mariadb-dbaas.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -*/}} -{{- define "mariadb-dbaas.fullname" -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "mariadb-dbaas.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create full hostname for autogenerated hosts -*/}} -{{- define "mariadb-dbaas.autogeneratedHost" -}} -{{- printf "%s.%s" .Release.Name .Values.routesAutogenerateSuffix | trimSuffix "-" -}} -{{- end -}} - -{{- define "mariadb-dbaas.fullnameUppercase" -}} -{{ include "mariadb-dbaas.fullname" . | upper | replace "-" "_" }} -{{- end -}} - -{{/* -Common labels -*/}} -{{- define "mariadb-dbaas.labels" -}} -helm.sh/chart: {{ include "mariadb-dbaas.chart" . }} -{{ include "mariadb-dbaas.selectorLabels" . }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{ include "mariadb-dbaas.lagoonLabels" . }} - -{{- end -}} - -{{/* -Selector labels -*/}} -{{- define "mariadb-dbaas.selectorLabels" -}} -app.kubernetes.io/name: {{ include "mariadb-dbaas.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end -}} - -{{/* -Lagoon Labels -*/}} -{{- define "mariadb-dbaas.lagoonLabels" -}} -lagoon.sh/service: {{ .Release.Name }} -lagoon.sh/service-type: {{ .Chart.Name }} -lagoon.sh/project: {{ .Values.project }} -lagoon.sh/environment: {{ .Values.environment }} -lagoon.sh/environmentType: {{ .Values.environmentType }} -lagoon.sh/buildType: {{ .Values.buildType }} -{{- end -}} - -{{/* -Annotations -*/}} -{{- define "mariadb-dbaas.annotations" -}} -lagoon.sh/version: {{ .Values.lagoonVersion | quote }} -{{- if .Values.branch }} -lagoon.sh/branch: {{ .Values.branch | quote }} -{{- end }} -{{- if .Values.prNumber }} -lagoon.sh/prNumber: {{ .Values.prNumber | quote }} -lagoon.sh/prHeadBranch: {{ .Values.prHeadBranch | quote }} -lagoon.sh/prBaseBranch: {{ .Values.prBaseBranch | quote }} -{{- end }} -{{- end -}} diff --git a/legacy/helmcharts/mariadb-dbaas/templates/dbaas.yaml b/legacy/helmcharts/mariadb-dbaas/templates/dbaas.yaml deleted file mode 100644 index b751cfe7..00000000 --- a/legacy/helmcharts/mariadb-dbaas/templates/dbaas.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: mariadb.amazee.io/v1 -kind: MariaDBConsumer -metadata: - name: {{ include "mariadb-dbaas.fullname" . }} - labels: - {{- include "mariadb-dbaas.labels" . | nindent 4 }} - annotations: - {{- include "mariadb-dbaas.annotations" . | nindent 4 }} - -spec: - environment: {{ .Values.environment}} diff --git a/legacy/helmcharts/mariadb-dbaas/values.yaml b/legacy/helmcharts/mariadb-dbaas/values.yaml deleted file mode 100644 index 38f8de1b..00000000 --- a/legacy/helmcharts/mariadb-dbaas/values.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# Default values for nginx. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -environment: "" - -readReplicaHosts: "" - -imageCache: "" diff --git a/legacy/helmcharts/mongodb-dbaas/.helmignore b/legacy/helmcharts/mongodb-dbaas/.helmignore deleted file mode 100644 index 50af0317..00000000 --- a/legacy/helmcharts/mongodb-dbaas/.helmignore +++ /dev/null @@ -1,22 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/legacy/helmcharts/mongodb-dbaas/Chart.yaml b/legacy/helmcharts/mongodb-dbaas/Chart.yaml deleted file mode 100644 index a9c381b6..00000000 --- a/legacy/helmcharts/mongodb-dbaas/Chart.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: v2 -name: mongodb-dbaas -description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -version: 0.1.0 \ No newline at end of file diff --git a/legacy/helmcharts/mongodb-dbaas/templates/_helpers.tpl b/legacy/helmcharts/mongodb-dbaas/templates/_helpers.tpl deleted file mode 100644 index a8487815..00000000 --- a/legacy/helmcharts/mongodb-dbaas/templates/_helpers.tpl +++ /dev/null @@ -1,79 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "mongodb-dbaas.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -*/}} -{{- define "mongodb-dbaas.fullname" -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "mongodb-dbaas.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create full hostname for autogenerated hosts -*/}} -{{- define "mongodb-dbaas.autogeneratedHost" -}} -{{- printf "%s.%s" .Release.Name .Values.routesAutogenerateSuffix | trimSuffix "-" -}} -{{- end -}} - -{{- define "mongodb-dbaas.fullnameUppercase" -}} -{{ include "mongodb-dbaas.fullname" . | upper | replace "-" "_" }} -{{- end -}} - -{{/* -Common labels -*/}} -{{- define "mongodb-dbaas.labels" -}} -helm.sh/chart: {{ include "mongodb-dbaas.chart" . }} -{{ include "mongodb-dbaas.selectorLabels" . }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{ include "mongodb-dbaas.lagoonLabels" . }} - -{{- end -}} - -{{/* -Selector labels -*/}} -{{- define "mongodb-dbaas.selectorLabels" -}} -app.kubernetes.io/name: {{ include "mongodb-dbaas.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end -}} - -{{/* -Lagoon Labels -*/}} -{{- define "mongodb-dbaas.lagoonLabels" -}} -lagoon.sh/service: {{ .Release.Name }} -lagoon.sh/service-type: {{ .Chart.Name }} -lagoon.sh/project: {{ .Values.project }} -lagoon.sh/environment: {{ .Values.environment }} -lagoon.sh/environmentType: {{ .Values.environmentType }} -lagoon.sh/buildType: {{ .Values.buildType }} -{{- end -}} - -{{/* -Annotations -*/}} -{{- define "mongodb-dbaas.annotations" -}} -lagoon.sh/version: {{ .Values.lagoonVersion | quote }} -{{- if .Values.branch }} -lagoon.sh/branch: {{ .Values.branch | quote }} -{{- end }} -{{- if .Values.prNumber }} -lagoon.sh/prNumber: {{ .Values.prNumber | quote }} -lagoon.sh/prHeadBranch: {{ .Values.prHeadBranch | quote }} -lagoon.sh/prBaseBranch: {{ .Values.prBaseBranch | quote }} -{{- end }} -{{- end -}} diff --git a/legacy/helmcharts/mongodb-dbaas/templates/dbaas.yaml b/legacy/helmcharts/mongodb-dbaas/templates/dbaas.yaml deleted file mode 100644 index 84a1b3e4..00000000 --- a/legacy/helmcharts/mongodb-dbaas/templates/dbaas.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: mongodb.amazee.io/v1 -kind: MongoDBConsumer -metadata: - name: {{ include "mongodb-dbaas.fullname" . }} - labels: - {{- include "mongodb-dbaas.labels" . | nindent 4 }} - annotations: - {{- include "mongodb-dbaas.annotations" . | nindent 4 }} - -spec: - environment: {{ .Values.environment}} diff --git a/legacy/helmcharts/mongodb-dbaas/values.yaml b/legacy/helmcharts/mongodb-dbaas/values.yaml deleted file mode 100644 index 495f8cc0..00000000 --- a/legacy/helmcharts/mongodb-dbaas/values.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# Default values for nginx. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -environment: "" - -imageCache: "" diff --git a/legacy/helmcharts/postgres-dbaas/.helmignore b/legacy/helmcharts/postgres-dbaas/.helmignore deleted file mode 100644 index 50af0317..00000000 --- a/legacy/helmcharts/postgres-dbaas/.helmignore +++ /dev/null @@ -1,22 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/legacy/helmcharts/postgres-dbaas/Chart.yaml b/legacy/helmcharts/postgres-dbaas/Chart.yaml deleted file mode 100644 index d1491904..00000000 --- a/legacy/helmcharts/postgres-dbaas/Chart.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: v2 -name: postgres-dbaas -description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -version: 0.1.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. -appVersion: 1.16.0 diff --git a/legacy/helmcharts/postgres-dbaas/templates/_helpers.tpl b/legacy/helmcharts/postgres-dbaas/templates/_helpers.tpl deleted file mode 100644 index d8680f0a..00000000 --- a/legacy/helmcharts/postgres-dbaas/templates/_helpers.tpl +++ /dev/null @@ -1,87 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "postgres-dbaas.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -*/}} -{{- define "postgres-dbaas.fullname" -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "postgres-dbaas.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create full hostname for autogenerated hosts -*/}} -{{- define "postgres-dbaas.autogeneratedHost" -}} -{{- printf "%s.%s" .Release.Name .Values.routesAutogenerateSuffix | trimSuffix "-" -}} -{{- end -}} - -{{- define "postgres-dbaas.fullnameUppercase" -}} -{{ include "postgres-dbaas.fullname" . | upper | replace "-" "_" }} -{{- end -}} - -{{/* -Common labels -*/}} -{{- define "postgres-dbaas.labels" -}} -helm.sh/chart: {{ include "postgres-dbaas.chart" . }} -{{ include "postgres-dbaas.selectorLabels" . }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{ include "postgres-dbaas.lagoonLabels" . }} -{{- end -}} - -{{/* -Add annotations -*/}} -{{- define "postgres-dbaas.annotations" -}} -{{ if .Values.annotations }} -{{- toYaml .Values.annotations }} -{{- end }} -{{- end -}} - -{{/* -Selector labels -*/}} -{{- define "postgres-dbaas.selectorLabels" -}} -app.kubernetes.io/name: {{ include "postgres-dbaas.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end -}} - -{{/* -Lagoon Labels -*/}} -{{- define "postgres-dbaas.lagoonLabels" -}} -lagoon.sh/service: {{ .Release.Name }} -lagoon.sh/service-type: {{ .Chart.Name }} -lagoon.sh/project: {{ .Values.project }} -lagoon.sh/environment: {{ .Values.environment }} -lagoon.sh/environmentType: {{ .Values.environmentType }} -lagoon.sh/buildType: {{ .Values.buildType }} -{{- end -}} - -{{/* -Annotations -*/}} -{{- define "postgres-dbaas" -}} -lagoon.sh/version: {{ .Values.lagoonVersion | quote }} -{{- if .Values.branch }} -lagoon.sh/branch: {{ .Values.branch | quote }} -{{- end }} -{{- if .Values.prNumber }} -lagoon.sh/prNumber: {{ .Values.prNumber | quote }} -lagoon.sh/prHeadBranch: {{ .Values.prHeadBranch | quote }} -lagoon.sh/prBaseBranch: {{ .Values.prBaseBranch | quote }} -{{- end }} -{{- end -}} diff --git a/legacy/helmcharts/postgres-dbaas/templates/dbaas.yaml b/legacy/helmcharts/postgres-dbaas/templates/dbaas.yaml deleted file mode 100644 index 231c05a6..00000000 --- a/legacy/helmcharts/postgres-dbaas/templates/dbaas.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: postgres.amazee.io/v1 -kind: PostgreSQLConsumer -metadata: - name: {{ include "postgres-dbaas.fullname" . }} - labels: - {{- include "postgres-dbaas.labels" . | nindent 4 }} - annotations: - {{- include "postgres-dbaas.annotations" . | nindent 4 }} - -spec: - environment: {{ .Values.environment}} \ No newline at end of file diff --git a/legacy/helmcharts/postgres-dbaas/values.yaml b/legacy/helmcharts/postgres-dbaas/values.yaml deleted file mode 100644 index 03e79048..00000000 --- a/legacy/helmcharts/postgres-dbaas/values.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# Default values for postgres-dbaas. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -environment: "" - -readReplicaHosts: "" - -imageCache: ""