User Tools

Site Tools


инструмент_gitlab

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
инструмент_gitlab [2025/01/02 06:58]
val [Регистрация]
инструмент_gitlab [2025/03/18 09:14] (current)
val [Пример shell Kubernetes]
Line 31: Line 31:
  
   * [[https://​docs.gitlab.com/​ee/​install/​docker.html#​install-gitlab-using-docker-compose|Install GitLab using Docker Compose]]   * [[https://​docs.gitlab.com/​ee/​install/​docker.html#​install-gitlab-using-docker-compose|Install GitLab using Docker Compose]]
 +  * [[https://​hub.docker.com/​r/​gitlab/​gitlab-ce/​tags/​|gitlab/​gitlab-ce tags (versions)]]
 +
   * [[Технология Docker]]   * [[Технология Docker]]
   * [[Технология Docker#​docker-compose]]   * [[Технология Docker#​docker-compose]]
Line 50: Line 52:
         gitlab_rails['​registry_enabled'​] = true         gitlab_rails['​registry_enabled'​] = true
         gitlab_rails['​registry_host'​] = "​server.corpX.un"​         gitlab_rails['​registry_host'​] = "​server.corpX.un"​
-        ​external_url '​http://​server.corpX.un'​ +        external_url '​https://​server.corpX.un'​ 
-        registry_external_url '​http://​server.corpX.un'​ +        registry_external_url '​https://​server.corpX.un:​5000'​ 
-        gitlab_rails['​registry_port'​] = "​5000"​ +        gitlab_rails['​registry_port'​] = "​5050"​ 
-        registry['​registry_http_addr'​] = "​server.corpX.un:​5000"​ +        registry['​registry_http_addr'​] = "​server.corpX.un:​5050"​
-#        ​external_url '​https://​server.corpX.un'​ +
-       ​registry_external_url '​https://​server.corpX.un:​5000'​ +
-       ​gitlab_rails['​registry_port'​] = "​5050"​ +
-       ​registry['​registry_http_addr'​] = "​server.corpX.un:​5050"​+
     ports:     ports:
-      ​- '​80:​80'​ +      - '​443:​443'​
-#      ​- '​443:​443'​+
       - '​2222:​22'​       - '​2222:​22'​
       - '​5000:​5000'​       - '​5000:​5000'​
Line 73: Line 70:
         max-size: "​2048m"​         max-size: "​2048m"​
 </​code><​code>​ </​code><​code>​
-# ### cat /​etc/​gitlab/​ssl/​gitlab.bmstu.ru.{crt,​key} 
- 
 # docker-compose up -d # docker-compose up -d
  
Line 296: Line 291:
  
 или по инструкции в "New instance runner"​ или по инструкции в "New instance runner"​
 +<​code>​ 
 +# gitlab-runner register -n --executor "​shell"​ -u http://​server.corpX.un -t "​NNNNNNNNNNNNNNNNNNNNNNNNNNNN"​ 
 +</​code>​
 Перезапускать не нужно Перезапускать не нужно
  
Line 348: Line 345:
   --non-interactive \   --non-interactive \
   --url "​http://​server.corpX.un/"​ \   --url "​http://​server.corpX.un/"​ \
-  --registration-token "​NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"​ \+  --token "​NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"​ \
   --executor "​docker"​ \   --executor "​docker"​ \
   --docker-image "​docker:​stable"​ \   --docker-image "​docker:​stable"​ \
Line 365: Line 362:
 docker run --rm -v /​srv/​gitlab-runner/​config:/​etc/​gitlab-runner gitlab/​gitlab-runner register \ docker run --rm -v /​srv/​gitlab-runner/​config:/​etc/​gitlab-runner gitlab/​gitlab-runner register \
 ... ...
-  --url "​https://​server.corp20.un/" \+  --url "​https://​server.corpX.un/" \
   --tls-ca-file "/​etc/​gitlab-runner/​wild.crt"​ \   --tls-ca-file "/​etc/​gitlab-runner/​wild.crt"​ \
 ... ...
Line 540: Line 537:
 ==== Пример shell Kubernetes ==== ==== Пример shell Kubernetes ====
  
 +<​code>​
 +kube1:​~/​gowebd-k8s#​ cat .gitlab-ci.yml
 +</​code><​code>​
 +stages:
 +  - deploy
 +
 +#variables:
 +#  HELM_NAMESPACE:​ "​my-ns"​
 +
 +trigger-deploy:​
 +  stage: deploy
 +  rules:
 +    - if: '​$CI_PIPELINE_SOURCE == "​pipeline"​ && $VER'
 +  script:
 +    - env
 +    - envsubst < my-webd-deployment-env.yaml | kubectl apply -f - -n my-ns
 +#    - helm upgrade -i my-webd webd-chart/ --set=image.tag=$VER --create-namespace
 +  tags:
 +    - k8s-deploy
 +
 +manual-deploy:​
 +  stage: deploy
 +  when: manual
 +  variables:
 +    VER: "​$MY_WEBD_VER" ​ # New Pipeline or Settings->​CI/​CD->​Variables
 +  script:
 +    - env
 +    - envsubst < my-webd-deployment-env.yaml | kubectl apply -f - -n my-ns
 +#    - helm upgrade -i my-webd webd-chart/ --set=image.tag=$VER --create-namespace
 +  tags:
 +    - k8s-deploy
 +</​code>​
 +
 +== старый вариант ==
 <​code>​ <​code>​
 gitlab-runner@server:​~/​webd$ cp my-webd-deployment.yaml my-webd-deployment-env.yaml gitlab-runner@server:​~/​webd$ cp my-webd-deployment.yaml my-webd-deployment-env.yaml
Line 626: Line 657:
     - docker push $CI_REGISTRY_IMAGE:​$CI_COMMIT_SHA     - docker push $CI_REGISTRY_IMAGE:​$CI_COMMIT_SHA
  
-#    - echo "​{\"​auths\":​{\"​${CI_REGISTRY}\":​{\"​auth\":​\"​$(printf "​%s:​%s"​ "​${CI_REGISTRY_USER}"​ "​${CI_REGISTRY_PASSWORD}" | base64 | tr -d '​\n'​)\"​},​\"​$CI_DEPENDENCY_PROXY_SERVER\":​{\"​auth\":​\"​$(printf "​%s:​%s"​ ${CI_DEPENDENCY_PROXY_USER} "​${CI_DEPENDENCY_PROXY_PASSWORD}" | base64 | tr -d '​\n'​)\"​}}}"​ > /​kaniko/​.docker/​config.json+#    - echo "​{\"​auths\":​{\"​${CI_REGISTRY}\":​{\"​auth\":​\"​$(printf "​%s:​%s"​ "​${CI_REGISTRY_USER}"​ "​${CI_REGISTRY_PASSWORD}"​ | base64 | tr -d '​\n'​)\"​}}}"​ > /​kaniko/​.docker/​config.json
 #    - /​kaniko/​executor #    - /​kaniko/​executor
 #      --insecure --skip-tls-verify #      --insecure --skip-tls-verify
Line 632: Line 663:
 #      --dockerfile "​${CI_PROJECT_DIR}/​Dockerfile"​ #      --dockerfile "​${CI_PROJECT_DIR}/​Dockerfile"​
 #      --destination "​${CI_REGISTRY_IMAGE}:​${CI_COMMIT_SHA}"​ #      --destination "​${CI_REGISTRY_IMAGE}:​${CI_COMMIT_SHA}"​
 +
 +#  except:
 +#    - tags
 +#  tags:
 +#    - build
  
 Push latest: Push latest:
Line 649: Line 685:
 #    - crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY #    - crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
 #    - crane --insecure cp $CI_REGISTRY_IMAGE:​$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:​latest #    - crane --insecure cp $CI_REGISTRY_IMAGE:​$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:​latest
 +#  tags:
 +#    - build
  
 Push tag: Push tag:
Line 666: Line 704:
 #   - crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY #   - crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
 #   - crane --insecure cp $CI_REGISTRY_IMAGE:​$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:​$CI_COMMIT_REF_NAME #   - crane --insecure cp $CI_REGISTRY_IMAGE:​$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:​$CI_COMMIT_REF_NAME
 +#  tags:
 +#    - build
  
 +### Not work in DooD
 #Lint test: #Lint test:
 #  stage: lint #  stage: lint
 #  script: #  script:
 +#    - pwd
 #    - docker run --rm -v $(pwd):/app -w /app golangci/​golangci-lint:​v1.62.2 golangci-lint run --timeout=10m #    - docker run --rm -v $(pwd):/app -w /app golangci/​golangci-lint:​v1.62.2 golangci-lint run --timeout=10m
 +#  except:
 +#    - tags
  
 #Smoke test: #Smoke test:
Line 679: Line 723:
 #    - docker run --rm alpine/curl -sS $MY_IP #    - docker run --rm alpine/curl -sS $MY_IP
 #    - docker stop $MY_ID #    - docker stop $MY_ID
 +#  except:
 +#    - tags
 +
  
 #Deploy: #Deploy:
инструмент_gitlab.1735790334.txt.gz · Last modified: 2025/01/02 06:58 by val