Env Template

Environment templates are collections of resource templates and static resources that encapsulate key elements such as environment variables, lifecycle hooks, and dependencies. For example, an environment template can define the complete operational setup needed for a complex Kubernetes application.

Typically, an environment template consists of one or more resource templates or static resources. It can be used to generate one or more environment instances.


Setting Description
apiVersion Rafay’s API version eaas.envmgmt.io/v1.
Kind EnvironmentTemplate.
Metadata - description: Description or purpose of the environment template resource. Optional but recommended for visibility on the environment card.
- name: Name of the environment template.
- project: Project name where the environment template resides.
annotations: Annotations for details like category (e.g., eaas.envmgmt.io/category: Developer Productivity) and IaC source (eaas.envmgmt.io/github).
labels: Key-value pairs for identifying attributes of the environment template (e.g., environment: dev).
spec -> agents The name of the agent designated to execute the code for all resource templates in this environment template.
spec -> iconURL Base64 encoded icon representing the resource created by the environment template.
spec -> readme Inline README documentation (supports HTML formatting) for usage instructions.
spec -> resources A list of resources including:
- name
- kind (e.g., resourcetemplate, resource, or environment)
- resourceOptions: Version information.
- type: dynamic or static.
Dependency Ordering: Driven by dependsOn.
spec -> variables List of input variables:
- name: Name of the variable.
- valueType: hcl, json, expression, text.
- overrideType: allowed, notallowed, restricted.
- required: true or false.
- value: Single value.
- sensitive: true (encrypted) or false.
spec -> contexts Refers to Config Context defined outside of the environment template for passing settings (variables, files, etc.).
spec -> hooks Lifecycle hooks:
- on_completion
- on_failure
- on_init
- on_success
- provider
spec -> schedules Configures schedules for jobs (deploy, destroy, workflows):
- name: Name of the schedule.
- type: Type of schedule.
- cadence: Cron expressions, time zones, and maximum TTL.

cadence options
cron_expression: Configure schedule.
- cron_timezone: Specify time zone.
- time_to_live: Maximum duration (e.g., 8h, 2d).

opt-out options
- allow_opt_out: Allow opt-outs.
- max_allowed_duration: Maximum opt-out duration.
- max_allowed_times: Maximum number of opt-outs.
- approval: Approval workflow for opt-outs.

Sample Environment Template spec

apiVersion: eaas.envmgmt.io/v1
kind: EnvironmentTemplate
metadata:
  description: Allowed k8s_version changes
  name: caas-eks-env-tmpl
  project: dev-project
  description: Self Service for requesting a new EKS Kubernetes cluster
  displayName: EKS Cluster as a Service

  annotations:
    eaas.envmgmt.io/category: Developer Productivity

spec:
  iconURL: https://static-00.iconduck.com/assets.00/amazon-eks-icon-455x512-0zairb3r.png
  readme: "Developers...."
  agents:
  - name: agent-one
  hooks: {}
  resources:
  - kind: resourcetemplate
    name: rs-tmpl
    resourceOptions:
      version: v1
    type: dynamic
  - dependsOn:
    - name: rs-tmpl
    kind: resourcetemplate
    name: grp-rs-tmpl
    resourceOptions:
      version: v1
    type: dynamic
  - dependsOn:
    - name: grp-rs-tmpl
    kind: resourcetemplate
    name: grp-assoc-rs-tmpl
    resourceOptions:
      version: v1
    type: dynamic
  variables:
  - name: project
    options:
      override:
        type: allowed
      required: true
    value: caas-eks
    valueType: text
  - name: base_blueprint
    options:
      override:
        type: allowed
    value: minimal
    valueType: text
  - name: base_blueprint_version
    options:
      override:
        type: allowed
      required: true
    value: 1.28.0
    valueType: text
  - name: infra_addons
    options:
      override:
        type: allowed
      required: true
    value: |-
      {
        "addon1" = {
             name          = "cert-manager"
             namespace     = "cert-manager"
             addon_version = "v1.9.1"
             chart_name    = "cert-manager"
             chart_version = "v1.12.3"
             repository    = "cert-manager"
             file_path     = "file://./artifacts/cert-manager/custom_values.yaml"
             depends_on    = []
        }
      }
    valueType: hcl
   version: v1

Note: By default, the field name is displayed on the form as-is when creating the environment. To present a more user-friendly name, the "alias" feature can be utilized.

Suppose base_blueprint_version is an input variable in the resource template res-temp. If you want it to appear as ‘Base Blueprint Version’ during environment launch, you can use the alias override feature. This is done by defining the input variable in the Environment Template and referencing the corresponding variable in the resource template.

- name: Base Blueprint Version
    options:
      description: Enter the Blueprint version
      override:
        selectors: [resource.res-temp.base_blueprint_version]
        type: allowed
      required: true
    value: "latest"
    valueType: text

An environment variable can be mapped to multiple resource template variables, which is useful when the same input is required by multiple variables across different resource templates.