kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app

部署gitlab,cd /home/k8s/gitlab && kubectl apply -f .

cd ingress && && kubectl apply -f .

cd ../runner,配置gitlab的token,执行kubectl apply -f .

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第1张图片

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第2张图片

gitlab注册runner,复制Registration token内容(LgdHoMos5rJdFAxb8Jks)。

并且将token进行Base64编码:

 token 进行 base64 编码:

echo LgdHoMos5rJdFAxb8Jks | base64 -w0

得到内容:TGdkSG9Nb3M1ckpkRkF4YjhKa3MK

将上面得到的内容,配置在gitlab-ci-token-secret.yaml文件中

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第3张图片

在/home/k8s/gitlab/runner目录下执行

kubectl apply -f .

gitlab注册runner后的效果

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第4张图片

 Add Kubernete Cluster

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第5张图片

Connect a Kubernetes cluster(注意工程下一定要有agent的配置文件)

.gitlab/agents/demo-agent,否则下拉列表无法加载出来。点击Register按钮

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第6张图片

 页面弹出如下信息

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)执行

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第7张图片

  上面的内容稍作修改

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/

得到的效果:

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第8张图片

搭建Harbor,在/home/harbor目录执行./install.sh

配置环境变量

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第9张图片

修改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

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第10张图片

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第11张图片

 kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第12张图片

 kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第13张图片

 kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第14张图片

 kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第15张图片

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第16张图片

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第17张图片

Maven打包阶段kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第18张图片

K8s部署apply阶段

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第19张图片

 kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第20张图片

 验证效果:

http://10.10.10.99:30812/word/demo,下载word文档

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第21张图片

 存在问题:

构建docker image出现Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?,还没有解决》

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第22张图片

使用docker:latest和docker:dind不知道为什么不行!!!!

降低版本:

kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第23张图片

 kubernetes部署gitlab+ci/cd Runner+Harbor+spring-boot-app_第24张图片

 

你可能感兴趣的:(问题记录,kubernetes)