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

ServiceClass: extract data from secrets

XMLWordPrintable

    • Icon: Story Story
    • Resolution: Done
    • Icon: Critical Critical
    • Primaza 0.1
    • None
    • Service Binding
    • None
    • 3
    • False
    • None
    • False
    • Hide
      Feature: ServicesClasses can extract RegisteredService from resource-linked secrets

          Background:
              Given Primaza Cluster "main" is running
              And Worker Cluster "worker" for ClusterEnvironment "worker" is running
              And Clusters "main" and "worker" can communicate
              And On Worker Cluster "worker", service namespace "services" for ClusterEnvironment "worker" exists
              And On Worker Cluster "worker", Primaza Service Agent is deployed into namespace "services"
              And Resource "backend_crd.yaml" is installed on worker cluster "worker" in namespace "services"
              And On Primaza Cluster "main", Resource is created
                  """
                  apiVersion: rbac.authorization.k8s.io/v1
                  kind: RoleBinding
                  metadata:
                      name: primaza:reporter-svc-worker-services
                      namespace: primaza-system
                  roleRef:
                      apiGroup: rbac.authorization.k8s.io
                      kind: Role
                      name: primaza-reporter
                  subjects:
                  - kind: ServiceAccount
                    name: primaza-svc-worker-services
                  """

          Scenario: A Service Class creates Registered Services as specified
              Given On Worker Cluster "worker", Resource is created
                  """
                  apiVersion: stable.example.com/v1
                  kind: Backend
                  metadata:
                      name: $scenario_id
                      namespace: services
                  spec:
                      fromSecret:
                      - secretName: $scenario_id-sec
                        secretKey: internal-host
                  ---
                  apiVersion: v1
                  kind: Secret
                  metadata:
                      name: $scenario_id-sec
                      namespace: services
                  stringData:
                      internal-host: internal.db.stable.example.com
                  """
              When 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
                          serviceEndpointDefinitionMappings:
                              secretRefFields:
                              - name: host
                                secretName: .spec.fromSecret[0].secretName
                                secretKey: .spec.fromSecret[0].secretKey
                      serviceClassIdentity:
                        - name: type
                          value: backend
                        - name: provider
                          value: stable.example.com
                        - name: version
                          value: v1
                  """
              Then The resource registeredservices.primaza.io/$scenario_id:primaza-system is available in cluster "main"
              And jsonpath ".spec.serviceEndpointDefinition[0]" on "registeredservices.primaza.io/$scenario_id:primaza-system" in cluster main is "{"name": "host", "valueFromSecret": {"key": "host", "name": "$scenario_id-descriptor"}}"
              And The resource secrets/$scenario_id-descriptor:primaza-system is available in cluster "main"
              And jsonpath ".data.host" on "secrets/$scenario_id-descriptor:primaza-system" in cluster main is ""aW50ZXJuYWwuZGIuc3RhYmxlLmV4YW1wbGUuY29t""
      Show
      Feature: ServicesClasses can extract RegisteredService from resource-linked secrets     Background:         Given Primaza Cluster "main" is running         And Worker Cluster "worker" for ClusterEnvironment "worker" is running         And Clusters "main" and "worker" can communicate         And On Worker Cluster "worker", service namespace "services" for ClusterEnvironment "worker" exists         And On Worker Cluster "worker", Primaza Service Agent is deployed into namespace "services"         And Resource "backend_crd.yaml" is installed on worker cluster "worker" in namespace "services"         And On Primaza Cluster "main", Resource is created             """             apiVersion: rbac.authorization.k8s.io/v1             kind: RoleBinding             metadata:                 name: primaza:reporter-svc-worker-services                 namespace: primaza-system             roleRef:                 apiGroup: rbac.authorization.k8s.io                 kind: Role                 name: primaza-reporter             subjects:             - kind: ServiceAccount               name: primaza-svc-worker-services             """     Scenario: A Service Class creates Registered Services as specified         Given On Worker Cluster "worker", Resource is created             """             apiVersion: stable.example.com/v1             kind: Backend             metadata:                 name: $scenario_id                 namespace: services             spec:                 fromSecret:                 - secretName: $scenario_id-sec                   secretKey: internal-host             ---             apiVersion: v1             kind: Secret             metadata:                 name: $scenario_id-sec                 namespace: services             stringData:                 internal-host: internal.db.stable.example.com             """         When 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                     serviceEndpointDefinitionMappings:                         secretRefFields:                         - name: host                           secretName: .spec.fromSecret[0].secretName                           secretKey: .spec.fromSecret[0].secretKey                 serviceClassIdentity:                   - name: type                     value: backend                   - name: provider                     value: stable.example.com                   - name: version                     value: v1             """         Then The resource registeredservices.primaza.io/$scenario_id:primaza-system is available in cluster "main"         And jsonpath ".spec.serviceEndpointDefinition[0]" on "registeredservices.primaza.io/$scenario_id:primaza-system" in cluster main is "{"name": "host", "valueFromSecret": {"key": "host", "name": "$scenario_id-descriptor"}}"         And The resource secrets/$scenario_id-descriptor:primaza-system is available in cluster "main"         And jsonpath ".data.host" on "secrets/$scenario_id-descriptor:primaza-system" in cluster main is ""aW50ZXJuYWwuZGIuc3RhYmxlLmV4YW1wbGUuY29t""
    • AppSvc Sprint 237

      Owner: Architect:

      Francesco Ilario

      Story (Required)

      As a Primaza Developer,
      I would like Primaza to extract data from secret's related to my deployment
      so that I can extract secret data for a given service

      Background (Required)

      As defined in the Primaza architecture document, we need to build RegisteredService's Service Endpoint Deinition from Service specification and from linked secrets.

      See epic for arch document link.

      Glossary

      See glossary in architecture document

      Out of scope

      NA

      In Scope

      • Secret's data extraction

      Approach(Required)

      Given the following service and secret:

      apiVersion: stable.example.com/v1
      kind: Backend
      metadata: 
      	name: backend
      	namespace: services
      spec: 
      	fromSecret: 
      	- secretName: backend-sec
      	  secretKey: internal-host
      ---
      apiVersion: v1
      kind: Secret
      metadata: 
      	name: backend-sec
      	namespace: services
      stringData: 
      	internal-host: internal.db.stable.example.com
      

      we want to use the following ServiceClass for extracting the internal-host from the backend's secret:

      apiVersion: primaza.io/v1alpha1
      kind: ServiceClass
      metadata: 
      	name: demo
      	namespace: services
      spec: 
      	constraints: {}
      	resource: 
      		apiVersion: stable.example.com/v1
      		kind: Backend
      		serviceEndpointDefinitionMappings: 
      			secretRefFields: 
      			- name: host
      			  secretName: .spec.fromSecret[0].secretName
      			  secretKey: .spec.fromSecret[0].secretKey
      	serviceClassIdentity: 
      	  - name: type
      		value: backend
      

      The data extracted from secrets MUST always be stored in another secret and never in RegisteredServices' specification.

      The secretName and secretKey should be defined as JSONPath.

      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
        ServiceClass controller fetches data from resource related secrets
      • QE
        There are test cases for data fetched from resource related secrets
      • Docs
        There is a section in our ServiceClass docs dedicated to explaining how data is fetched from a related Secret
        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

              ansadler@redhat.com Andy Sadler
              rh-ee-filario Francesco Ilario
              Francesco Ilario
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: