Jac*_*cob 6 jenkins kubernetes
我正在尝试为示例Kubernetes集群部署部署我的Kubernetes Helm图表。我创建了一个示例Helm图表,并添加了Docker映像参考,并使用terminal命令部署了Helm图表helm install <my-chartname>。而且微服务可以成功访问而没有任何问题。
之后,我创建了一个Jenkins管道作业,并仅添加了一个包含部署步骤的阶段。我按照以下方式添加
pipeline
{
agent any
stages
{
stage ('helmchartinstall')
{
steps
{
sh 'helm install spacestudychart'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我收到如下错误,
[Pipeline] { (helmchartinstall)
[Pipeline] sh
+ helm install spacestudychart
Error: the server could not find the requested resource (get pods)
Run Code Online (Sandbox Code Playgroud)
当我通过终端运行时,相同的命令正在工作。
更新资料
要将分er升级到最新版本,请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"}
Run Code Online (Sandbox Code Playgroud)
“ kubectl版本--short”的输出如下所示,
Client Version: v1.14.1
Server Version: v1.13.5
Run Code Online (Sandbox Code Playgroud)
当我运行命令“ kubectl --v = 5 get pods; helm install spacestudychart”时,我得到的控制台输出如下所示,
+ 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
Run Code Online (Sandbox Code Playgroud)
我需要升级kubectl版本吗?与Jenkins一起运行时,确切的问题是什么?
这是100%的工作,我之前有这个问题。
首先,构建jenkins用户,然后复制config到/home/jenkins/.kube/
cp $HOME/.kube/config /home/jenkins/.kube/
or
cp ~/.kube/config /home/jenkins/.kube/
Run Code Online (Sandbox Code Playgroud)
然后使用
chmod 777 /home/jenkins/.kube/config
Run Code Online (Sandbox Code Playgroud)
您的kubernetes命令需要您的kubernetes配置文件。这就像您的kubernetes集群的密钥或密码,因此您应该将kubernetes配置提供给您的jenkins,然后它可以运行kubernetes命令
这是一个很好的教程,可以帮助我解决它。
UPDATE1 您应该具有jenkins用户来添加jenkins用户,您应该将jenkins用户添加到ubuntu或centos或..
adduser jenkins
Run Code Online (Sandbox Code Playgroud)
更新2
,您应该安装kubectl在你的服务器,你使用它作为jenkins使kubectl命令可以工作,之后请复制的配置在~/.kube/config你的kubernetes集群您的jenkins服务器,以前安装kubectl就可以了。
| 归档时间: |
|
| 查看次数: |
3246 次 |
| 最近记录: |