<p>I'm using the <code>stable/prometheus</code> helm chart and I've configured a custom values file that further configures alertmanager for the chart deployment. I can install the chart via Helm3 without any issues, however, there's one thing I'm not able to figure out. For the <code>Slack Reciever/slack_configs/api_url</code> I want to pass that through the <code>set</code> command so I don't have to keep it hardcoded into file. </p>

<p>I hope I'm on the right path, and here's what I'm thinking of running to access the value.</p>

<pre><code>helm install test-release stable/prometheus -f customALM.yml --set alertmanagerFiles.alertmanager.yml.receivers[0].api_url=https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/xxxxxxxxxxxxxxxxxxxxxxxxxxx
</code></pre>

<p><strong><code>customALM.yml</code></strong></p>

<pre><code>alertmanagerFiles:
  alertmanager.yml:
        route:
          group_wait: 10s
          group_interval: 5m
          repeat_interval: 30m
          receiver: "slack"

          routes:
            - receiver: "slack"
              group_wait: 10s
              match_re:
                severity: error|warning
              continue: true

        receivers:
          - name: "slack"
            slack_configs:
              - api_url: '[howDoIsetThisAtTheCLI?'
                channel: 'someChannel'
                text: "Text message template etc."
</code></pre>

<p><strong>Update 4/8:</strong> I'm making progress thanks to willro! I'm able to get a value inserted but it puts it at the root of the alertmanager block. I've tried a few different combinations to access receivers/slack_configs but no luck yet =/</p>

<pre><code>helm install test-release stable/prometheus -f customALM.yml --set alertmanagerFiles.api_url=PleaseInsertPrettyPlease --dry-run
</code></pre>

<p><strong>Update 4/9:</strong> I've decided to move the receivers block into a separate file that's encrypted and stored securely. </p>

<blockquote>
  <p>Running the command to change the URL after its been deployed is definitely an option that I want to have.</p>
</blockquote>

<p>I'd like to write this answer to give you this option!</p>

<ul>
<li><p>You can chain a few commands with <a href="https://www.grymoire.com/Unix/Sed.html" rel="nofollow noreferrer">SED</a> to edit data on that ConfigMap (it's very similar to what <code>kubectl edit</code> does!)</p></li>
<li><p>For that you will need to use the string deployed on the <code>customALM.yml</code>. For this example I set the parameter as <code>api_url: ChangeMeLater</code> before deploying.</p></li>
<li><p>Then I deployed the chart with <code>helm install test-release stable/prometheus -f customALM.yml</code></p></li>
<li><p>Lastly we run: </p></li>
</ul>

<pre><code>kubectl get cm &lt;CONFIG_MAP_NAME&gt; -o yaml | sed -e "s,&lt;OLD_VALUE&gt;,&lt;NEW_VALUE&gt;,g" | kubectl replace -f -
</code></pre>

<ul>
<li><p>Explaining what's going on:</p>

<ul>
<li><code>kubectl get cm &lt;CONFIG_MAP_NAME&gt; -o yaml |</code> = gets the deployed configmap in yaml format and pipe it to the next command</li>
<li><code>sed -e "s,&lt;OLD_VALUE&gt;,&lt;NEW_VALUE&gt;,g" |</code> = use <code>sed</code> to replace  <code>old_value</code> for <code>new_value</code> and pipe it to the next comand</li>
<li><code>kubectl replace -f -</code> = use the output from the last command and replace the object currently deployed with the same name.</li>
</ul></li>
<li><p>I'll leave an example here step by step to elucidate more:</p></li>
</ul>

<pre><code>$ helm install test-release stable/prometheus -f customALM.yml
Release "test-release" has been installed. Happy Helming!
...

$ kubectl get cm
NAME                                   DATA   AGE
test-release-prometheus-alertmanager   1      44m
test-release-prometheus-server         5      44m

$ kubectl get cm test-release-prometheus-alertmanager -o yaml
apiVersion: v1
data:
  alertmanager.yml: |
    global: {}
    receivers:
    - name: slack
      slack_configs:
      - api_url: ChangeMeLater
        channel: someChannel
        text: Text message template etc.
    route:
      group_interval: 5m
      group_wait: 10s
      receiver: slack
      repeat_interval: 30m
      routes:
      - continue: true
        group_wait: 10s
        match_re:
          severity: error|warning
        receiver: slack
kind: ConfigMap
metadata:
  creationTimestamp: "2020-04-10T13:41:15Z"
  labels:
    app: prometheus
    chart: prometheus-11.0.6
    component: alertmanager
    heritage: Helm
    release: test-release
  name: test-release-prometheus-alertmanager
  namespace: default
  resourceVersion: "218148"
  selfLink: /api/v1/namespaces/default/configmaps/test-release-prometheus-alertmanager
  uid: 323fdd40-2f29-4cde-833c-c6300d5688c0

$ kubectl get cm test-release-prometheus-alertmanager -o yaml | sed -e "s,ChangeMeLater,theurl.com/any,g" | kubectl replace -f -
configmap/test-release-prometheus-alertmanager replaced

$ kubectl get cm test-release-prometheus-alertmanager -o yaml
apiVersion: v1
data:
  alertmanager.yml: |
    global: {}
    receivers:
    - name: slack
      slack_configs:
      - api_url: theurl.com/any
        channel: someChannel
        text: Text message template etc.
    route:
      group_interval: 5m
      group_wait: 10s
      receiver: slack
      repeat_interval: 30m
      routes:
      - continue: true
        group_wait: 10s
        match_re:
          severity: error|warning
        receiver: slack
kind: ConfigMap
metadata:
  creationTimestamp: "2020-04-10T13:41:15Z"
  labels:
    app: prometheus
    chart: prometheus-11.0.6
    component: alertmanager
    heritage: Helm
    release: test-release
  name: test-release-prometheus-alertmanager
  namespace: default
  resourceVersion: "219507"
  selfLink: /api/v1/namespaces/default/configmaps/test-release-prometheus-alertmanager
  uid: 323fdd40-2f29-4cde-833c-c6300d5688c0
</code></pre>

<p>You can see that the command changed the <code>ChangeMeLater</code> for <code>theurl.com/any</code>.</p>

<p>I'm still thinking about your first option, but this is a good workaround to have in hand.</p>

<p>If you have any doubt let me know!</p>
