Templates and Catalog
- This catalog item is a combination of various objects we built throughout this course.
- It has a build configuration, an image stream, a deployment configuration.
- Database credential can be stored securely in a Secret object
- The template also has a definition for user parameters seen in the Wizard such as application name, Namespace, Git repository, etc.
- All of these various components are packaged into a single template that can be deployed at once for user to deploy full application stack.
- You can create your own such template too.
- Template can be created using a YAML file using kind Template.
- Under objects section, create an array of the different objects part of the application stack such as secret, service, build config, deployment config, route, image stream
- Finally, a section for defining the parameters that user will enter in the wizard.
apiVersion: v1
kind: Template
metadata:
name: custom-app
objects:
- apiVersion: v1
kind: Secret
# ...
- apiVersion: v1
kind: Service
# ...
- apiVersion: v1
kind: Service
# ...
- apiVersion: v1
kind: Route
# ...
- apiVersion: v1
kind: BuildConfig
# ...
- apiVersion: v1
kind: DeploymentConfig
# ...
- apiVersion: v1
kind: DeploymentConfig
# ...
- apiVersion: v1
kind: ImageStream
# ...
parameters:
- deplayName: "Namespace"
name: "NAMESPACE"
- Template can be created by
oc create -f template-config.yml
- If you are not sure about the YAML config, try to copying from the existing one e.g.
oc export service db
Workshop
- Create template YAML file >>>See YAML file here<<<
- Create application from template by Add to Project --> Select from Project.