我的场景:
我让 Jenkins 在http://localhost:8080运行,kubectl,minikube 启动并运行
$ minikube status
host: Running
kubelet: Running
apiserver: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100
我想设置一个简单的 Jenkins 管道,以便自动应用 kubernetes 配置文件。这是我的管道的片段:
stage('deploy'){
sh '''
kubectl apply -f .'''
}
出现此错误:
+ kubectl apply -f .
unable to recognize "myApp_deployment.yaml": no matches for kind "Deployment" in version "apps/v1"
unable to recognize "myApp_service.yaml": no matches for kind "Service" in version "v1"
我尝试更改apps/v1为,apps/v1beta1但仍然没有运气。
当我尝试检查 kubectl 版本(也在 jenkins 管道中)时,输出如下:
+ kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.0", GitCommit:"e8462b5b5dc2584fdcd18e6bcfe9f1e4d970a529", GitTreeState:"clean", BuildDate:"2019-06-19T16:40:16Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
Error from server (Forbidden): <html><head><meta http-equiv='refresh' content='1;url=/login?from=%2Fversion%3Ftimeout%3D32s'/><script>window.location.replace('/login?from=%2Fversion%3Ftimeout%3D32s');</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
-->
我可以毫无问题地手动运行这些命令(打开终端,在项目目录中运行)。
我该如何解决这个问题?