Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the SupplyChain deploying a Quarkus application #23

Open
cmoulliard opened this issue Jun 13, 2022 · 0 comments
Open

Improve the SupplyChain deploying a Quarkus application #23

cmoulliard opened this issue Jun 13, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@cmoulliard
Copy link
Contributor

To do

Improve the SupplyChain deploying a Quarkus application to create the ResourceClaim and ServiceBinding if a ServiceRef has been defined on the workload. See the following ytt code

    #@ def get_claims_extension():
    #@   claims_extension_key = "serviceclaims.supplychain.apps.x-tanzu.vmware.com/extensions"
    #@   if not hasattr(data.values.workload.metadata, "annotations") or not hasattr(data.values.workload.metadata.annotations, claims_extension_key):
    #@     return None
    #@   end
    #@
    #@   extension = json.decode(data.values.workload.metadata.annotations[claims_extension_key])
    #@
    #@   spec_extension = extension.get('spec')
    #@   if spec_extension == None:
    #@     return None
    #@   end
    #@
    #@   return spec_extension.get('serviceClaims')
    #@ end

    #@ def merge_claims_extension(claim, claims_extension):
    #@   if claims_extension == None:
    #@     return claim.ref
    #@   end
    #@   extension = claims_extension.get(claim.name)
    #@   if extension == None:
    #@      return claim.ref
    #@   end
    #@   extension.update(claim.ref)
    #@   return extension
    #@ end

    #@ def claims():
    #@ claims_extension = get_claims_extension()
    #@ for s in data.values.workload.spec.serviceClaims:
    ---
    apiVersion: services.apps.tanzu.vmware.com/v1alpha1
    kind: ResourceClaim
    metadata:
      name: #@ data.values.workload.metadata.name + '-' + s.name
      annotations: #@ merge_annotations({})
      labels: #@ merge_labels({ "app.kubernetes.io/component": "run", "carto.run/workload-name": data.values.workload.metadata.name })
    spec:
      ref: #@ merge_claims_extension(s, claims_extension)
    ---
    apiVersion: servicebinding.io/v1alpha3
    kind: ServiceBinding
    metadata:
      name: #@ data.values.workload.metadata.name + '-' + s.name
      annotations: #@ merge_annotations({})
      labels: #@ merge_labels({ "app.kubernetes.io/component": "run", "carto.run/workload-name": data.values.workload.metadata.name })
    spec:
      name: #@ s.name
      service:
        apiVersion: services.apps.tanzu.vmware.com/v1alpha1
        kind: ResourceClaim
        name: #@ data.values.workload.metadata.name + '-' + s.name
      workload:
        apiVersion: serving.knative.dev/v1
        kind: Service
        name: #@ data.values.workload.metadata.name
    #@ end
    #@ end
@cmoulliard cmoulliard added the enhancement New feature or request label Jun 13, 2022
cmoulliard added a commit that referenced this issue Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant