Skip to content

Commit

Permalink
Add service instance and service binding to spring-music
Browse files Browse the repository at this point in the history
  • Loading branch information
trisberg committed Nov 11, 2024
1 parent 890ff84 commit 5861e2d
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 62 deletions.
76 changes: 14 additions & 62 deletions spring-music/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,48 +171,24 @@ tanzu deploy
```

<!--- #IF(#persistenceType == 'redis') -->
### Create the service and bind it to the app

You can deploy a Redis instance using a provided service type.
To list available service types use:

```shell
tanzu services type list
```

Then, create the service instance using:

```shell
tanzu services create RedisCluster/music
```
### Check the status of the service bound to the app

When prompted, bind the service to your deployed app.
The deployment includes a Redis instance using a provided service type.
The instance is bound to the app.

You can list the services you have created using:
You can list the services created using:

```shell
tanzu services list
```
<!--- #ENDIF -->
<!--- #IF(#persistenceType == 'mongodb') -->
### Create the service and bind it to the app

You can deploy a mongoDB instance using a provided service type.
To list available service types use:

```shell
tanzu services type list
```

Then, create the service instance using:

```shell
tanzu services create MongoDBInstance/music
```
### Check the status of the service bound to the app

When prompted, bind the service to your deployed app.
The deployment includes a MongoDB instance using a provided service type.
The instance is bound to the app.

You can list the services you have created using:
You can list the services created using:

```shell
tanzu services list
Expand All @@ -229,45 +205,21 @@ No service binding is necessary.

<!--- #ENDIF -->
<!--- #IF(#databaseType == 'mysql') -->
You can deploy a MySQL instance using a provided service type.
To list available service types use:

```shell
tanzu services type list
```

Create a MySQL database service instance using:

```shell
tanzu services create MySQLInstance/music
```

When prompted, bind the service to your deployed app.
The deployment includes a MySQL instance using a provided service type.
The instance is bound to the app.

You can list the services you have created using:
You can list the services created using:

```shell
tanzu services list
```

<!--- #ENDIF -->
<!--- #IF(#databaseType == 'postgres') -->
You can deploy a PostgreSQL instance using a provided service type.
To list available service types use:

```shell
tanzu services type list
```

Create a PostgreSQL database service instance using:

```shell
tanzu services create PostgreSQLInstance/music
```

When prompted, bind the service to your deployed app.
The deployment includes a PostgreSQL instance using a provided service type.
The instance is bound to the app.

You can list the services you have created using:
You can list the services created using:

```shell
tanzu services list
Expand Down
30 changes: 30 additions & 0 deletions spring-music/accelerator.axl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,36 @@ engine {
ReplaceText({{text: "spring-music", with: #artifactId.toLowerCase()}})
RewritePath(rewriteTo: '.tanzu/config/' + #artifactId.toLowerCase() + '.yml')
}
if ((#persistenceType == 'jpa' && #databaseType != 'h2') || #persistenceType == 'mongodb' || #persistenceType == 'redis') {
applyTo("deploy/tpfork8s/.tanzu/config/spring-music-binding.yml") {
ReplaceText({{text: "spring-music", with: #artifactId.toLowerCase()}})
RewritePath(rewriteTo: '.tanzu/config/' + #artifactId.toLowerCase() + '-binding.yml')
}
}
if (#persistenceType == 'jpa' && #databaseType == 'mysql') {
applyTo("deploy/tpfork8s/.tanzu/config/spring-music-mysql-instance.yml") {
ReplaceText({{text: "spring-music", with: #artifactId.toLowerCase()}})
RewritePath(rewriteTo: '.tanzu/config/' + #artifactId.toLowerCase() + '-mysql-instance.yml')
}
}
if (#persistenceType == 'jpa' && #databaseType == 'postgres') {
applyTo("deploy/tpfork8s/.tanzu/config/spring-music-postgresql-instance.yml") {
ReplaceText({{text: "spring-music", with: #artifactId.toLowerCase()}})
RewritePath(rewriteTo: '.tanzu/config/' + #artifactId.toLowerCase() + '-postgresql-instance.yml')
}
}
if (#persistenceType == 'mongodb') {
applyTo("deploy/tpfork8s/.tanzu/config/spring-music-mongodb-instance.yml") {
ReplaceText({{text: "spring-music", with: #artifactId.toLowerCase()}})
RewritePath(rewriteTo: '.tanzu/config/' + #artifactId.toLowerCase() + '-mongodb-instance.yml')
}
}
if (#persistenceType == 'redis') {
applyTo("deploy/tpfork8s/.tanzu/config/spring-music-redis-instance.yml") {
ReplaceText({{text: "spring-music", with: #artifactId.toLowerCase()}})
RewritePath(rewriteTo: '.tanzu/config/' + #artifactId.toLowerCase() + '-redis-instance.yml')
}
}
select(!"deploy/**")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: services.tanzu.vmware.com/v1
kind: ServiceBinding
metadata:
generateName: music-
spec:
alias: music
serviceRef:
apiGroup: bitnami.database.tanzu.vmware.com
#IF(#persistenceType == 'jpa')
#IF(#databaseType != 'h2')
#IF(#databaseType == 'mysql')
kind: MySQLInstance
#ENDIF
#IF(#databaseType == 'postgres')
kind: PostgreSQLInstance
#ENDIF
#ENDIF
#ELSE
#IF(#persistenceType == 'mongodb')
kind: MongoDBInstance
#ENDIF
#IF(#persistenceType == 'redis')
kind: RedisCluster
#ENDIF
#ENDIF
name: music
targetRef:
apiGroup: apps.tanzu.vmware.com
kind: ContainerApp
name: spring-music
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: bitnami.database.tanzu.vmware.com/v1alpha1
kind: MongoDBInstance
metadata:
name: music
spec:
storageGB: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: bitnami.database.tanzu.vmware.com/v1alpha1
kind: MySQLInstance
metadata:
name: music
spec:
storageGB: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: bitnami.database.tanzu.vmware.com/v1alpha1
kind: PostgreSQLInstance
metadata:
name: music
spec:
storageGB: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: bitnami.database.tanzu.vmware.com/v1alpha1
kind: RedisCluster
metadata:
name: music
spec:
storageGB: 1

0 comments on commit 5861e2d

Please sign in to comment.