Devops软件生命周期的第一阶段,代码阶段。
我们需要在这个阶段实现开发部门人员能将写好的代码上传到GitLab上存储,接下来由Jenkins处理,进行代码的构建(maven),进行代码测试(sonarqube),也就是所谓的CI阶段。再由Jenkins处理,进行项目的打包push到测试/生产环境,再告知测试/生产环境进行项目的部署,也就是所谓的CD阶段。
Dev0ps理念:让开发人员可以持续集成,运维人员可以持续交付和持续部署,让整个开发过程自动部署,上线...
-
开发写完的代码自动集成,自动交付与部署。其本质是自动化。
-
Devops是一套快速、频繁、可靠的软件交付实践。
#整个流程我们准备了三台机器用作模拟生产环境
hostname | ip |
k8smaster | 192.168.64.20 |
k8snode1 | 192.168.64.21 |
k8snode2 | 192.168.64.22 |
#我们现在要做的就是Gitlab的安装部署
#gitlab运行内存推荐4G.(运行需要3G左右) ,需要在机器上安装docker和docker-compose
#首先拉取镜像
docker pull gitlab/gitlab-ce
#随后编写yml,安装gitlab
[root@k8smaster gitlab]# cat docker-compose.yml
version: "3.1"
services:
gitlab:
image: 'gitlab/gitlab-ce'
container_name: gitlab
restart: always
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://192.168.64.20:8929' #这里替换为宿主机地址
gitlab_rails['gitlab_shell_ssh_port'] = 2224
ports:
- '8929:8929'
- '2224:2224'
volumes:
- './config:/etc/gitlib'
- './logs:/var/log/gitlab'
- './data:/var/opt/gitlb'
[root@k8smaster gitlab]#
[root@k8smaster gitlab]# pwd
/usr/local/gitlab
#运行即可
docker-compose up -d
#浏览器访问ip:8929
#登录密码在容器内,查看后复制登录即可
[root@k8smaster gitlab]# docker exec -it gitlab bash
root@e91bc8e1e8d0:/#
root@e91bc8e1e8d0:/# cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
# 2. Password hasn't been changed manually, either via UI or via command line.
#
# If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
Password: +O5+gG5B/ShbsDl9j0EUXQNfJ+IjSDieJhjClrLj/3k=
# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
#到这里就安装好gitlab了。