第三篇 jenkins怎么样部署k8s项目之Jenkins-Slave补充,问题总结
Git下载代码报错
ERROR: Error cloning remote repo ‘origin’
hudson.plugins.git.GitException: Command “git fetch –tags –force –progress – https://gitlab.rails.cn/zhangxiangyang/CARSOA-CLOUD.git +refs/heads/_:refs/remotes/origin/_” returned status code 128:
stdout:
stderr: fatal: unable to access ‘https://gitlab.rails.cn/zhangxiangyang/CARSOA-CLOUD.git/’: server certificate verification failed. CAfile: none CRLfile: none
server certificate verification failed. CAfile: none CRLfile: none
解决方法
添加环境变量export GIT_SSL_NO_VERIFY=1
在k8s部署的pipeline上需要在Jenkins上配置
如何保存构建数据
在java
和node
项目构建时,需要保留缓存的maven
和node_modules
依赖来保证下次快速构建,不用每次都去仓库下载
解决方法
如图,我们只需要将仓库挂在到主机就可以了
无法打包docker镜像
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
原因:Jenkins-slave节点内没有运行docker服务
解决方法
只需要把主机的docker.sock挂载到container里就可以了
权限问题
解决上面问题后,是可以构建打包了,但发现部署时出了问题Error from server (Forbidden): error when deleting "deployment.yaml": deployments.apps "config-deployment" is forbidden: User "system:serviceaccount:devops:default" cannot delete resource "deployments" in API group "apps" in the namespace "bjj"
说明一下,默认情况下pod会使用namespace中的default用户去执行,default用户是没有权限操作其它namespace中的pod的,所以我们要添加一个用户,指定其为集群权限
权限配置如下可以去 原文 copy
https://www.code404.icu/520.html
没有部署权限
在Jenkins上的pod模板上配置一下用户
这样就可以了,不过这样配置还是比较麻烦的,我们在第四篇讲解如何把这些配置写到一个配置文件里