使用gitlab + gitlab runner + nexus + k8s技术栈搭建devops全流程

版本清单

  • gitlab:12.8.1-ce.0
  • gitlab runner:v12.9.0
  • nexus:3.21.1
  • k8s:1.17.4
  • istio:1.5.1

前提条件

  • maven镜像未使用官方的,而是基于JDK镜像自己创建,原因是官方的镜像对于配置全局mirror没有找到简单方便的办法
  • kubectl官方没有镜像,当前使用的是:bitnami/kubectl

安装过程

gitlab

  • 使用compose安装:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  gitlab:
    image: gitlab/gitlab-ce:12.8.1-ce.0
    ports:
    - '22:22'
    - '80:80'
    - '443:443'
    volumes:
    - /data/gitlab/config:/etc/gitlab
    - /data/gitlab/logs:/var/log/gitlab
    - /data/gitlab/data:/var/opt/gitlab
    container_name: gitlab
    restart: unless-stopped
  • gitlab.rb配置文件修改:
 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
external_url 'https://ip'

gitlab_rails['time_zone'] = 'Asia/Shanghai'

gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'xxx@xxx.xxx'
gitlab_rails['gitlab_email_display_name'] = 'xxx'

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.xxx.xxx.xxx"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "xxx@xxx.xxx"
gitlab_rails['smtp_password'] = "********"
gitlab_rails['smtp_domain'] = "xxx.xxx"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true

user['git_user_name'] = "GitLab"
user['git_user_email'] = "xxx@xxx.xxx"

nginx['enable'] = true
nginx['redirect_http_to_https'] = true
nginx['redirect_http_to_https_port'] = 80

nginx['ssl_certificate'] = "/etc/gitlab/trusted-certs/xxx.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/trusted-certs/xxx.key"

go 1.13开发环境搭建

进入项目目录:go mod init

设置环境变量:GOPROXY=“https://goproxy.io,direct”

运行go get的时候,发现报410 gone的错误,目前网上查到的资料都是扯淡,查官方文档,在1.13版本加了版本验证,官方说如果因为防火墙或代理问题验证不了,可以添加环境变量:GOSUMDB=off关闭验证。记得:命令行窗口需要退出重新打开才能生效!!!

[阅读全文]

使用Nexus3搭建docker registry

Nexus 3.0 的三种docker仓库:

  1. docker (proxy) 代理和缓存远程仓库 ,只能pull
  2. docker (hosted) 托管仓库 ,私有仓库,可以push和pull
  3. docker (group) 将多个proxy和hosted仓库添加到一个组,只访问一个组地址即可,只能pull

前提:安装配置好了Java运行环境

[阅读全文]