Config Context
ConfigOption
func ConfigOption(optionName string) string
Returns the value of the config option as a string.
For information about the config screen and associated options, see Config in the Custom Resources section.
'{{repl ConfigOption "hostname" }}'
ConfigOption
returns the base64 encoded value of the file
config option.
'{{repl ConfigOption "ssl_key"}}'
To use files in a Secret, use ConfigOption
:
apiVersion: v1
kind: Secret
metadata:
name: tls-secret
type: kubernetes.io/tls
data:
tls.crt: '{{repl ConfigOption "tls_certificate_file" }}'
tls.key: '{{repl ConfigOption "tls_private_key_file" }}'
For more information about using TLS certificates, see Using TLS Certificates.
ConfigOptionData
func ConfigOptionData(optionName string) string
ConfigOptionData
returns the base64 decoded value of a file
config option.
'{{repl ConfigOptionData "ssl_key"}}'
To use files in a ConfigMap, use ConfigOptionData
:
apiVersion: v1
kind: ConfigMap
metadata:
name: tls-config
data:
tls.crt: |
repl{{- ConfigOptionData "tls_certificate_file" | nindent 4 }}
tls.key: |
repl{{- ConfigOptionData "tls_private_key_file" | nindent 4 }}
ConfigOptionFilename
func ConfigOptionFilename(optionName string) string
ConfigOptionFilename
returns the filename associated with a file
config option.
It will return an empty string if used erroneously with other types.
'{{repl ConfigOptionFilename "pom_file"}}'
As an example, if you have the following Config Spec defined:
apiVersion: kots.io/v1beta1
kind: Config
metadata:
name: my-application
spec:
groups:
- name: java_settings
title: Java Settings
description: Configures the Java Server build parameters
items:
- name: pom_file
type: file
required: true
You can use ConfigOptionFilename
in a Pod Spec to mount a file like so:
apiVersion: v1
kind: Pod
metadata:
name: configmap-demo-pod
spec:
containers:
- name: some-java-app
image: busybox
command: ["bash"]
args:
- "-C"
- "cat /config/{{repl ConfigOptionFilename pom_file}}"
volumeMounts:
- name: config
mountPath: "/config"
readOnly: true
volumes:
- name: config
configMap:
name: demo-configmap
items:
- key: data_key_one
path: repl{{ ConfigOptionFilename pom_file }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: demo-configmap
data:
data_key_one: repl{{ ConfigOptionData pom_file }}