Skip to main content
Version: v4.5.0

Create your packages

Package, Components, and Revision

For you who develop applications to be able to access and use the Cloud components, it is necessary to provide a package with these components. In Runtimes, the creation of these packages is abstracted in:

That way, the Runtimes engine groups, versions, and makes Cloud components available. Check below the steps to create a Cloud component package with Runtimes.

Create Package

The Package is the structure that will group your components. To create the Package, enter the name of the package in the "name:" fields and the description of the package content in the "description:" field and execute the command below in your terminal:

curl --location --request PUT 'https://runtime-engine-api.runtimes.stackspot.com/packages' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "package-name",
"description": "package-description"
}'

The request will return the Package ID.

Create Revision

A Revision represents a version of your package's components. Each Revision generates a new version of a Package's components. To generate a Revision follow the steps below:

Packing the Components

The Components (Cloud components) need to be in a directory structure that represents your Package so that you can generate the component package. In Runtimes, the Components must be inside a /definitions folder and in the root of the folder you must create the file metadata.yaml. To generate the package, follow the steps below:

Step 1. Create your package folder

Create a folder with the name given to create the Package, then inside it, create the folder definitions.

Step 2. Create the metadata.yaml file

In the root of the directory, create the file metadata.yaml as in the example below:

root/User/package-name/metadata.yaml
name: "package-name"                                              
version: 1.0.0
description: "package_description"
icon: https://legacy.stackspot.com/_next/static/media/logo.e8653093.svg
url: http://legacy.stackspot.com/

tags:
- stackspot
- package

deployTo:
control_plane: true
runtime_cluster: true

invisible: false
}

Step 3. Add your components in the definitions folder

Consider that you have written a DynamoDB database component "dynamodb.yaml".

Click here to see component examples
root/User/package-name/definitions/dynamodb.yaml
apiVersion: core.oam.dev/v1beta1
kind: ComponentDefinition
metadata:
name: sample-dynamodb
namespace: samples
annotations:
definition.oam.dev/description: "Sample AWS dynamoDB resource"
spec:
workload:
type: autodetects.core.oam.dev
schematic:
cue:
template: |
import("encoding/json")
output: {
apiVersion: "dynamodb.aws.crossplane.io/v1alpha1"
kind: "Table"
metadata: {
name: context.name
namespace: context.namespace
}
spec: {
forProvider: {
attributeDefinitions: [
for _, v in parameter.attributes {
attributeName: v.name
attributeType: v.type
}
]
keySchema: [
for _, v in parameter.primaryKey {
attributeName: v.name
keyType: v.type
}
]
globalSecondaryIndexes: [
for _, gs in parameter.globalSecondary {
indexName: gs.name
projection: {
projectionType: gs.projection
}
provisionedThroughput: {
readCapacityUnits: gs.rcu
writeCapacityUnits: gs.wcu
}
keySchema:[
for _, v in gsi.keySchema {
attributeName: v.name
keyType: v.type
}
]
}
]
provisionedThroughput: {
readCapacityUnits: 1
writeCapacityUnits: 1
}

billingMode: "PROVISIONED"
region: parameter.region
sseSpecification: enabled: true
}
providerConfigRef: name: "aws-provider"
}
}
outputs: {
"policy": {
apiVersion: "iam.aws.crossplane.io/v1beta1"
kind: "Policy"
metadata: name: context.name+"-policy"
spec: {
forProvider: {
name: context.name+"-policy"
document:
json.Marshal({
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Action: [
"dynamodb:UpdateTimeToLive",
"dynamodb:UpdateItem",
"dynamodb:Scan",
"dynamodb:PutItem",
"dynamodb:GetItem",
"dynamodb:DescribeTimeToLive",
"dynamodb:DescribeTable",
"dynamodb:DeleteItem",
"dynamodb:ConditionCheckItem",
"dynamodb:BatchWriteItem",
"dynamodb:BatchGetItem",
"dynamodb:Query",
],
Resource: [
"arn:aws:dynamodb:"+parameter.region+":*:table/"+context.name,
"arn:aws:dynamodb:"+parameter.region+":*:table/"+context.name+"/*"
]
}
]
})
}
providerConfigRef: name: "aws-provider"
}
}
"attach": {
apiVersion: "iam.aws.crossplane.io/v1beta1"
kind: "RolePolicyAttachment"
metadata: name: context.name+"-role-policy-attachment"
spec: {
forProvider: {
policyArnRef: name: context.name+"-policy"
roleNameRef: name: context.appName
}
providerConfigRef: name: "aws-provider"
}
}
}
parameter: {
// +usage=region where resource will be create us-east-1 is default value
region: *"us-east-1" | string
// +usage=attribute definitions using format {name: ... type: ...}
attributes: [...{name:string,type:string}]
// +usage=keys definitions using format {name: ... type: ...}
primaryKey: [...{name:string,type:string}]
globalSecondary: [...{name:string,projection:string,wcu:int,rcu:int,keySchema:[...{name:string,type:string}]}]
}

Put all the components inside the /definitions folder, and you will have the following structure:

.
├── package-name
│   ├── definitions
│   └── dynamodb.yaml
| ├── metadata.yaml

Step 4. Package the files to generate your Revision

Now is the time to send the package to StackSpot to generate the Revision, but first, the metadata.yaml files and all the contents of the /definitions folder must be packaged as a single file to be processed by the Runtimes. You must compress these files in .zip or .tar format.

Check out the following examples to generate a .tar or .zip file:

Inside the package folder, run the command:

Zip:

zip package-name.zip definitions/*.yaml metadata.yaml

Tar:

tar cfv package-name.tar definitions/*.yaml metadata.yaml

Generate your package version

info

Use the Package ID generated earlier in place of "{pkgId}" from the request below.

Fill out the request by entering the Package ID in the request URL and in the --form 'package=@"{/path}"' field the path to the .tar or .zip file. (Ex.: --form 'package=@"/root/User/package-name/package-name.tar"').

After that, run the request in your terminal:

curl --location --request PUT 'https://runtime-engine-api.runtimes.stackspot.com/packages/{pkgId}' \
--form 'package=@"/root/User/package-name/package-name.tar"'

Consult Revision

After publishing one or more Revisions, you can query them with the Runtimes API. Fill in the desired {packageId}/{revision} (PackageID and Revision) in the request, then run the command below:

curl --location --request GET 'https://runtime-engine.runtime-controlplane.sbox.stackspot.com/packages/{packageId}/{revision}'

Enable and Disable Revisions

When you create a Revision, by default it is enabled for use.

You can disable and enable Revisions to better control the lifecycle of your component and ensure that all users will use the most up-to-date version of some component.

Fill in the following fields in the request: {packageId}/{revision} (PackageID and desired Revision), then fill in the field --data-raw and set the "enable:" values:

  • true to Enable the Revision:
curl --location --request PATCH 'https://runtime-engine.runtime-controlplane.sbox.stackspot.com/packages/{packageId}/{revision}/' \
--header 'Content-Type: application/json' \
--data-raw '{
"enabled": true
}'
  • false to Disable the Revision.
curl --location --request PATCH 'https://runtime-engine.runtime-controlplane.sbox.stackspot.com/packages/{revision}/{revision}/' \
--header 'Content-Type: application/json' \
--data-raw '{
"enabled": false
}'

Was this page helpful?