Understanding Catalog Items
Catalog items in OpenShift combine multiple objects into a single deployable unit. For instance, take the Django and PostgreSQL catalog item. This catalog item includes several critical components that work together to deliver a complete application stack:- A BuildConfig to compile the application.
- An ImageStream to tag completed builds.
- A DeploymentConfig to deploy the application.
- An additional DeploymentConfig to deploy a PostgreSQL database.
- A Service to expose the PostgreSQL database on port 5432.
- A Secret object to securely store database credentials.
- Another Service to expose the application on port 8080.
- A Route to provide user access to the application.
- A section that defines user parameters (such as application name, namespace, and Git repository) through an input wizard.
Creating a Template
Templates in OpenShift can be created by uploading or downloading a YAML or JSON file. The following steps outline how to create a template using YAML:-
Define the Template Metadata
Start by creating a YAML file where you declare the API version and kind. For example:
-
Specify the Application Stack Objects
Under the
objectssection, list the various objects that make up your application stack. This can include Secrets, Services, Routes, BuildConfigs, DeploymentConfigs, and ImageStreams. Below is an abbreviated example: -
Create and Deploy the Template
Save your file as
template-config.yaml(or any other name you prefer), and then create the template by running the following command in your terminal:
If you’re not sure how to construct the YAML for a particular service, you can export the existing configuration by running:This command outputs the YAML configuration for the service, which you can modify and parameterize as needed.