Kustomize commands fail in DevOps pipeline since update of `ubuntu-latest` build agents (last week)

Rich Else 0 Reputation points
2023-02-15T16:45:52.0266667+00:00

The version of Kustomize (version 5) has changed on the latest version of the build agents released last week (https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml and https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md). We haven't been able to use our pipelines since. We have checked the release notes and breaking changes but can't spot the problem (not that we are Kustomize experts).

Either kustomize build commands run as part of a pipeline

parameters:
  - name: environmentOverlay
    displayName: Name of the environment overlay (e.g. sandbox, qa, uat, prod)
    type: string
  - name: kubernetesNamespace
    displayName: Name of the kubernetes namespace
    type: string
  - name: image
    displayName: The container image to use
    type: string

steps:
  - script: kustomize build $(Pipeline.Workspace)/Manifests/overlays/${{ parameters.environmentOverlay }} > $(Pipeline.Workspace)/baked.yaml
    displayName: Bake environment specific manifest

  - task: KubernetesManifest@0
    displayName: Deploy to Kubernetes cluster
    inputs:
      action: deploy
      namespace: ${{ parameters.kubernetesNamespace }}
      manifests: $(Pipeline.Workspace)/baked.yaml
      containers: ${{ parameters.image }}

Or those run as part of bash fail with the error

Error: invalid Kustomization: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go struct field Kustomization.patches of type types.Patch

Is anyone else encountering this problem and what's the secret?! We have tried numerous different patch syntax

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,109 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Alexey Prognimak 0 Reputation points
    2023-04-13T13:49:14.4633333+00:00

    Same problem manifested for me today. You might need to use the following task before calling kustomize script (which I would instead replace with KubernetesManifests@: bake action, cleaner this way imo)

              - task: KubectlInstaller@0
                displayName: Install kubectl
                inputs:
                  kubectlVersion: 1.26.3
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.