🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
gitlab-runner回部署两个服务分别为docker、share,他们一个是编包的访问一个是发布的服务。 ### 先来部署docker服务 ``` 部署前存储目录 # mkdir -p /nfs_dir/{gitlab-runner1-ver130806-docker,gitlab-runner2-ver130806-share} 文件这个地方需要修改:     - ip: "10.68.31.18"       hostnames:       - "git.boge.com" [root@node-111 home]# kubectl -n gitlab-ver130806 get svc | grep git gitlab NodePort 10.68.31.18 <none> 80:31945/TCP,22:30324/TCP 21h # pv --- apiVersion: v1 kind: PersistentVolume metadata: name: gitlab-runner1-ver130806-docker labels:   type: gitlab-runner1-ver130806-docker spec: capacity:   storage: 0.1Gi accessModes:   - ReadWriteMany persistentVolumeReclaimPolicy: Retain storageClassName: nfs nfs:   path: /nfs_dir/gitlab-runner1-ver130806-docker   server: 10.4.7.111 # pvc --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: gitlab-runner1-ver130806-docker namespace: gitlab-ver130806 spec: accessModes:   - ReadWriteMany resources:   requests:     storage: 0.1Gi storageClassName: nfs selector:   matchLabels:     type: gitlab-runner1-ver130806-docker --- # https://docs.gitlab.com/runner/executors # concurrent = 30 # check_interval = 0 # # [session_server] # session_timeout = 1800 # # [[runners]] # name = "gitlab-runner1-ver130806-docker" # url = "http://git.boge.com/" # token = "LQsVzL-XdGKW9F1jSkJu" # executor = "kubernetes" # [runners.kubernetes] # namespace = "gitlab-ver130806" # image = "harbor.boge.com/library/docker:stable" # helper_image = "harbor.boge.com/library/gitlab-runner-helper:x86_64-9fc34d48-pwsh" ~~~ #   image = "docker:stable" #   helper_image = "gitlab/gitlab-runner-helper:x86_64-9fc34d48-pwsh" ~~~ # privileged = true # [[runners.kubernetes.volumes.pvc]] # name = "gitlab-runner1-ver130806-docker" # mount_path = "/mnt" --- apiVersion: apps/v1 kind: Deployment metadata: name: gitlab-runner1-ver130806-docker namespace: gitlab-ver130806 spec: replicas: 1 selector:   matchLabels:     name: gitlab-runner1-ver130806-docker template:   metadata:     labels:       name: gitlab-runner1-ver130806-docker   spec:     hostAliases:     - ip: "10.68.31.18"       hostnames:       - "git.boge.com"     serviceAccountName: gitlab     containers:     - args:       - run       image: gitlab/gitlab-runner:v13.10.0       name: gitlab-runner1-ver130806-docker       volumeMounts:       - mountPath: /etc/gitlab-runner         name: config       - mountPath: /etc/ssl/certs         name: cacerts         readOnly: true     restartPolicy: Always     volumes:     - persistentVolumeClaim:         claimName: gitlab-runner1-ver130806-docker       name: config     - hostPath:         path: /usr/share/ca-certificates/mozilla       name: cacerts ``` 进入对应runner-pod注册服务 kubectl -n gitlab-ver130806 exec -it gitlab-runner1-ver130806-docker-5f5c4c9f6d-vmwlf bash 输入:gitlab-ci-multi-runner register 然后输入:URL 再输入:token ![](https://img.kancloud.cn/9e/bd/9ebd0c58989ba1c33e53eb1a094e99df_1624x370.png) 再输入:gitlab-runner1-ver130806-docker 再输入:docker 再输入:kubernetes 然后退出容器修改其他配置: ``` [root@node-111 gitlab]# cat /nfs_dir/gitlab-runner1-ver130806-docker/config.toml concurrent = 30 check_interval = 0 [session_server] session_timeout = 1800 [[runners]] name = "gitlab-runner1-ver130806-docker" url = "http://git.boge.com/" token = "LQsVzL-XdGKW9F1jSkJu" executor = "kubernetes" [runners.kubernetes] namespace = "gitlab-ver130806" image = "harbor.boge.com/library/docker:stable" helper_image = "harbor.boge.com/library/gitlab-runner-helper:x86_64-9fc34d48-pwsh" privileged = true [[runners.kubernetes.volumes.pvc]] name = "gitlab-runner1-ver130806-docker" mount_path = "/mnt" ``` 修改完成重启pod kubectl -n gitlab-ver130806 delete pod gitlab-runner1-ver130806-docker-5f5c4c9f6d-vmwlf 下来需要配置一下 ![](https://img.kancloud.cn/dd/53/dd5365c72f0f62d41a9de7aec04e706b_1311x646.png) ### 部署share服务 ``` # pv --- apiVersion: v1 kind: PersistentVolume metadata: name: gitlab-runner2-ver130806-share labels:   type: gitlab-runner2-ver130806-share spec: capacity:   storage: 0.1Gi accessModes:   - ReadWriteMany persistentVolumeReclaimPolicy: Retain storageClassName: nfs nfs:   path: /nfs_dir/gitlab-runner2-ver130806-share   server: 10.4.7.111 # pvc --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: gitlab-runner2-ver130806-share namespace: gitlab-ver130806 spec: accessModes:   - ReadWriteMany resources:   requests:     storage: 0.1Gi storageClassName: nfs selector:   matchLabels:     type: gitlab-runner2-ver130806-share --- # https://docs.gitlab.com/runner/executors # concurrent = 30 # check_interval = 0 # # [session_server] # session_timeout = 1800 # # [[runners]] # name = "gitlab-runner2-ver130806-share" # url = "http://git.boge.com/" # token = "nD7XtNy28PsY9T8_bdsX" # executor = "kubernetes" # [runners.kubernetes] # namespace = "gitlab-ver130806" # image = "harbor.boge.com/library/busybox:v1.29.2" # helper_image = "harbor.boge.com/library/gitlab-runner-helper:x86_64-9fc34d48-pwsh" ~~~ #   image = "registry.cn-beijing.aliyuncs.com/acs/busybox/busybox:v1.29.2" #   helper_image = "gitlab/gitlab-runner-helper:x86_64-9fc34d48-pwsh" ~~~ # privileged = false # [[runners.kubernetes.volumes.pvc]] # name = "gitlab-runner2-ver130806-share" # mount_path = "/mnt" --- apiVersion: apps/v1 kind: Deployment metadata: name: gitlab-runner2-ver130806-share namespace: gitlab-ver130806 spec: replicas: 1 selector:   matchLabels:     name: gitlab-runner2-ver130806-share template:   metadata:     labels:       name: gitlab-runner2-ver130806-share   spec:     hostAliases:     - ip: "10.68.140.109"       hostnames:       - "git.boge.com"     serviceAccountName: gitlab     containers:     - args:       - run       image: gitlab/gitlab-runner:v13.10.0       name: gitlab-runner2-ver130806-share       volumeMounts:       - mountPath: /etc/gitlab-runner         name: config       - mountPath: /etc/ssl/certs         name: cacerts         readOnly: true     restartPolicy: Always     volumes:     - persistentVolumeClaim:         claimName: gitlab-runner2-ver130806-share       name: config     - hostPath:         path: /usr/share/ca-certificates/mozilla       name: cacerts ``` 这里需要修改的步骤和上面一样 一样这里也需要配置一下 ![](https://img.kancloud.cn/a9/4b/a94b0207acc10f3c70b6898624c3f8fa_1167x588.png) 配置完成以后 ![](https://img.kancloud.cn/d2/41/d241711baab40d13f96255faf29eb7a8_1719x622.png)