部署gitlab,cd /home/k8s/gitlab && kubectl apply -f .
cd ingress && && kubectl apply -f .
cd ../runner,配置gitlab的token,执行kubectl apply -f .
gitlab注册runner,复制Registration token内容(LgdHoMos5rJdFAxb8Jks)。
并且将token进行Base64编码:
token 进行 base64 编码:
echo LgdHoMos5rJdFAxb8Jks | base64 -w0
得到内容:TGdkSG9Nb3M1ckpkRkF4YjhKa3MK
将上面得到的内容,配置在gitlab-ci-token-secret.yaml文件中
在/home/k8s/gitlab/runner目录下执行
kubectl apply -f .
gitlab注册runner后的效果
Add Kubernete Cluster
Connect a Kubernetes cluster(注意工程下一定要有agent的配置文件)
.gitlab/agents/demo-agent,否则下拉列表无法加载出来。点击Register按钮
页面弹出如下信息
Connect a Kubernetes cluster
Agent access token:
-LDW7CieVEn9VK8uJnBve8u1-Vxs8HLjzjTwsUzZQGxjKubDyA
The agent uses the token to connect with GitLab.
You cannot see this token again after you close this window.
Install using Helm (recommended)
From a terminal, connect to your cluster and run this command. The token is included in the command.
helm repo add gitlab https://charts.gitlab.io
helm repo update
helm upgrade --install demo-agent gitlab/gitlab-agent \
--namespace gitlab-agent \
--create-namespace \
--set image.tag=v15.6.0 \
--set config.token=-LDW7CieVEn9VK8uJnBve8u1-Vxs8HLjzjTwsUzZQGxjKubDyA \
--set config.kasAddress=ws://gitlab-558b4cdbf6-7h9jw/-/kubernetes-agent/
Advanced installation methods
View the documentation for advanced installation. Ensure you have your access token available.
复制Install using Helm (recommended)执行
上面的内容稍作修改
helm upgrade --install demo-agent gitlab/gitlab-agent \
--namespace demo \
--create-namespace \
--set image.tag=v15.6.0 \
--set config.token=-LDW7CieVEn9VK8uJnBve8u1-Vxs8HLjzjTwsUzZQGxjKubDyA \
--set config.kasAddress=ws://gitlab/-/kubernetes-agent/
得到的效果:
搭建Harbor,在/home/harbor目录执行./install.sh
配置环境变量
修改gitlab的域名,同时启动了ingress controller
find / -name gitlab.rb
/home/data/nfs-share/demo-gitlab-persistent-config-pvc-b2dcdc21-f02a-45d8-a93c-819569d86467/gitlab.rb
kubectl exec -it gitlab-874bb9784-42dhs -n demo bash
gitlab-ctl reconfigure
gitlab-ctl restart
K8s部署apply阶段
验证效果:
http://10.10.10.99:30812/word/demo,下载word文档
存在问题:
构建docker image出现Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?,还没有解决》
使用docker:latest和docker:dind不知道为什么不行!!!!
降低版本: