一、基本概念git
Jenkins在DevOps工具链中是核心的流程管理中心,负责串联系统的构建流程、测试流程、镜像制做流程、部署流程等,在持续集成中经常使用到的工具以下:github
Maven:源代码编译工具shell
RobotFramework:自动化测试工具json
NewMan:接口自动化测试工具安全
SonarQube Scanner:源代码扫描工具架构
GitLab:代码仓库工具工具
Docker:镜像制做工具测试
kubectl:K8S工具jsonp
公司目前使用的流程是经过Redmine和GitLab中建立项目、开发提交代码、触发jenkins完成镜像构建并自动部署到k8s集群。ui
二、部署
[root@k8s-master01 jenkins]# git clone https://github.com/dotbalo/helm.git
[root@k8s-master01 ~]# cd helm/jenkins
[root@k8s-master01 jenkins]# helm install --name jenkins . --namespace public-service NAME: jenkins LAST DEPLOYED: Tue Dec 4 14:55:24 2018 NAMESPACE: public-service STATUS: DEPLOYED RESOURCES: ==> v1/Secret NAME AGE jenkins 0s ==> v1/ConfigMap jenkins 0s jenkins-tests 0s ==> v1/PersistentVolumeClaim jenkins 0s ==> v1/Service jenkins-agent 0s jenkins 0s ==> v1beta1/Deployment jenkins 0s ==> v1/Pod(related) NAME READY STATUS RESTARTS AGE jenkins-5b6c648956-zds2p 0/1 Pending 0 0s NOTES: 1. Get your 'admin' user password by running: printf $(kubectl get secret --namespace public-service jenkins -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode);echo 2. Get the Jenkins URL to visit by running these commands in the same shell: export POD_NAME=$(kubectl get pods --namespace public-service -l "component=jenkins-master" -o jsonpath="{.items[0].metadata.name}") echo http://127.0.0.1:8080 kubectl port-forward $POD_NAME 8080:8080 3. Login with the password from step 1 and the username: admin For more information on running Jenkins on Kubernetes, visit: https://cloud.google.com/solutions/jenkins-on-container-engine
建立ingress
[root@k8s-master01 jenkins]# kubectl create -f traefik-jenkins.yaml
ingress.extensions/jenkins created
三、查看状态
[root@k8s-master01 ~]# kubectl get po,svc,ingress,pvc -n public-service | grep jenkins pod/jenkins-5b6c648956-zds2p 1/1 Running 5 44h service/glusterfs-dynamic-jenkins ClusterIP 10.111.100.114 <none> 1/TCP 44h service/jenkins ClusterIP 10.107.215.94 <none> 8080/TCP 44h service/jenkins-agent ClusterIP 10.103.212.222 <none> 50000/TCP 44h ingress.extensions/jenkins jenkins.xxx.net 80 3m26s persistentvolumeclaim/jenkins Bound pvc-953c3093-f791-11e8-9640-000c298bf023 20Gi RWX gluster-heketi-2 44h
四、访问测试
查看密码
[root@k8s-master01 ~]# kubectl get secret --namespace public-service jenkins -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode 9jni0dNNY9
登陆:admin/9jni0dNNY9
五、配置LDAP登陆
系统管理 -- 插件管理
创建openLDAP组织架构以下
ou=People对应的用户的组为ou=jenkins,ou=Groups里面的组
系统管理 -- 全局安全配置
配置以下
配置完LDAP登录之后,本地认证就会失效,因此提早配置好权限也可,上述权限按需修改。
另外,本人对openLDAP filter语法不太熟,配置邮箱登陆的时候没法获取对应的组,因此采用了uid登陆,若有openLDAP大神还请指教。
验证权限,登陆jenkins-dev组的用户
没法管理jenkins
赞助做者: