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.

Variable for kubernetesServiceEndpoint in Kubectl task can handle only Global Variables

See original GitHub issue

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: Kubectl task

list here (V# not needed):
https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks

Environment

  • Server - Azure Pipelines
  • Agent - Private:

Issue Description

Variable for kubernetesServiceEndpoint in Kubectl task can handle only Global Variables and Stage Variable are not recognized

When using kubectl task and login command the kubernetesServiceEndpoint accepts only the Global Variable When setting the variable inside stage the kubectl task login complains it can’t find the resource. Service endpoint is private and security is set to all pipelines

image when echoing the variable is reflected KubeTest image

this is how variable is set.

  displayName: Deploy to Test
  variables:
  - name: k8sNamespace
    value: wso2is
  - name: k8sReleaseName
    value: test
  - name: k8sService
    value: KubeTest
  - group: test-wso2is
  jobs:

this is how is used:

- task: Kubernetes@1
  displayName: Login to Kubernetes
  inputs:
    connectionType: Kubernetes Service Connection
    kubernetesServiceEndpoint: $(k8sService)
    command: login

Task logs

N/A

Troubleshooting

When setting the variable in the global variables, deployment stage accept it and can work with variable. When hardcoding the Kubernetes endpoint also everything works fine.

Error logs

Error message appears even before any stage starts.

There was a resource authorization issue: "The pipeline is not valid. Job DeployTest: Step input kubernetesServiceEndpoint references service connection $(k8sService) 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 3 years ago
  • Reactions:4
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
harlandgomezcommented, Jun 19, 2022

I saw this somewhere which works for me: {{ variables.k8sService }} instead of $(k8sService)

1reaction
iasha102commented, Jul 14, 2020

I had more days to test everything. And come to this: If I declare the variable in the global section and then redeclare it in the staging section, then everything works fine. And this does not happen with other variables.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Define Dependent Environment Variables - Kubernetes
This page shows how to define dependent environment variables for a container in a Kubernetes Pod. Before you begin You need to have...
Read more >
Kubernetes service environment variables - Microsoft Learn
The default environment variables created by Kubernetes are described in the Kubernetes documentation. For information about the supported ...
Read more >
Kubernetes global variables (for all namespaces)
MongoDB endpoint. For any reason, when i change/migrate any global variable, i want to change one time for all running applications in cluster...
Read more >
How To Handle Environment Variables With Kubernetes?
Using a configMap ... Another method for defining environment variables is using configMaps. You can use configMaps for more than environment ...
Read more >
Configure charts using globals - GitLab Docs
The chart will template the hostname of the service (and current . ... The current Redis Sentinel support only supports Sentinels that have...
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