atomci icon indicating copy to clipboard operation
atomci copied to clipboard

编译环境支持更多的参数定义

Open colynn opened this issue 3 years ago • 4 comments

您有什么需求,是否与某个功能或问题相关? 请描述 如题

你想要的解决方案是什么 当前编译环境只支持镜像启动命令启动参数的定义, 比如对于 volume的挂载也期望可以支持

Screen Shot 2022-03-12 at 10 40 53 AM

  • 请你通过留下👍 表情为此issue投票,帮助社区和维护者优先考虑这个请求;

  • 请不要留下 "+1 "或 "me too"的评论,它们会给问题订阅者带来额外的噪音,并且无助于优先处理请求。

  • 如果你有兴趣在这个问题上工作,或者已经提交了pull request,请留下评论.

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request

  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request

  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

colynn avatar Mar 12 '22 02:03 colynn

@sampsonye 讲述一下这个issue的两种思路呗,结合2.0的roadmap

fanhousanbu avatar Mar 30 '22 07:03 fanhousanbu

@sampsonye 讲述一下这个issue的两种思路呗,结合2.0的roadmap

个人思路: AtomCI是借助Jenkins的Kubernetes插件能力实现分布式构建的,我们只需要在构建的流水线中加入合适的挂载,即可实现挂载副本的能力 首先我们看一个默认生成的流水线样式:


            
pipeline {
    agent {
        kubernetes {
            defaultContainer 'jnlp'
            yaml """
apiVersion: v1
kind: Pod
metadata:
  namespace: devops
spec:
  containers:
  - name: jnlp
    image: colynn/jenkins-jnlp-agent:latest
    workingDir: /home/jenkins/agent
    command:
    args:
    tty: true
  - name: kaniko
    image: colynn/kaniko-executor:debug
    workingDir: /home/jenkins/agent
    command:
    - /bin/sh
    - -c
    args:
    - cat
    tty: true
"""          
        }
    }
    environment {
        def JENKINS_SLAVE_WORKSPACE = '/home/jenkins/agent'
        def ACCESS_TOKEN = 'XXXX'
        def REPO_CNF = '{"XXXX":["xxx","XXXXX"]}'
        def DOCKER_AUTH = 'MjcxMjMyNTA3QHFxLmNvbTpsZWFmbHkwNzE5'
        def REGISTRY_ADDR = 'registry.cn-hangzhou.aliyuncs.com'
        def DOCKER_CONFIG = '/kaniko/.docker'
    }
    stages {
        
stage('Checkout') {    
    parallel {
        stage('first-blood-3') {
            steps {
                sh 'python3 /home/admin/scripts_dev/app_checkout.py  --project-id 1 --stage-id 1 --publish-job-id 87   --scm-app-id 5 --app-name first-blood-3 --app-language C# --branch-url http://180.76.53.109/sampsonye/quant-first-blood.git --vcs-type git --build-path /   --branch-name clean '
            }
        }
    }
    
}
 
stage('Builds') {
    
    parallel {
        stage('first-blood-3') {
            steps {
                container('jnlp') {
                    sh 'echo app:first-blood-3 language:C#, did not setup compile env,skip compile...'
                }
            }
        }
    }   
}
 
stage('Images') {    
    parallel {
        stage('first-blood-3') {
            steps {
                container("kaniko") {
                    sh "[ -d $DOCKER_CONFIG ] || mkdir -pv $DOCKER_CONFIG"
                    sh """
                    echo '{"auths": {"'$REGISTRY_ADDR'": {"auth": "'$DOCKER_AUTH'"}}}' > $DOCKER_CONFIG/config.json
                    """
                    sh "cd /home/jenkins/agent/1/1/first-blood-3/clean/; export DOCKER_CONFIG=$DOCKER_CONFIG; /kaniko/executor -f Approve.Enterance/Dockerfile -c ./  -d registry.cn-hangzhou.aliyuncs.com/leafly/quant-first-blood-3:clean-275edf6  "
                }
            }
        }
    }
    
}

        stage('Callback') {
            steps {
                retry(count: 5) {
                    httpRequest acceptType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON', customHeaders: [[maskValue: true, name: 'Authorization', value: 'Bearer XXXX']], httpMode: 'POST', requestBody: '''{"publish_job_id": 87}''', responseHandle: 'NONE', timeout: 10, url: 'http://XXXX/atomci/api/v1/pipelines/1/publishes/9/stages/1/steps/build/callback'
                }
            }
        }
    }
}

我们只需将volume放到这里即可

apiVersion: v1
kind: Pod
metadata:
  namespace: devops
spec:
  containers:
  - name: jnlp
    image: colynn/jenkins-jnlp-agent:latest
    workingDir: /home/jenkins/agent
    command:
    args:
    tty: true
  - name: kaniko
    image: colynn/kaniko-executor:debug
    workingDir: /home/jenkins/agent
    command:
    - /bin/sh
    - -c
    args:
    - cat
    tty: true

找到生成这个YAML的地方,搞它!!!

文档参考

Jenkins Kubernetes插件:https://plugins.jenkins.io/kubernetes/ Kubernetes POD定义:https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/

sampsonye avatar Apr 03 '22 05:04 sampsonye

目前看,最适合我们的是hostPath卷挂载:https://kubernetes.io/zh/docs/concepts/storage/volumes/#hostpath-%E9%85%8D%E7%BD%AE%E7%A4%BA%E4%BE%8B 优点是:

  1. 云平台无关性
  2. 持久保存

缺点:

  1. 与host绑定,无法动态共享
  2. 安全性存疑

关于使用何种类型的Volume,各位的意见是怎么样的呢? @colynn @fanhousanbu @CraiGZero

sampsonye avatar Apr 06 '22 14:04 sampsonye

close 这个issue如何?

fanhousanbu avatar Apr 07 '22 02:04 fanhousanbu