question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KubernetesManifest task doesn't accept variable for kubernetesServiceConnection

See original GitHub issue

Question, Bug, or Feature?
Type: Bug

Enter Task Name: KubernetesManifest

Environment

Azure Pipelines

Issue Description

When trying to store the kubernetesServiceConnection in a variable, it doesn’t appear to resolve the variable and fails.

Task:

- task: KubernetesManifest@0
  displayName: Deploy
  inputs:
    kubernetesServiceConnection: $(KubernetesServiceConnection)
    namespace: default
    manifests: '$(Pipeline.Workspace)/service.yml'
    containers: '$(ContainerRegistry)/$(ImageName):$(Build.BuildNumber)'

This results in the error in the Error Logs section below, regardless of whether I try and include it from a variable group at the pipeline level ie this at the top of the file:

variables:

  • group: myVarGroup

or from a variable group inside the stage or job, or as a direct variable in either place, ie this:

variables:

  • name: KubernetesServiceConnection value: MyServiceConnectionName

If I replace the variable with the actual name, using: kubernetesServiceConnection: MyServiceConnectionName

it works as expected. Is this expected to work with variables, and if so is there anything obvious I’m doing wrong?

Task logs

Task doesn’t start so no logs

Error logs

There was a resource authorization issue: "The pipeline is not valid. Job Job1: Step input kubernetesServiceConnection references service connection $(KubernetesServiceConnection) which could not be found. The service connection does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
CrazyTunacommented, Oct 21, 2019

@clpalmer can you try ${{ variables.kubernetesServiceConnection }}. It is working for me. Also all my variables are defined in yaml variable files.

1reaction
sergiopratescommented, Sep 19, 2022

2022 and worked with this work around.

` jobs: - deployment: release_api displayName: Deploy API Development pool: vmImage: ‘ubuntu-latest’ environment: Development variables: - group: Group - Development # Defined variable Kubernetes.ServiceEndpointName

    strategy:
      runOnce:
        deploy:
          steps:
            - download: none
           
            - task: HelmDeploy@0
              displayName: Login in K8s
              inputs:
                connectionType: Kubernetes Service Connection
                kubernetesServiceConnection: ${{ variables.Kubernetes.ServiceEndpointName }}
                command: login`
Read more comments on GitHub >

github_iconTop Results From Across the Web

Utilize variable to populate kubernetesServiceConnection ...
I am using the KubernetesManifest@0 task to create and populate k8s secret in a k8s namespace. I have 100's of namespaces to represent...
Read more >
KubernetesManifest@0 - Deploy to Kubernetes v0 task
Use a Kubernetes manifest task in a build or release pipeline to bake and deploy manifests to Kubernetes clusters using Helm charts. Syntax....
Read more >
Timeout in task control options does not accept variable input ...
It seems only numeric values are acceptable. We expect control options can either honor the variable input, or explicitly prompt error message on...
Read more >
Deploying to Kubernetes with Azure DevOps Pipelines
Screenshot showing Kubernetes service connection option ... Take a look at that! Azure DevOps created ... Screenshot of generate Kubernetes manifest task.
Read more >
Azure DevOps multi-stage YAML pipelines - baeke.info
ArtifactsDirectory)/manifests' - task: KubernetesManifest@0 inputs: action: 'deploy' kubernetesServiceConnection: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found