Compose Plan Lifecycle Example¶
After building from Compose, use this example to create free and premium plans, publish a changed version, and mount configuration and secret files. Complete Step 1 and choose your deployment model first.
Warning
These examples use illustrative images and credentials. Pin artifacts, configure the intended account, and manage secrets before production use. Run only in an approved disposable development environment. Creating instances can incur charges.
Create and Evolve Your Plans¶
Create a Postgres product with free and premium plans, then release an updated plan version in development. Replace the example image tags with pinned versions and use supported secrets instead of the illustrative static credentials before deploying outside a disposable environment. Adapt the Dev environment name to your configured development environment.
Step 1: Create a SaaS Product with a Free Tier Plan¶
To start, create a free tier plan for the Postgres service.
Save omnistrate-compose.yaml with the following contents:
version: "3.9"
x-omnistrate-service-plan:
name: 'Postgres Free'
tenancyType: 'OMNISTRATE_MULTI_TENANCY'
services:
postgres:
image: postgres
ports:
- '5432:5432'
environment:
- SECURITY_CONTEXT_USER_ID=999
- SECURITY_CONTEXT_GROUP_ID=999
- POSTGRES_USER=default
- POSTGRES_PASSWORD=default
- PGDATA=/var/lib/postgresql/data/dbdata
volumes:
- ./data:/var/lib/postgresql/data
deploy:
resources:
limits:
cpus: '0.50'
memory: 50M
reservations:
cpus: '0.25'
memory: 20M
x-omnistrate-capabilities:
autoscaling:
minReplicas: 1
maxReplicas: 5
serverlessConfiguration:
enableAutoStop: true
minimumNodesInPool: 1
targetPort: 5432
In this example, a free tier plan is created for the Postgres service, optimized for cost savings and scalability. The plan leverages multitenancy and serverless configuration, including auto-stop to minimize costs when the service is not in use.
Run the following command to build the service:
omnistrate-ctl build --file omnistrate-compose.yaml --product-name "Postgres" --environment "Dev" --environment-type "dev" --release --release-description "Development plan example"
Inspect the released development plan and use the organization-only Customer Portal to create a test instance. Verify the application before considering production promotion.
Step 2: Enhance your SaaS Product by Adding a Premium Plan¶
Next, let's enhance the service by adding a premium plan.
Save omnistrate-compose.yaml with the following contents:
version: "3.9"
x-omnistrate-service-plan:
name: 'Postgres Premium'
tenancyType: 'OMNISTRATE_DEDICATED_TENANCY'
services:
postgres:
image: postgres
ports:
- '5432:5432'
environment:
- SECURITY_CONTEXT_USER_ID=999
- SECURITY_CONTEXT_GROUP_ID=999
- POSTGRES_USER=default
- POSTGRES_PASSWORD=default
- PGDATA=/var/lib/postgresql/data/dbdata
volumes:
- ./data:/var/lib/postgresql/data
x-omnistrate-capabilities:
autoscaling:
minReplicas: 1
maxReplicas: 5
This plan offers dedicated tenancy with enhanced performance and resource allocation for users who require more robust features and higher limits.
Run the following command to build and release the premium plan in development:
omnistrate-ctl build --file omnistrate-compose.yaml --product-name "Postgres" --environment "Dev" --environment-type "dev" --release --release-description "Development plan example"
Step 3: Update your SaaS Product as You Evolve your Service¶
Based on the previous example, let's update the Postgres service's free tier plan to include more features and capabilities.
Save omnistrate-compose.yaml with the following contents:
version: "3.9"
x-omnistrate-service-plan:
name: 'Postgres Free'
tenancyType: 'OMNISTRATE_MULTI_TENANCY'
x-customer-integrations:
logs:
metrics:
services:
postgres:
image: postgres
ports:
- '5432:5432'
environment:
- SECURITY_CONTEXT_USER_ID=999
- SECURITY_CONTEXT_GROUP_ID=999
- POSTGRES_USER=default
- POSTGRES_PASSWORD=default
- PGDATA=/var/lib/postgresql/data/dbdata
volumes:
- ./data:/var/lib/postgresql/data
deploy:
resources:
limits:
cpus: '0.50'
memory: 50M
reservations:
cpus: '0.25'
memory: 20M
x-omnistrate-capabilities:
autoscaling:
minReplicas: 1
maxReplicas: 5
serverlessConfiguration:
enableAutoStop: true
minimumNodesInPool: 1
targetPort: 5432
In this example, the free tier plan for the Postgres service is updated to include logs and metrics integration and enable autoscaling. These enhancements provide better monitoring and scalability for the service.
Run the following command to update and release the free plan in development:
omnistrate-ctl build --file omnistrate-compose.yaml --product-name "Postgres" --environment "Dev" --environment-type "dev" --release --release-description "Development plan example"
Step 4: Mounting Configuration and Secret Files (Optional)¶
The CTL allows users to define and manage configuration files and secret files required by their services. These files can be specified in the compose specification and will be automatically mounted to the specified paths in the service containers.
Configuration Files¶
To specify configuration files in the compose spec file, use the following format:
services:
service:
configs:
- source: my_config # The name of the config
target: /etc/config/my_config.txt # The target path in the container
configs:
my_config: # The name of the config
file: ./my_config.txt # The path to the config file in your local filesystem
This example shows how to define a config named my_config and mount it to the path /etc/config/my_config.txt within the service container.
Secret Files¶
Similarly, you can specify secret files as follows:
services:
service:
secrets:
- source: server-certificate # The name of the secret
target: /etc/ssl/certs/server.cert # The target path in the container
secrets:
server-certificate: # The name of the secret
file: ./server.cert # The path to the secret file in your local filesystem
Here is a comprehensive example of a compose spec file for a Postgres service that includes both configuration and secret files:
version: "3.9"
x-omnistrate-service-plan:
name: 'Postgres Premium'
tenancyType: 'OMNISTRATE_DEDICATED_TENANCY'
services:
postgres:
image: postgres
configs:
- source: postgres-config
target: /etc/postgresql/postgresql.conf
secrets:
- source: postgres-secret
target: /run/secrets/postgres.secret
ports:
- '5432:5432'
environment:
- SECURITY_CONTEXT_USER_ID=999
- SECURITY_CONTEXT_GROUP_ID=999
- POSTGRES_USER=default
- POSTGRES_PASSWORD=default
- PGDATA=/var/lib/postgresql/data/dbdata
volumes:
- ./data:/var/lib/postgresql/data
x-omnistrate-capabilities:
autoscaling:
minReplicas: 1
maxReplicas: 5
configs:
postgres-config:
file: ./config/postgres.conf
secrets:
postgres-secret:
file: ./secrets/postgres.secret
In this example, the postgres service uses a configuration file for Postgres settings and a secret file for sensitive information. These files are specified in the configs and secrets sections and mounted to the appropriate paths within the container.
Name the above file as omnistrate-compose.yaml and run the following command to build the service. Make sure the paths to the configuration and secret files are correct and accessible from the location where you run the CTL command.
omnistrate-ctl build --file omnistrate-compose.yaml --product-name "Postgres" --environment "Dev" --environment-type "dev" --release --release-description "Development plan example"
Next: Test the customer journey and release process before preparing for production.