1. 程式人生 > >Kubernetes - - k8s - v1.12.3 Helm持久化部署 Jenkins 整合 OpenLDAP 登入

Kubernetes - - k8s - v1.12.3 Helm持久化部署 Jenkins 整合 OpenLDAP 登入

1,基本概念

  • Jenkins在DevOps工具鏈中是核心的流程管理中心,負責串聯絡統的構建流程、測試流程、映象製作流程、部署流程等,在持續整合中常用到的工具如下:
  • Maven:原始碼編譯工具
  • RobotFramework:自動化測試工具
  • NewMan:介面自動化測試工具
  • SonarQube Scanner:原始碼掃描工具
  • GitLab:程式碼倉庫工具
  • Docker:映象製作工具
  • kubectl:K8S工具
  • 目前使用的流程是通過Redmine和GitLab中建立專案、開發提交程式碼、觸發jenkins完成映象構建並自動部署到k8s叢集。

2,部署

2.1 下載程式碼

git clone https://github.com/xiaoqshuo/k8s-cluster.git

2.2 安裝 Jenkins

[[email protected] jenkins-helm]# helm install --name jenkins . --namespace public-service
NAME:   jenkins
LAST DEPLOYED: Fri Dec 21 08:49:59 2018
NAMESPACE: public-service
STATUS: DEPLOYED

RESOURCES:
==> v1/Service
NAME           AGE
jenkins-agent  1s
jenkins        1s

==> v1beta1/Deployment
jenkins  1s

==> v1/Secret
jenkins  2s

==> v1/ConfigMap
jenkins        2s
jenkins-tests  2s

==> v1/PersistentVolumeClaim
jenkins  2s


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

2.3 建立 ingress

[[email protected] jenkins-helm]# kubectl create -f traefik-jenkins.yaml
ingress.extensions/jenkins created

2.4 檢視狀態

[[email protected] jenkins-helm]# kubectl get po,svc,ingress,pvc -n public-service | grep jenkins
pod/jenkins-678c74d8f8-dzvcm           1/1     Running            1          16m

service/glusterfs-dynamic-jenkins                  ClusterIP   10.96.104.25     <none>        1/TCP                            15m
service/jenkins                                    ClusterIP   10.103.109.143   <none>        8080/TCP                         16m
service/jenkins-agent                              ClusterIP   10.104.102.106   <none>        50000/TCP                        16m

ingress.extensions/jenkins   jenkins.k8s.net             80      19h

persistentvolumeclaim/jenkins                                                    Bound    pvc-5ba828d9-04ba-11e9-a5f6-000c2927a0d0   20Gi       RWX            gluster-heketi                 16m

2.5 訪問測試

  • 解析域名 https://jenkins.k8s.net 至叢集

3,配置 Jenkins

3.1 登入

3.1.1 檢視密碼

[[email protected] jenkins-helm]# kubectl get secret --namespace public-service jenkins -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode
OZy8B3uklZ

3.1.2 登入

  • admin/OZy8B3uklZ

3.2 配置LDAP登入

3.2.1 安裝LDAP外掛

3.2.2 建立openLDAP組織架構如下

3.2.3 配置

  • ou=People對應的使用者的組為ou=jenkins,ou=Groups裡面的組
  • 配置完LDAP登陸以後,本地認證就會失效

  • uid:ONE PIECE luobing
  • passwd: luobing

3.2.4 登入

  • 參考:
    • https://www.cnblogs.com/dukuan/p/10064150.htm