How to Add Config map in Azure DevOps for AKS

9/24/2020

I am trying out few things in AKS. right now I am trying to release to AKS through Azure DevOps. But I am unable to achieve the creation of config map through pipeline. right now, when I run the pipeline all it does is it creates the pods/service mentioned in the deployment.yaml file but unable to create the config map file, but shows the deployment successful.I am using Volume Mounts for the configuration for the application. right now my release file looks like this.

steps:
- task: Kubernetes@0
  displayName: 'kubectl apply'
  inputs:
    kubernetesServiceConnection: 'AKS-Test'
    namespace: testns
    command: apply
    useConfigurationFile: true
    configuration: '$(System.DefaultWorkingDirectory)/DeploymentManifest/deployment.yaml'
    useConfigMapFile: true
    configMapFile: '$(System.DefaultWorkingDirectory)/DeploymentManifest/configmap.yaml'

Manually I used to do like this to test the application. two step process. I don't think I need to add another task just for apply configmap. can someone point me in the right direction.

kubectl apply -f configmap.yaml
kubectl apply -f deployment.yaml

here is the content of configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: demo-config
data:
  appsettings.json: |-
    {
      "Logging": {
        "LogLevel": {
          "Default": "Error",
          "System": "Error",
          "Microsoft": "Error"
        }
      },
      "Testing":"ReleaseEnv"
    }

Update: For now I have added a new task to apply the configmap and its working not sure this is the right way.

-- threeleggedrabbit
azure-aks
azure-devops
configmap
kubernetes
release

0 Answers