GitLab CICD自动更新k8s中容器版本

前提

之前使用Gitlab和Runner的版本是12.*,现在已经到了16.*,安装和配置跟之前相比几乎没有变化,所以按之前的文档操作下来,一路比较顺利。在更新k8s集群容器版本的时候出现问题了,原来Auto Deploy方式在14.*版本被弃用,较新的方案是安装k8s代理,方案有2种:

[阅读全文]

使用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"