用詹金斯设置kubectl

时间:2018-11-20 10:13:41

标签: jenkins kubernetes aws-eks

有人知道如何使用jenkins设置kubectl吗? Jenkins在可与AWS EKS群集进行通信的AWS EC2上运行。

当我在jenkins中以kubectl版本运行shell脚本时,我得到:

+ kubectl version

输出:

Client Version: version.Info{Major:"1", Minor:"10",    GitVersion:"v1.10.3",     GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0",     GitTreeState:"clean", BuildDate:"2018-07-26T20:40:11Z",     GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Error from server (Forbidden): <html><head><meta http-equiv='refresh' content='1;url=/login?from=%2Fversion'/>    <script>window.location.replace('/login?from=%2Fversion');</script></head>    <body style='background-color:white; color:white;'>


Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:

Permission you need to have (but didn't): hudson.model.Hudson.Read
 ... which is implied by: hudson.security.Permission.GenericRead
 ... which is implied by: hudson.model.Hudson.Administer
-->

</body></html>
Build step 'Execute shell' marked build as failure

3 个答案:

答案 0 :(得分:2)

以适当方式配置它的一种方法是使用Jenkins Kubernetes pluginhttps://illya-chekrygin.com/2017/08/26/configuring-certificates-for-jenkins-kubernetes-plugin-0-12/

另一种方法是将集群kubeconfig文件传递给kubectl。

答案 1 :(得分:1)

有多种方法可以做到这一点。检查 AWS 发布的以下链接。根据链接。关于EKS,您可以使用 Jenkins X 。它仅适用于K8。

https://aws.amazon.com/blogs/opensource/continuous-delivery-eks-jenkins-x/

答案 2 :(得分:0)

从aws eks导出命令中删除〜/,然后可以轻松地为aws eks设置kubectl。