Inside our CD pipeline, I first want to bake a manifest file through Kustomize(more about Kustomize in a later blog post) and then use the baked manifest to deploy to our AKS cluster.
Both actions are possible through the Kubernetes Manifest task, but I didn’t find immediatelly how I could pass the location of the baked manifest bundle from the bake task to the deployment task.
Here is the original yaml file I created:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
steps: | |
- task: KubernetesManifest@0 | |
displayName: Bake manifests | |
inputs: | |
action: 'bake' | |
namespace: 'example-namespace' | |
containers: 'containername:latest' | |
renderType: 'kustomize' | |
kustomizationPath: '/dev' # Location of the kustomization file | |
- task: KubernetesManifest@0 | |
displayName: Deploy manifests | |
inputs: | |
kubernetesServiceConnection: '${{ parameters.aksServiceConnectionDev }}' | |
namespace: bridges-platform | |
manifests: ?????? |
The trick is to give the first task a specific name and point to the ‘manifestsBundle’ property through the task name.
Let’s update our yaml file to show this. In the example below I named the bake task ‘bake’ so I can use ‘$(bake.manifestBundle)’ in the second task:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
steps: | |
- task: KubernetesManifest@0 | |
displayName: Bake manifests | |
inputs: | |
action: 'bake' | |
name: bake | |
namespace: 'example-namespace' | |
containers: 'containername:latest' | |
renderType: 'kustomize' | |
kustomizationPath: '/dev' # Location of the kustomization file | |
- task: KubernetesManifest@0 | |
displayName: Deploy manifests | |
inputs: | |
kubernetesServiceConnection: '${{ parameters.aksServiceConnectionDev }}' | |
namespace: bridges-platform | |
manifests: $(bake.manifestsBundle) |