一、基本概念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
贊助做者: