一直想用kubesphere的devops,因为可视化界面很友好,操作简单。但事不如我愿,一直遇到各种坑,现在分享下我遇到的坑,我是用的官方的demo,链接:https://v2-1.docs.kubesphere.io/docs/zh-CN/quick-start/devops-online。
- 第一个坑,多节点部署的情况下 ,devops流水线明明创建成功了 ,但是devops列表页面没有显示,再次创建同名字的 devops流水线,提示已存在。如下图:

这个问题原因是 ks-controller-manager 组件和 ks-jenkins 组件 不在 一个节点上,并且他们有通信的问题,解决思路有3个:
方法1:在部署的时候 让这2个 组件放到一个节点上(我没试过)。
方法2:解决通信问题(我还不清楚怎么解决)。
方法3:单节点部署(我就玩个demo,所以用的这个方法)
具体解决过程可以看:https://kubesphere.com.cn/forum/d/1931-3-0-devops
2.第二个坑,具体错误:
Starting Kubernetes deployment
Loading configuration: /home/jenkins/agent/workspace/demo-devopsqh6lr_demo1_master/deploy/dev-ol/devops-sample-svc.yaml
ERROR: ERROR: java.lang.RuntimeException: io.kubernetes.client.openapi.ApiException: Forbidden
hudson.remoting.ProxyException: java.lang.RuntimeException: io.kubernetes.client.openapi.ApiException: Forbidden
at com.microsoft.jenkins.kubernetes.wrapper.ResourceManager.handleApiExceptionExceptNotFound(ResourceManager.java:180)
at com.microsoft.jenkins.kubernetes.wrapper.V1ResourceManager$ServiceUpdater.getCurrentResource(V1ResourceManager.java:391)
at com.microsoft.jenkins.kubernetes.wrapper.V1ResourceManager$ServiceUpdater.getCurrentResource(V1ResourceManager.java:379)
at com.microsoft.jenkins.kubernetes.wrapper.ResourceManager$ResourceUpdater.createOrApply(ResourceManager.java:93)
at com.microsoft.jenkins.kubernetes.wrapper.KubernetesClientWrapper.handleResource(KubernetesClientWrapper.java:289)
at com.microsoft.jenkins.kubernetes.wrapper.KubernetesClientWrapper.apply(KubernetesClientWrapper.java:256)
at com.microsoft.jenkins.kubernetes.command.DeploymentCommand$DeploymentTask.doCall(DeploymentCommand.java:172)
at com.microsoft.jenkins.kubernetes.command.DeploymentCommand$DeploymentTask.call(DeploymentCommand.java:124)
at com.microsoft.jenkins.kubernetes.command.DeploymentCommand$DeploymentTask.call(DeploymentCommand.java:106)
at hudson.remoting.UserRequest.perform(UserRequest.java:212)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:369)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:93)
at java.lang.Thread.run(Thread.java:748)
Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from 10.233.90.94/10.233.90.94:34394
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1743)
at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357)
at hudson.remoting.Channel.call(Channel.java:957)
at hudson.FilePath.act(FilePath.java:1160)
at com.microsoft.jenkins.kubernetes.command.DeploymentCommand.execute(DeploymentCommand.java:68)
at com.microsoft.jenkins.kubernetes.command.DeploymentCommand.execute(DeploymentCommand.java:45)
at com.microsoft.jenkins.azurecommons.command.CommandService.runCommand(CommandService.java:88)
at com.microsoft.jenkins.azurecommons.command.CommandService.execute(CommandService.java:96)
at com.microsoft.jenkins.azurecommons.command.CommandService.executeCommands(CommandService.java:75)
at com.microsoft.jenkins.azurecommons.command.BaseCommandContext.executeCommands(BaseCommandContext.java:77)
at com.microsoft.jenkins.kubernetes.KubernetesDeploy.perform(KubernetesDeploy.java:42)
at com.microsoft.jenkins.azurecommons.command.SimpleBuildStepExecution.run(SimpleBuildStepExecution.java:54)
at com.microsoft.jenkins.azurecommons.command.SimpleBuildStepExecution.run(SimpleBuildStepExecution.java:35)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
… 1 more
Caused by: hudson.remoting.ProxyException: io.kubernetes.client.openapi.ApiException: Forbidden
at io.kubernetes.client.openapi.ApiClient.handleResponse(ApiClient.java:979)
at io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:895)
at io.kubernetes.client.openapi.apis.CoreV1Api.readNamespacedServiceWithHttpInfo(CoreV1Api.java:26889)
at io.kubernetes.client.openapi.apis.CoreV1Api.readNamespacedService(CoreV1Api.java:26865)
at com.microsoft.jenkins.kubernetes.wrapper.V1ResourceManager$ServiceUpdater.getCurrentResource(V1ResourceManager.java:388)
… 16 more
Api call failed with code 403, detailed message: {
“kind”: “Status”,
“apiVersion”: “v1”,
“metadata”: {
},
“status”: “Failure”,
“message”: "services \“ks-sample-dev\” is forbidden: User \“system:anonymous\” cannot get resource \“services\” in API group \“\” in the namespace \“kubesphere-sample-dev\”",
“reason”: “Forbidden”,
“details”: {
“name”: “ks-sample-dev”,
“kind”: “services”
},
“code”: 403
}
Kubernetes deployment ended with HasError
这个问题是 kubeconfig不对的问题,原因是3.0版本的bug,最后官方大佬给出了临时解决方法。
kubectl -n kubesphere-controls-system delete cm kubeconfig-[用户名]
kubectl -n kubesphere-system rollout restart deployment ks-controller-manager ks-apiserver
例:kubectl -n kubesphere-controls-system delete cm kubeconfig-admin
然后重建demo-kubeconfig,运行流水线,一次搞定。
单独说一下:Received fatal alert: bad_certificate,遇到这个问题 其实原因是一个,就是 kubeconfig不对的问题。
解决过程参考:https://kubesphere.com.cn/forum/d/2591-spring-boot-received-fatal-alert-bad-certificate
其他问题请参考官方大佬文档:https://kubesphere.com.cn/forum/d/2408-kubesphere-devops-30