New template parameters that can be used in resources.manifests
or resources.helm.values
to define placeholders that can be used later in a template instance. These placeholders can be either used within a string (e.g. myvalue: 'Hello from ${NAMESPACE}'
) or can be rendered directly as a json value (e.g. for numbers in replicas: '${{REPLICAS}}'
. Furthermore there are 2 predefined parameters ${NAMESPACE}
(holds the namespace that the template instance was deployed in) and ${ACCOUNT}
(holds the name of the account that owns the namespace that the the template instance was deployed in). (#68)
For example:
apiVersion: config.kiosk.sh/v1alpha1
kind: Template
metadata:
name: space-restrictions
# This section defines parameters that can be used for this template
# Can be used in resources.manifests and resources.helm.values
parameters:
# Name of the parameter
- name: DEFAULT_CPU_LIMIT
# The default value of the parameter
value: "1"
- name: DEFAULT_CPU_REQUESTS
value: "0.5"
# If a parameter is required the template instance will need to set it
required: true
# Make sure only values are entered for this parameter
validation: "^[0-9]*\\.?[0-9]+$"
resources:
manifests:
- apiVersion: v1
kind: LimitRange
metadata:
name: space-limit-range
annotations:
# Parameters can also be used inside a string
example-parameter: "Hello from ${NAMESPACE}"
spec:
limits:
- default:
# Use the DEFAULT_CPU_LIMIT parameter here and
# parse it as json, which renders the "1" as 1.
cpu: "${{DEFAULT_CPU_LIMIT}}"
defaultRequest:
cpu: "${{DEFAULT_CPU_REQUESTS}}"
type: Container
In the template instance the parameters are then used as:
apiVersion: config.kiosk.sh/v1alpha1
kind: TemplateInstance
metadata:
name: space-restrictions-instance-sync
spec:
template: space-restrictions
parameters:
- name: DEFAULT_CPU_REQUESTS
value: "1"