<p>As part of the build pipeline I wanted to create a ConfigMap with the content of a file which is part of the Git repository from which the pipeline runs.</p>

<p>According to the Kubectl task für Azure Pipelines, this should be possible. But I have no idea how to apply it. It doesn't matter how my YAML is look like for this task, the result is always 'success'. Even I enter <code>foo</code> / <code>bar</code> as input parameters.
<a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/kubernetes?view=azure-devops" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/kubernetes?view=azure-devops</a></p>

<p>I asked Microsoft whether there could be a lack in the documentation or in the implementation itself. The only answer I get was ask here. They really move the responsibility for support to the community.</p>

<p>This is my definition:</p>

<pre><code>- task: Kubernetes@1
  displayName: 'Create ConfigMap for /data'
  inputs:
    kubernetesServiceEndpoint: 'cluster-test'
    namespace: 'app-test'
    forceUpdateConfigMap: true
    configMapName: data
    configMapArguments: --from-file $(Build.SourcesDirectory)/data/ExcelTemplate.xlsx
</code></pre>

<p>With this I expect, according to the documentation, that with every run the ConfigMap will be deleted and recrated with the content of the given Excel file (and ExcelTemaplte.xlsx as the key).
Manuelly I can do this with:<br>
<code>kubectl create configmap data --from-file ExcelTemplate.xlsx</code></p>

<p>The linked documentation mention the usage like this (I d:</p>

<pre><code>    - task: Kubernetes@1
      displayName: configMap with literal values
      inputs:
        azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
        azureResourceGroup: $(azureResourceGroup)
        kubernetesCluster: $(kubernetesCluster)
        command: apply
        arguments: -f mhc-aks.yaml
        secretType: generic
        secretArguments: --from-literal=contoso=$(contosovalue)
        secretName: mysecretkey4
        configMapName: myconfig
        forceUpdateConfigMap: true
        configMapArguments: --from-literal=myname=contoso
</code></pre>

<ul>
<li>The first part is clear, the example uses a Azure cluster, but there can be used any kind of.</li>
<li>Why do they use <code>apply</code> with a <code>.yaml</code> file? What should be inside?</li>
<li>Why do they deal with secrets, just a combined example? It's not mentioned</li>
<li><code>configMapArguments</code> is mentioned in the docs (a guess newly added, was not before)</li>
</ul>

<p>But I can give for every of the ConfigMap parameters a random value and the task is even then successful. Or in return, I can configure correct values and the result is successful without doing anything.</p>

<pre><code>- task: Kubernetes@1
  displayName: 'Create ConfigMap for /data'
  inputs:
    kubernetesServiceEndpoint: 'cluster-test'
    namespace: foobar # does not exist
    forceUpdateConfigMap: true
    configMapName: data
    configMapArguments: 'today is sunny'
</code></pre>

<p>Does someone already use this task for creating a ConfigMap? Or was successful in trying out this task?</p>

<p>For know I have to ran this task twice once with delete and once with a dedicated manifest for ConfigMap creation with the <code>apply</code> command. Or as a second solution just firing the <code>kubectl</code> commands for deletion/creation in bash script.</p>

dannyyy
<p>It seems, that something has been fixed since last Friday. Now the following definition is working as expected:</p>

<pre><code>- task: Kubernetes@1
  displayName: 'Create ConfigMap for /data'
  inputs:
    kubernetesServiceEndpoint: 'cluster-test'
    namespace: 'app-test'
    forceUpdateConfigMap: true
    configMapName: data
    configMapArguments: --from-file $(Build.SourcesDirectory)/data/ExcelTemplate.xlsx
</code></pre>
