Uploaded image for project: 'Service Binding'
  1. Service Binding
  2. APPSVC-1311

Service Agent watches Service Classes' resources

XMLWordPrintable

    • Icon: Story Story
    • Resolution: Done
    • Icon: Major Major
    • Primaza 0.1
    • None
    • Service Binding
    • None
    • 5
    • False
    • None
    • False
    • Hide
      Feature: Service Agent watches Service Class Resource

          Background:
              Given Primaza Cluster "main" is running
              And Worker Cluster "worker" for "main" is running
              And Clusters "main" and "worker" can communicate
              And On Worker Cluster "worker", service namespace "services" exists
              And On Worker Cluster "worker", Primaza Service Agent is deployed into namespace "services"
              And Primaza cluster's "main" kubeconfig is available on "worker" in namespace "services"
              And Resource "backend_crd.yaml" is installed on worker cluster "worker" in namespace "services"

          Scenario: A Service Class creates Registered Services as specified
              Given On Worker Cluster "worker", Resource is created
              """
              apiVersion: primaza.io/v1alpha1
              kind: ServiceClass
              metadata:
                  name: $scenario_id-serviceclass
                  namespace: services
              spec:
                  constraints: {}
                  resource:
                      apiVersion: stable.example.com/v1
                      kind: Backend
                      serviceEndpointDefinitionMapping:
                        - name: host
                          jsonPath: .spec.host
                  serviceClassIdentity:
                    - name: type
                      value: backend
                    - name: provider
                      value: stable.example.com
                    - name: version
                      value: v1
              """
              When On Worker Cluster "worker", Resource is created
              """
              apiVersion: stable.example.com/v1
              kind: Backend
              metadata:
                  name: $scenario_id-1
                  namespace: services
              spec:
                  host: internal.db.stable.example.com
              """
              Then RegisteredService.primaza.io/$scenario_id-1 is available in cluster "main"
              And jsonpath ".spec.serviceEndpointDefinition[0]" on "registeredservices.primaza.io/$scenario_id-1" in cluster main is "{"name":"host","value":"internal.db.stable.example.com"}"

          Scenario: A Registered Service should not be created if the resource doesn't have the needed binding information
              Given On Worker Cluster "worker", Resource is created
              """
              apiVersion: primaza.io/v1alpha1
              kind: ServiceClass
              metadata:
                  name: $scenario_id-serviceclass
                  namespace: services
              spec:
                  constraints: {}
                  resource:
                      apiVersion: stable.example.com/v1
                      kind: Backend
                      serviceEndpointDefinitionMapping:
                        - name: host
                          jsonPath: .spec.host
                  serviceClassIdentity:
                    - name: type
                      value: backend
                    - name: provider
                      value: stable.example.com
                    - name: version
                      value: v1
              """
              When On Worker Cluster "worker", Resource is created
              """
              apiVersion: stable.example.com/v1
              kind: Backend
              metadata:
                  name: $scenario_id-1
                  namespace: services
              spec:
                  host_internal_db: internal.db.stable.example.com
              """
              Then The resource registeredservices.primaza.io/$scenario_id-1:services is not available in cluster "worker"

          Scenario: A Service Class updates Registered Services
              Given On Worker Cluster "worker", Resource is created
              """
              apiVersion: stable.example.com/v1
              kind: Backend
              metadata:
                  name: $scenario_id-1
                  namespace: services
              spec:
                  host: internal.db.stable.example.com
              """
              And On Worker Cluster "worker", Resource is created
              """
              apiVersion: primaza.io/v1alpha1
              kind: ServiceClass
              metadata:
                  name: $scenario_id-serviceclass
                  namespace: services
              spec:
                  constraints: {}
                  resource:
                      apiVersion: stable.example.com/v1
                      kind: Backend
                      serviceEndpointDefinitionMapping:
                        - name: host
                          jsonPath: .spec.host
                  serviceClassIdentity:
                    - name: type
                      value: backend
                    - name: provider
                      value: stable.example.com
                    - name: version
                      value: v1
              """
              And RegisteredService.primaza.io/$scenario_id-1 is available in cluster "main"
              And jsonpath ".spec.serviceEndpointDefinition[0]" on "registeredservices.primaza.io/$scenario_id-1" in cluster main is "{"name":"host","value":"internal.db.stable.example.com"}"
              When On Worker Cluster "worker", Resource is created
              """
              apiVersion: stable.example.com/v1
              kind: Backend
              metadata:
                  name: $scenario_id-1
                  namespace: services
              spec:
                  host: internal-upd.db.stable.example.com
              """
              Then RegisteredService.primaza.io/$scenario_id-1 is available in cluster "main"
              And jsonpath ".spec.serviceEndpointDefinition[0]" on "registeredservices.primaza.io/$scenario_id-1" in cluster main is "{"name":"host","value":"internal-upd.db.stable.example.com"}"

          Scenario: A Service Class deletes Registered Services
              Given On Worker Cluster "worker", Resource is created
              """
              apiVersion: stable.example.com/v1
              kind: Backend
              metadata:
                  name: $scenario_id-1
                  namespace: services
              spec:
                  host: internal.db.stable.example.com
              """
              And On Worker Cluster "worker", Resource is created
              """
              apiVersion: primaza.io/v1alpha1
              kind: ServiceClass
              metadata:
                  name: $scenario_id-serviceclass
                  namespace: services
              spec:
                  constraints: {}
                  resource:
                      apiVersion: stable.example.com/v1
                      kind: Backend
                      serviceEndpointDefinitionMapping:
                        - name: host
                          jsonPath: .spec.host
                  serviceClassIdentity:
                    - name: type
                      value: backend
                    - name: provider
                      value: stable.example.com
                    - name: version
                      value: v1
              """
              And RegisteredService.primaza.io/$scenario_id-1 is available in cluster "main"
              And jsonpath ".spec.serviceEndpointDefinition[0]" on "registeredservices.primaza.io/$scenario_id-1" in cluster main is "{"name":"host","value":"internal.db.stable.example.com"}"
              When On Worker Cluster "worker", Resource is deleted
              """
              apiVersion: stable.example.com/v1
              kind: Backend
              metadata:
                  name: $scenario_id-1
                  namespace: services
              """
              Then RegisteredService.primaza.io/$scenario_id-1 is not available in cluster "main"
      Show
      Feature: Service Agent watches Service Class Resource     Background:         Given Primaza Cluster "main" is running         And Worker Cluster "worker" for "main" is running         And Clusters "main" and "worker" can communicate         And On Worker Cluster "worker", service namespace "services" exists         And On Worker Cluster "worker", Primaza Service Agent is deployed into namespace "services"         And Primaza cluster's "main" kubeconfig is available on "worker" in namespace "services"         And Resource "backend_crd.yaml" is installed on worker cluster "worker" in namespace "services"     Scenario: A Service Class creates Registered Services as specified         Given On Worker Cluster "worker", Resource is created         """         apiVersion: primaza.io/v1alpha1         kind: ServiceClass         metadata:             name: $scenario_id-serviceclass             namespace: services         spec:             constraints: {}             resource:                 apiVersion: stable.example.com/v1                 kind: Backend                 serviceEndpointDefinitionMapping:                   - name: host                     jsonPath: .spec.host             serviceClassIdentity:               - name: type                 value: backend               - name: provider                 value: stable.example.com               - name: version                 value: v1         """         When On Worker Cluster "worker", Resource is created         """         apiVersion: stable.example.com/v1         kind: Backend         metadata:             name: $scenario_id-1             namespace: services         spec:             host: internal.db.stable.example.com         """         Then RegisteredService.primaza.io/$scenario_id-1 is available in cluster "main"         And jsonpath ".spec.serviceEndpointDefinition[0]" on "registeredservices.primaza.io/$scenario_id-1" in cluster main is "{"name":"host","value":"internal.db.stable.example.com"}"     Scenario: A Registered Service should not be created if the resource doesn't have the needed binding information         Given On Worker Cluster "worker", Resource is created         """         apiVersion: primaza.io/v1alpha1         kind: ServiceClass         metadata:             name: $scenario_id-serviceclass             namespace: services         spec:             constraints: {}             resource:                 apiVersion: stable.example.com/v1                 kind: Backend                 serviceEndpointDefinitionMapping:                   - name: host                     jsonPath: .spec.host             serviceClassIdentity:               - name: type                 value: backend               - name: provider                 value: stable.example.com               - name: version                 value: v1         """         When On Worker Cluster "worker", Resource is created         """         apiVersion: stable.example.com/v1         kind: Backend         metadata:             name: $scenario_id-1             namespace: services         spec:             host_internal_db: internal.db.stable.example.com         """         Then The resource registeredservices.primaza.io/$scenario_id-1:services is not available in cluster "worker"     Scenario: A Service Class updates Registered Services         Given On Worker Cluster "worker", Resource is created         """         apiVersion: stable.example.com/v1         kind: Backend         metadata:             name: $scenario_id-1             namespace: services         spec:             host: internal.db.stable.example.com         """         And On Worker Cluster "worker", Resource is created         """         apiVersion: primaza.io/v1alpha1         kind: ServiceClass         metadata:             name: $scenario_id-serviceclass             namespace: services         spec:             constraints: {}             resource:                 apiVersion: stable.example.com/v1                 kind: Backend                 serviceEndpointDefinitionMapping:                   - name: host                     jsonPath: .spec.host             serviceClassIdentity:               - name: type                 value: backend               - name: provider                 value: stable.example.com               - name: version                 value: v1         """         And RegisteredService.primaza.io/$scenario_id-1 is available in cluster "main"         And jsonpath ".spec.serviceEndpointDefinition[0]" on "registeredservices.primaza.io/$scenario_id-1" in cluster main is "{"name":"host","value":"internal.db.stable.example.com"}"         When On Worker Cluster "worker", Resource is created         """         apiVersion: stable.example.com/v1         kind: Backend         metadata:             name: $scenario_id-1             namespace: services         spec:             host: internal-upd.db.stable.example.com         """         Then RegisteredService.primaza.io/$scenario_id-1 is available in cluster "main"         And jsonpath ".spec.serviceEndpointDefinition[0]" on "registeredservices.primaza.io/$scenario_id-1" in cluster main is "{"name":"host","value":"internal-upd.db.stable.example.com"}"     Scenario: A Service Class deletes Registered Services         Given On Worker Cluster "worker", Resource is created         """         apiVersion: stable.example.com/v1         kind: Backend         metadata:             name: $scenario_id-1             namespace: services         spec:             host: internal.db.stable.example.com         """         And On Worker Cluster "worker", Resource is created         """         apiVersion: primaza.io/v1alpha1         kind: ServiceClass         metadata:             name: $scenario_id-serviceclass             namespace: services         spec:             constraints: {}             resource:                 apiVersion: stable.example.com/v1                 kind: Backend                 serviceEndpointDefinitionMapping:                   - name: host                     jsonPath: .spec.host             serviceClassIdentity:               - name: type                 value: backend               - name: provider                 value: stable.example.com               - name: version                 value: v1         """         And RegisteredService.primaza.io/$scenario_id-1 is available in cluster "main"         And jsonpath ".spec.serviceEndpointDefinition[0]" on "registeredservices.primaza.io/$scenario_id-1" in cluster main is "{"name":"host","value":"internal.db.stable.example.com"}"         When On Worker Cluster "worker", Resource is deleted         """         apiVersion: stable.example.com/v1         kind: Backend         metadata:             name: $scenario_id-1             namespace: services         """         Then RegisteredService.primaza.io/$scenario_id-1 is not available in cluster "main"
    • AppSvc Sprint 235, AppSvc Sprint 236

      Owner: Architect:

      Francesco Ilario

      Story (Required)

      As a Primaza Developer,
      I would like Service Agent to watch Service Classes' Resources
      so that it will create Registered Services for new resource instances

      Background (Required)

      When a Service Class is created, the Service Agent looks for resources matching its specification.
      The Service Agent also needs to monitor changes to resources matching the Service Class specifications and update Registered Services accordingly.

      See epic for arch document link.

      Glossary

      See glossary in architecture document

      Out of scope

      NA

      In Scope

      • Watcher for Service Class's resource
      • Handling Resource creation
      • Handling Resource update
      • Handling Resource deletion

      Approach(Required)

      When a Service Class is created, a watcher for the Service Class's resource must be registered.

      When a watched resource is created/updated/deleted, the Registered Service is created/updated/deleted.

      For watching resources it may be used the DynamicInformer. An example of implementation can be found here.

      Demo requirements(Required)

      NA

      Dependencies

      NA

      Edge Case

      NA

      BDD Tests

      You can find BDD Test specification for this story in the "Testing Instruction" Field Tab or in the GitHub Issue linked to this story.
      Click here for all BDD Tests Issues.

      Acceptance Criteria

      • Development
        Service Agent creates a Registered Service when a resource matching a registered Service Class is created
        Service Agent updates the Registered Service when a resource matching a registered Service Class is updated
        Service Agent deletes the Registered Service when a resource matching a registered Service Class is deleted
      • QE
        There are test cases for resource creation
        There are test cases for resource update
        There are test cases for resource deletion
      • Docs
        There is a section in our Service Agent docs dedicated to explaining how it monitors resources matching Service Classes
        Update architecture document with any changes while implementing

      INVEST Checklist

      Dependencies identified
      Blockers noted and expected delivery timelines set
      Design is implementable
      Acceptance criteria agreed upon
      Story estimated

      Legend

      Unknown
      Verified
      Unsatisfied

              kmamgain@redhat.com Kartikey Mamgain (Inactive)
              rh-ee-filario Francesco Ilario
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: