• kubernetes实战(十五):k8s使用helm持久化部署jenkins集成openLDAP登录


    1、基本概念

      Jenkins在DevOps工具链中是核心的流程管理中心,负责串联系统的构建流程、测试流程、镜像制作流程、部署流程等,在持续集成中常用到的工具如下:

      Maven:源代码编译工具

      RobotFramework:自动化测试工具

      NewMan:接口自动化测试工具

      SonarQube Scanner:源代码扫描工具

      GitLab:代码仓库工具

      Docker:镜像制作工具

      kubectl:K8S工具

      公司目前使用的流程是通过Redmine和GitLab中创建项目、开发提交代码、触发jenkins完成镜像构建并自动部署到k8s集群。

     

    2、部署

    [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

    3、查看状态

    [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

    4、访问测试

      查看密码

    [root@k8s-master01 ~]# kubectl get secret --namespace public-service jenkins -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode
    9jni0dNNY9

      登录:admin/9jni0dNNY9

     

    5、配置LDAP登录

      系统管理 -- 插件管理

      建立openLDAP组织架构如下

      ou=People对应的用户的组为ou=jenkins,ou=Groups里面的组

      系统管理 -- 全局安全配置

      配置如下

      配置完LDAP登陆以后,本地认证就会失效,所以提前配置好权限也可,上述权限按需修改。

      另外,本人对openLDAP filter语法不太熟,配置邮箱登录的时候无法获取对应的组,所以采用了uid登录,如有openLDAP大神还请指教。

      验证权限,登录jenkins-dev组的用户

      无法管理jenkins

    赞助作者:

      

  • 相关阅读:
    LeetCode-Path Sum I & II & III
    LeetCode-Unique Binary Search Trees I & II
    LeetCode-230. Kth Smallest Element in a BST
    LeetCode-98. Validate Binary Search Tree
    LeetCode-450. Delete Node in a BST
    LeetCode-108. Convert Sorted Array to Binary Search Tree
    LeetCode-129. Sum Root to Leaf Numbers
    视频中人体轮廓检测
    新型SVM
    Surveillance Monitering入门学习论文笔记
  • 原文地址:https://www.cnblogs.com/dukuan/p/10064150.html
Copyright © 2020-2023  润新知