gpt4 book ai didi

jenkins - 使用 Jenkins 部署 Helm 图表时出现 "server could not find the requested resource (get pods)"错误

转载 作者:行者123 更新时间:2023-12-04 13:36:09 25 4
gpt4 key购买 nike

我正在尝试为示例 Kubernetes 集群部署部署我的 Kubernetes Helm 图表。我创建了一个示例 Helm 图表并添加了 Docker 镜像引用并使用终端命令 helm install <my-chartname> 部署了 Helm 图表.并且微服务访问成功,没有任何问题。

之后,我创建了一个 Jenkins 管道作业并仅添加了一个包含部署步骤的阶段。我添加如下方式,

pipeline 
{
agent any
stages
{
stage ('helmchartinstall')
{
steps
{
sh 'helm install spacestudychart'
}
}
}
}

我收到如下错误,
[Pipeline] { (helmchartinstall)
[Pipeline] sh
+ helm install spacestudychart
Error: the server could not find the requested resource (get pods)

当我通过终端运行时,相同的命令正在工作。

更新

要将分蘖升级到最新版本,我运行 helm init --upgrade终端上的命令。但错误仍然存​​在。

“helm version”的输出如下,
Client: &version.Version{SemVer:"v2.14.0", GitCommit:"05811b84a3f93603dd6c2fcfe57944dfa7ab7fd0", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.14.0", GitCommit:"05811b84a3f93603dd6c2fcfe57944dfa7ab7fd0", GitTreeState:"clean"}

“kubectl version --short”的输出如下,
Client Version: v1.14.1
Server Version: v1.13.5

当我运行命令 "kubectl --v=5 get pods; helm install spacetudychart"时,我得到如下所示的控制台输出,
+ kubectl --v=5 get pods
I0604 07:44:46.035459 2620 cached_discovery.go:121] skipped caching discovery info due to yaml: line 10: mapping values are not allowed in this context
I0604 07:44:46.152770 2620 cached_discovery.go:121] skipped caching discovery info due to yaml: line 10: mapping values are not allowed in this context
I0604 07:44:46.152819 2620 shortcut.go:89] Error loading discovery information: yaml: line 10: mapping values are not allowed in this context
I0604 07:44:46.283598 2620 cached_discovery.go:121] skipped caching discovery info due to yaml: line 10: mapping values are not allowed in this context
I0604 07:44:46.374088 2620 cached_discovery.go:121] skipped caching discovery info due to yaml: line 10: mapping values are not allowed in this context
I0604 07:44:46.467938 2620 cached_discovery.go:121] skipped caching discovery info due to yaml: line 10: mapping values are not allowed in this context
F0604 07:44:46.468122 2620 helpers.go:114] error: yaml: line 10: mapping values are not allowed in this context
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 255
Finished: FAILURE

我需要升级 kubectl 版本吗?与 Jenkins 一起运行时的确切问题是什么?

最佳答案

这是 100% 工作我以前遇到过这个问题。

首先建立jenkins用户然后
复制 config/home/jenkins/.kube/

cp $HOME/.kube/config /home/jenkins/.kube/ 
or
cp ~/.kube/config /home/jenkins/.kube/

在那之后使用
 chmod 777 /home/jenkins/.kube/config 

你的 kubernetes 命令需要你的 kubernetes 配置文件。它就像您的 kubernetes 集群的 key 或密码,因此您应该将 kubernetes 配置提供给您的 jenkins,然后它可以运行 kubernetes 命令

这是一个很好的教程,可以帮助我解决它。

tutorial

更新 1
你应该有 jenkins 用户来添加 jenkins 用户你应该将 jenkins 用户添加到你的 ubuntu 或 centos 或 ..
adduser jenkins

这是 adduser 的好链接
Adding user

更新 2
您应该在您的服务器中安装 kubectl 并将其用作 jenkins以便 kubectl 命令可以工作,然后请复制 ~/.kube/config 中的配置在您的 kubernetes群集到您的 jenkins您之前安装的服务器 kubectl在上面。

关于jenkins - 使用 Jenkins 部署 Helm 图表时出现 "server could not find the requested resource (get pods)"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56404886/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com