1. 打包自己的jenkins 1 2 3 4 5 6 7 8 FROM swr.cn-north-4 .myhuaweicloud.com/ddn-k8s/docker.io/jenkins/jenkins:latest-jdk17USER rootRUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources RUN apt-get update && apt-get install -y libltdl7 make RUN mkdir -p /home/tools/go COPY go1.22.5.linux-amd64.tar.gz /home/tools/go/ RUN rm -rf /usr/local/go && tar -C /usr/local -xzf /home/tools/go/go1.22.5.linux-amd64.tar.gz ENV PATH=$PATH:/usr/local/go/bin
2. 上传到阿里云 3. 部署jenkins 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 apiVersion: v1 kind: Service metadata: namespace: jenkins name: service-jenkins labels: app: jenkins spec: type: NodePort ports: - protocol: TCP port: 80 nodePort: 30080 targetPort: 80 name: jenkins-tcp - protocol: TCP port: 10022 nodePort: 30022 targetPort: 10022 name: jenkins-tcp-sshd selector: app: jenkins --- apiVersion: apps/v1 kind: Deployment metadata: namespace: jenkins name: jenkins-deployment spec: replicas: 1 selector: matchLabels: app: jenkins template: metadata: labels: app: jenkins spec: nodeName: nodecicd containers: - name: jenkins image: registry.cn-shanghai.aliyuncs.com/ethereal-o/jenkins:latest securityContext: runAsUser: 0 runAsGroup: 0 env: - name: 'TZ' value: 'Asia/Shanghai' - name: 'JENKINS_OPTS' value: '--httpPort=80' - name: 'JENKINS_SLAVE_AGENT_PORT' value: '10080' ports: - containerPort: 80 protocol: TCP - containerPort: 10080 protocol: TCP volumeMounts: - name: jenkins-cfgmap-vol mountPath: "/etc/ssh/ssh_config" subPath: "ssh-config" readOnly: true - name: jenkins-cfgmap-vol mountPath: "/etc/apt/sources.list.d/debian.sources" subPath: "etc-repo" readOnly: true - name: vol-jenkins-home mountPath: "/var/jenkins_home" - name: vol-jenkins-repo mountPath: "/home/share_data/nginx/share/repo" - name: vol-docker-socket mountPath: "/var/run/docker.sock" - name: vol-docker-exe mountPath: "/usr/bin/docker" - name: config-volume mountPath: /etc/kubernetes/admin.conf volumes: - name: jenkins-cfgmap-vol configMap: name: jenkins-cfgmap defaultMode: 0444 - name: vol-jenkins-home hostPath: path: "/home/share_data/k8s/jenkins/var/jenkins_home" type: DirectoryOrCreate - name: vol-jenkins-repo hostPath: path: "/home/share_data/nginx/share/repo" type: DirectoryOrCreate - name: vol-docker-socket hostPath: path: "/var/run/docker.sock" type: Socket - name: vol-docker-exe hostPath: path: /usr/bin/docker - name: config-volume hostPath: path: "/etc/kubernetes/admin.conf" type: File --- apiVersion: v1 kind: ConfigMap metadata: namespace: jenkins name: jenkins-cfgmap data: ssh-config: | Host * IdentityFile /var/jenkins_home/.ssh/id_rsa StrictHostKeyChecking no UserKnownHostsFile=/dev/null GSSAPIAuthentication=no etc-repo: | Types: deb # http://snapshot.debian.org/archive/debian/20240311T000000Z URIs: http://repo.huaweicloud.com/debian Suites: bookworm bookworm-updates Components: main Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg Types: deb URIs: http://repo.huaweicloud.com/debian-security Suites: bookworm-security Components: main Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
4. 配置jenkins 需要安装插件Publish Over SSH
5. 配置Gitee的WebHook 参考Jenkins在Linux环境下的安装与配置指南 (baidu.com)
6. 参考 Jenkins在Linux环境下的安装与配置指南 (baidu.com)
Jenkins部署及持续集成——傻瓜式教程-腾讯云开发者社区-腾讯云 (tencent.com)
最详细的k8s中部署Jenkins教程+基于jenkins+k8s(container)实现CI/CD-CSDN博客
docker in docker 出现 libltdl.so.7 问题 - fengjian1585 - 博客园 (cnblogs.com)
运维 - jenkins 手动安装Go 构建环境 - 个人文章 - SegmentFault 思否