Skip to content

Test case 1: SB + postgresql running within the same namespace #25

@cmoulliard

Description

@cmoulliard

Scenario

Title: Spring Boot Petclinic application and postgresql running within the same namespace

Reference: TAP documentation to play the different scenario using RabbitMQ - here

Steps:

  1. Have access to a k8s cluster and TAP
  2. Have a postgresql DB deployed within the target namespace demo-4
  3. Create a workload where the serviceRef is defined as such ApiVersion:Kind:NameofTheResource
APP=spring-tap-petclinic
NS=demo-4
tanzu apps workload create $APP \
  -n $NS \
  --git-repo https://github.com/halkyonio/$APP.git \
  --git-branch main\
  --type web \
  --annotation "autoscaling.knative.dev/scaleDownDelay=15m" \
  --annotation "autoscaling.knative.dev/minScale=1" \
  --env "SPRING_PROFILES_ACTIVE=postgres" \
  --label app.kubernetes.io/part-of=$APP\
  --service-ref "db=sql.tanzu.vmware.com/v1:Postgres:postgres-db" \
  -y

Expected

  • Knative service within the Namespace: Yes
  • ClusterResource/postgresql: Yes
  • ResourceClaim within the Namespace: No
  • Postgres/postgres-db within the Namespace: Yes

Results:

Wait and check the workload's deployment using these commands:

NS=demo-4
APP=spring-tap-petclinic
tanzu apps -n $NS workload get $APP

## Get the URL of the service and  open the URL  in your browser
kc get ksvc/$APP -n $NS -o json | jq .status.address.url

Resources checked and their result:

  • kc get ClusterResource/postgresql: Yes
    Remark: The ClusterResource corresponds to what tanzu services types list | grep postgresql command displays
  • kc get resourceclaim -n demo-4: No
  • kc get Postgres/postgres-db -n demo-4: YES

Conclusion

The Spring Boot Petclinic Application has been well deployed, the URL of the service is accessible
No resourceclaim has been needed to do the binding using SBO. The PostgresDB resource has been used directly
to bind the DB with the Knative Service.

See the SBO spec section

spec:
  name: db
  service:
    apiVersion: sql.tanzu.vmware.com/v1
    kind: Postgres
    name: postgres-db
  workload:
    apiVersion: serving.knative.dev/v1
    kind: Service
    name: spring-tap-petclinic
status:
  binding:
    name: postgres-db-app-user-db-secret

To cleanup

APP=spring-tap-petclinic
NS=demo-4
tanzu apps workload delete $APP -n $NS -y

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions