gitlab_ci _cd

发布时间 2023-10-25 23:35:44作者: virtualwxg

首先部署gitlab

>参考https://help.aliyun.com/zh/ecs/use-cases/deploy-and-use-gitlab
安装一个minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
不能是使用root直接启动,强制启动就行了,别忘了首先装好docker,不用docker driver的可以不装,具体不赘述了
minikube start --force
###网络还可以的话,很快就装好
###安装helm
>参考https://helm.sh/zh/docs/intro/install/
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
###添加gitlab chart仓库
helm search repo -l gitlab/gitlab-runner
helm repo add gitlab https://charts.gitlab.io
helm repo update gitlab
###拉取chart包
helm pull gitlab/gitlab-runner
###创建一个名称空间
kubectl create ns cicd
##去gitlab上copy一下gitlab-runner的token:SVCBg3u8ZzYTsyc792Q3配置到runnerRegistrationToken
###修改values.yaml按照你的需要修改
image:
  registry: registry.gitlab.com
  image: gitlab-org/gitlab-runner
replicas: 2
gitlabUrl: http://192.168.1.108
runnerRegistrationToken: "SVCBg3u8ZzYTsyc792Q3"
rbac:
  create: true
runners:
  config: |
    [[runners]]
      [runners.kubernetes]
        namespace = "{{.Release.Namespace}}"
        executor = "kubernetes"
        image = "alpine"
        privileged = true
  configPath: ""
  cache: {}
###
helm install --namespace cicd gitlab-runner -f values.yaml gitlab/gitlab-runner
###这就基本上可以了
###接下来就开始ci了, .gitlab-ci.yml配置未完待续