Template Functions for Embedded Cluster (Beta)
This topic lists the Replicated template functions for Embedded Cluster. For more imformation about how to use Replicated template functions, including a list of all available template functions, see About Template Functions.
HelmValue
func HelmValue(path string) string
Returns the value from the chart's values.yaml at the given dotted path. Use this to read the chart's default image values and pass them to the ReplicatedImageName, ReplicatedImageRegistry, or ReplicatedImageRegistry template functions.
Examples
Return a top-level value
# HelmChart custom resource
values:
initImage: '{{repl ReplicatedImageName (HelmValue ".initImage") true }}'
Return a value from a subchart
# HelmChart custom resource
values:
my-subchart:
image:
registry: '{{repl ReplicatedImageRegistry (HelmValue ".my-subchart.image.registry") }}'
repository: '{{repl ReplicatedImageRepository (HelmValue ".my-subchart.image.repository") true }}'
ReplicatedImageName
func ReplicatedImageName(image string, noProxy ...bool) string
Returns a full image reference, including the registry, repository, and any tags.
Use this when a chart expects the entire image reference in a single field.
Parameters
image
The image reference to rewrite.
Use the HelmValue function to return the value from the chart's values.yaml at the given dotted path.
noProxy
The following table describes the value returned by ReplicatedImageName in online or air gap installations, when the noProxy field is omitted or set to true:
| Install type | noProxy | Result |
|---|---|---|
| Online | Omitted | Returns the proxy registry URL for the image in the format: proxy.replicated.com/proxy/<app-slug>/<image>, where app-slug is the unique application slug |
| Online | true | Returns the image reference with no changes |
| Air gap | true or omitted | Returns the location of the image at the local image registry in the format: <local-registry>/<app-slug>/<name>:<tag> |
Examples
Public image (noProxy)
# HelmChart custom resource
values:
publicImage: '{{repl ReplicatedImageName (HelmValue ".publicImage") true }}'
Private image
# HelmChart custom resource
apiVersion: kots.io/v1beta2
kind: HelmChart
spec:
values:
initImage: '{{repl ReplicatedImageName (HelmValue ".initImage") }}'
ReplicatedImageRegistry
func ReplicatedImageRegistry(registry string, noProxy ...bool) string
Returns the registry host.
Use this with the ReplicatedImageRepository template function when the image reference in the Helm chart uses separate registry and repository fields.
Parameters
image
The image reference to rewrite.
Use the HelmValue function to return the value from the chart's values.yaml at the given dotted path.
noProxy
The following table describes the value returned by ReplicatedImageName in online or air gap installations when the noProxy field is omitted or set to true:
| Install type | noProxy | Result |
|---|---|---|
| Online | Omitted | Returns the proxy registry domain (either proxy.replicated.com or your custom domain) |
| Online | true | Returns the image registry value with no changes |
| Air gap | true or omitted | Returns the local registry address |
Examples
Rewrite image references using HelmValues
# HelmChart custom resource
apiVersion: kots.io/v1beta2
kind: HelmChart
spec:
values:
image:
registry: '{{repl ReplicatedImageRegistry (HelmValue ".image.registry") }}'
repository: '{{repl ReplicatedImageRepository (HelmValue ".image.repository") true }}'
Rewrite upstream image references for third-party Helm extensions
# Embedded Cluster Config
extensions:
helmCharts:
- chart:
name: ingress-nginx
chartVersion: "4.11.3"
releaseName: ingress-nginx
namespace: ingress-nginx
values: |
controller:
image:
registry: 'repl{{ ReplicatedImageRegistry "registry.k8s.io" }}'
repository: 'repl{{ ReplicatedImageRepository "registry.k8s.io/ingress-nginx/controller" }}'
ReplicatedImageRepository
func ReplicatedImageRepository(repository string, noProxy ...bool) string
Returns the repository path.
Use this with the ReplicatedImageRegistry template function when the image reference in the Helm chart uses separate registry and repository fields.
Parameters
image
The image reference to rewrite.
Use the HelmValue function to return the value from the chart's values.yaml at the given dotted path.
noProxy
The following table describes the value returned by ReplicatedImageName in online or air gap installations, when the noProxy field is omitted or set to true:
| Install type | noProxy | Result |
|---|---|---|
| Online | Omitted | Returns the proxy registry image repository in the format: proxy/<app-slug>/<repository>, where app_slug is the unique application slug |
| Online | true | Returns the image repository value with no changes |
| Air gap | true or omitted | Returns the local image repository in the format: <app-slug>/<name> |
Examples
Rewrite image references using HelmValues
# HelmChart custom resource
apiVersion: kots.io/v1beta2
kind: HelmChart
spec:
values:
image:
registry: '{{repl ReplicatedImageRegistry (HelmValue ".image.registry") }}'
repository: '{{repl ReplicatedImageRepository (HelmValue ".image.repository") true }}'
Rewrite upstream image references for third-party Helm extensions
# Embedded Cluster Config
extensions:
helmCharts:
- chart:
name: ingress-nginx
chartVersion: "4.11.3"
releaseName: ingress-nginx
namespace: ingress-nginx
values: |
controller:
image:
registry: 'repl{{ ReplicatedImageRegistry "registry.k8s.io" }}'
repository: 'repl{{ ReplicatedImageRepository "registry.k8s.io/ingress-nginx/controller" }}'