<p>I am new to using kubernetes and helm, though I have developed a few helms already. In one of the requirement, I am creating a helm of helms. Basically, the installable helm has some dependent helms. And, to install this, I have the install script something of the below form:</p>
<pre><code>${HELM_BIN} install final_helm helms/final-helm \
    --set old-service.fullnameOverride=old-service \
    --set old-service.image.registry=${DOCKER_REGISTRY} \
    --set old-service.ingress.enabled=true \
    --set old-service.ingress.hosts[0].host=${LOAD_BALANCER} \
    --set old-service.ingress.hosts[0].paths[0]=&quot;/old-service-api-${NAMESPACE}(/|$)(.*)&quot; \
    --set old-service.ingress.tls[0].hosts[0]=${LOAD_BALANCER} \
    --set old-service.ingress.tls[0].secretName=ssl-certificate \
    --set old-service.jvm.options=&quot;-Xmx${OLD_HEAPSIZEMB}M -Xms${OLD_HEAPSIZEMB}M&quot; \
    --set old-service.metrics.serviceMonitor.enabled=true \
    --set old-service.metrics.serviceMonitor.namespace=${NAMESPACE} \
    --set old-service.replicaCount=${OLD_REPLICAS} \
    --set old-service.resources.requests.cpu=100m \
    --set old-service.resources.requests.memory=${OLD_HEAPSIZEMB}Mi \
    --set new-service.fullnameOverride=new-service \
    --set new-service.image.registry=${DOCKER_REGISTRY} \
    --set new-service.ingress.enabled=true \
    --set new-service.ingress.hosts[0].host=${LOAD_BALANCER} \
    --set new-service.ingress.hosts[0].paths[0]=&quot;/new-service-api-${NAMESPACE}(/|$)(.*)&quot; \
    --set new-service.ingress.tls[0].hosts[0]=${LOAD_BALANCER} \
    --set new-service.ingress.tls[0].secretName=ssl-certificate \
    --set new-service.jvm.options=&quot;-Xmx${NEW_HEAPSIZEMB}M -Xms${NEW_HEAPSIZEMB}M&quot; \
    --set new-service.metrics.serviceMonitor.enabled=true \
    --set new-service.metrics.serviceMonitor.namespace=${NAMESPACE} \
    --set new-service.replicaCount=${OLD_REPLICAS} \
    --set new-service.resources.requests.cpu=100m \
    --set new-service.resources.requests.memory=${NEW_HEAPSIZEMB}Mi \
    --namespace ${NAMESPACE} \
    --version ${FINAL_HELM_VERSION}
</code></pre>
<p>I had a version of a Spring Boot service(old-service) which has been optimized by removing some adapter design pattern to new-service. However, considering the stage the project is in, integration tests could not be performed with the new-service supposed to replace the old-service.</p>
<p>So, I need to spin up one of the service only out of new-service and old-service based on some environment property set via env.sh script in which I have all the environment variables present.</p>
<p><strong>env.sh</strong></p>
<pre><code>export USE_NEW_SERVICE=true
</code></pre>
<p><strong>Chart.yaml for helms/final-helm</strong></p>
<pre><code>dependencies:
- name: old-service
  repository: &quot;file://../old-service&quot;
- name: new-service
  repository: &quot;file://../new-service&quot;
</code></pre>
<p>I do not know how I can use the environment property USE_NEW_SERVICE so that if it is true, I spin up new-service leaving behind old-service and if it is false, I spin up old-service leaving behind new-service. Simply, using if else in install script will not help as well as final-helm is dependent on new-service and old-service both and they will come up with default values specified if not from values obtained from install script.</p>
<p>Any help is appreciated. Thanks.</p>

KnockingHeads
<p>There is another link at SOF here:</p>
<p><a href="https://stackoverflow.com/questions/54032974/helm-conditionally-install-subchart">Helm conditionally install subchart</a></p>
<p>However, it uses <strong>condition</strong> with a subchart. The value of <strong>condition</strong> for any subchart can be set by any shell script to be true or false. Then, the subchart wont be included as a subchart of the main chart.</p>
<p><strong>But, my requirement was about spinning up the new_service or old_service based on some condition, but to have it as a subchart of the main chart.</strong></p>
<p>So, I simply set the new_service.replicaCount or old_service.replicaCount to 1 based on which condition is true. This way, both my charts are included as subcharts but only one would spin up based on the condition I set in my shell script.</p>
