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 Both sides next revision
инструмент_gitlab [2022/07/13 08:52]
val [GitLab CI/CD]
инструмент_gitlab [2022/07/13 08:58]
val [Пример docker]
Line 175: Line 175:
     - echo $(date) "Do your deploy here" >> /​tmp/​Bash.gitlab-ci.log     - echo $(date) "Do your deploy here" >> /​tmp/​Bash.gitlab-ci.log
     - docker-compose up -d     - docker-compose up -d
 +  tags:
 +    - webddeploy
 +</​code>​
 +
 +==== Пример Kubernetes ====
 +<​code>​
 +gitlab-runner@gate:​~/​webd$ cat build.sh
 +</​code><​code>​
 +#!/bin/sh
 +
 +VER="​$(echo $CI_COMMIT_MESSAGE | sed '​s/​[^a-zA-Z0-9\.]//​g'​)"​
 +
 +docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD http://​$CI_REGISTRY
 +docker build -t $CI_REGISTRY/​$CI_REGISTRY_IMAGE:​$VER webd
 +docker push $CI_REGISTRY/​$CI_REGISTRY_IMAGE:​$VER
 +</​code><​code>​
 +gitlab-runner@gate:​~/​webd$ cat my-webd-deployment-env.yaml
 +</​code><​code>​
 +...
 +        image: server.corp13.un:​5000/​student/​webd:​$VER
 +</​code><​code>​
 +gitlab-runner@gate:​~/​webd$ cat deploy.sh
 +</​code><​code>​
 +#!/bin/sh
 +
 +export VER="​$(echo $CI_COMMIT_MESSAGE | sed '​s/​[^a-zA-Z0-9\.]//​g'​)"​
 +
 +#envsubst < my-webd-deployment-env.yaml | kubectl apply -f -
 +#kubectl apply -f my-webd-service.yaml,​my-webd-ingress.yaml
 +
 +#export HELM_NAMESPACE=my-ns
 +#helm test my-webd && helm upgrade my-webd webd-chart/ --set=image.tag=$VER || helm install my-webd webd-chart/ --set=image.tag=$VER
 +</​code><​code>​
 +gitlab-runner@gate:​~/​webd$ cat .gitlab-ci.yml
 +stages:
 +  - lintertest
 +  - build
 +  - deploy
 +
 +lintertest1:​
 +  stage: lintertest
 +  script:
 +    - echo $(date) "Do a test here" >> /​tmp/​Bash.gitlab-ci.log
 +    - shellcheck webd/webd
 +  tags:
 +    - shellcheck
 +
 +build1:
 +  stage: build
 +  script:
 +    - echo $(date) "Do a build here" >> /​tmp/​Bash.gitlab-ci.log
 +    - ./build.sh
 +  tags:
 +    - webddeploy
 +
 +deploy1:
 +  stage: deploy
 +  script:
 +    - echo $(date) "Do your deploy k8s here" >> /​tmp/​Bash.gitlab-ci.log
 +    - ./deploy.sh
   tags:   tags:
     - webddeploy     - webddeploy
инструмент_gitlab.txt · Last modified: 2024/05/08 10:38 by val