You can use the subcharts map.
{{ $sub := index .Subcharts "cp-kafka" }}
This will give you all built in variables and even the .Values
from the values file.
For example, I create a chart and a subchart:
helm create foo
helm create foo/charts/bar
rm -rf foo/templates/*
rm -rf foo/charts/bar/templates/*
In bar values I put this:
some:
values: from
this: subchart
In foo templates I put this configmap:
kind: ConfigMap
apiVersion: v1
metadata:
name: example
data:
bar-chart: |
{{- .Subcharts.bar | toYaml | nindent 4 }}
Now when I render the chart with helm template foo
I get the below output:
---
# Source: foo/templates/cm.yaml
kind: ConfigMap
apiVersion: v1
metadata:
name: example
data:
bar-chart: |
Capabilities:
APIVersions:
- v1
- admissionregistration.k8s.io/v1
- admissionregistration.k8s.io/v1beta1
- internal.apiserver.k8s.io/v1alpha1
- apps/v1
- apps/v1beta1
- apps/v1beta2
- authentication.k8s.io/v1
- authentication.k8s.io/v1beta1
- authorization.k8s.io/v1
- authorization.k8s.io/v1beta1
- autoscaling/v1
- autoscaling/v2
- autoscaling/v2beta1
- autoscaling/v2beta2
- batch/v1
- batch/v1beta1
- certificates.k8s.io/v1
- certificates.k8s.io/v1beta1
- coordination.k8s.io/v1beta1
- coordination.k8s.io/v1
- discovery.k8s.io/v1
- discovery.k8s.io/v1beta1
- events.k8s.io/v1
- events.k8s.io/v1beta1
- extensions/v1beta1
- flowcontrol.apiserver.k8s.io/v1alpha1
- flowcontrol.apiserver.k8s.io/v1beta1
- flowcontrol.apiserver.k8s.io/v1beta2
- networking.k8s.io/v1
- networking.k8s.io/v1beta1
- node.k8s.io/v1
- node.k8s.io/v1alpha1
- node.k8s.io/v1beta1
- policy/v1
- policy/v1beta1
- rbac.authorization.k8s.io/v1
- rbac.authorization.k8s.io/v1beta1
- rbac.authorization.k8s.io/v1alpha1
- scheduling.k8s.io/v1alpha1
- scheduling.k8s.io/v1beta1
- scheduling.k8s.io/v1
- storage.k8s.io/v1beta1
- storage.k8s.io/v1
- storage.k8s.io/v1alpha1
- apiextensions.k8s.io/v1beta1
- apiextensions.k8s.io/v1
HelmVersion:
git_commit: 6e3701edea09e5d55a8ca2aae03a68917630e91b
git_tree_state: clean
go_version: go1.17.5
version: v3.8.2
KubeVersion:
Major: "1"
Minor: "23"
Version: v1.23.0
Chart:
IsRoot: false
apiVersion: v2
appVersion: 1.16.0
description: A Helm chart for Kubernetes
name: bar
type: application
version: 0.1.0
Files:
.helmignore: IyBQYXR0ZXJucyB0byBpZ25vcmUgd2hlbiBidWlsZGluZyBwYWNrYWdlcy4KIyBUaGlzIHN1cHBvcnRzIHNoZWxsIGdsb2IgbWF0Y2hpbmcsIHJlbGF0aXZlIHBhdGggbWF0Y2hpbmcsIGFuZAojIG5lZ2F0aW9uIChwcmVmaXhlZCB3aXRoICEpLiBPbmx5IG9uZSBwYXR0ZXJuIHBlciBsaW5lLgouRFNfU3RvcmUKIyBDb21tb24gVkNTIGRpcnMKLmdpdC8KLmdpdGlnbm9yZQouYnpyLwouYnpyaWdub3JlCi5oZy8KLmhnaWdub3JlCi5zdm4vCiMgQ29tbW9uIGJhY2t1cCBmaWxlcwoqLnN3cAoqLmJhawoqLnRtcAoqLm9yaWcKKn4KIyBWYXJpb3VzIElERXMKLnByb2plY3QKLmlkZWEvCioudG1wcm9qCi52c2NvZGUvCg==
Release:
IsInstall: true
IsUpgrade: false
Name: release-name
Namespace: default
Revision: 1
Service: Helm
Subcharts: {}
Values:
global: {}
some:
this: subchart
values: from