首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:不存在名称为“默认”的上下文

错误:不存在名称为“默认”的上下文
EN

Stack Overflow用户
提问于 2022-07-29 05:26:37
回答 1查看 540关注 0票数 0

跟踪误差

代码语言:javascript
复制
Starting: Bash
==============================================================================
Task         : Bash
Description  : Run a Bash script on macOS, Linux, or Windows
Version      : 3.201.1
Author       : Microsoft Corporation
Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/bash
==============================================================================
Generating script.
Formatted command: exec bash '/home/vsts/work/1/s/Orchestration/dev/deploy.sh'
========================== Starting Command Output ===========================
/bin/bash /home/vsts/work/_temp/bdf3cbe7-1e0a-4e19-a974-71118a3adb33.sh
error: no context exists with the name: "default"
The connection to the server localhost:8080 was refused - did you specify the right host or port?
The connection to the server localhost:8080 was refused - did you specify the right host or port?
The connection to the server localhost:8080 was refused - did you specify the right host or port?
The connection to the server localhost:8080 was refused - did you specify the right host or port?
##[error]Bash exited with code '1'.
Finishing: Bash

当我从azure管道运行任务时

代码语言:javascript
复制
- task: Bash@3
    inputs:
      filePath: '$(Build.SourcesDirectory)/Orchestration/dev/deploy.sh'

这些是deploy.sh的内容

代码语言:javascript
复制
kubectl config use-context default
kubectl apply -f Orchestration/dev/configmap.yaml
kubectl apply -f Orchestration/dev/secrets.yaml
kubectl apply -f Orchestration/dev/deployment.yaml
kubectl apply -f Orchestration/dev/service.yaml

我不知道为什么会出现错误,每个azure aks集群都会有一个默认的命名空间,而且我已经有了一个默认的命名空间。

EN

回答 1

Stack Overflow用户

发布于 2022-07-29 09:21:09

Agreed with @Thomas,是您在kubectl config use-context default中传递的名称。这是名称空间的类型,而不是我们需要提供集群名称的类型。

例如,要设置当前上下文:-

代码语言:javascript
复制
$ kubectl config use-context Context_name

同样基于这个,

kubeconfig

文件中的上下文元素用于以方便的名称对访问参数进行分组。每个上下文都有三个参数:集群、命名空间和用户。默认情况下,kubectl 命令行工具使用当前上下文中的参数与群集通信。

有关更多信息,请参阅此Kubernets

和这个类似的所以线程=

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73161993

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档