Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Concourse. CI с кубиками и на чистом YAML

DevOps Moscow
November 21, 2018

Concourse. CI с кубиками и на чистом YAML

Митап на тему "CI/CD", 21-11-2018
Максим Залысин (Devino Telecom)

CI систем сегодня не сосчитать — пальцев точно не хватит. Есть очень популярные, всегда на слуху, UI которых способен запутать в беготне по вкладкам. По ним написано не мало cookbook’ов, но сложности все равно возникают. Есть совсем простые — конфиг в проекте с несколькими строчками, и готово. И среди всех этих систем выделяется Concourse CI, с необычным UI и pipeline’ами на YAML.
В докладе я познакомлю с Concourse CI, расскажу, как готовятся pipeline’ы в Devino Telecom и какие планы по развитию CI, а также про недостатки которые не получилось устранить, и с которыми приходится мириться.

DevOps Moscow

November 21, 2018
Tweet

More Decks by DevOps Moscow

Other Decks in Education

Transcript

  1. 2

  2. 3

  3. 4 О чем доклад? • Как устроен Concourse CI •

    Для чего CLI-утилита fly? • Что делает Concourse CI в Devino Telecom? • Что такое pipeline в Concourse? • Для чего resource? • Что происходит в job`е?
  4. 5

  5. 6

  6. 10 TSA transportation security administration Secure Worker Registration fly ATC

    air traffic control Web UI, API, Pipeline Scheduler
  7. 11 TSA transportation security administration Secure Worker Registration fly ATC

    air traffic control Web UI, API, Pipeline Scheduler
  8. 12 Для чего CLI-утилита fly? Управление team`ами $ fly -t

    main set-team --team-name=develop --ldap-group=… Управление pipeline`ами $ fly -t develop --pipeline=HELLO-WORLD --config=pipelines/hello-world.yml Тестирование task`ов $ fly -t develop execute --config=ci/build.yml --input=source=./ Отладка работающего task`а $ fly -t develop hijack --job=HELLO-WORLD/hello-world_build …
  9. 14 • Unit-test • CheckStyle • SpotBugs • PMD •

    Build • Autotests • … TEST Pull Request Status Comment
  10. 15 • Unit-test • CheckStyle • SpotBugs • PMD •

    Build • Autotests • … TEST Pull Request Status Comment Review, Merge, Tag TEST • Unit-test • CheckStyle • SpotBugs • PMD • Build • Autotests • …
  11. 16 • Unit-test • CheckStyle • SpotBugs • PMD •

    Build • Autotests • … • Get Dependencies • Compile • Pack TEST Pull Request Status Comment Review, Merge, Tag BUILD TEST N otify Project Channel Build & Push • Unit-test • CheckStyle • SpotBugs • PMD • Build • Autotests • …
  12. 17 • Unit-test • CheckStyle • SpotBugs • PMD •

    Build • Autotests • … • Get Dependencies • Compile • Pack TEST Pull Request Status Comment Review, Merge, Tag BUILD Build & Push TEST • Prepare DEPLOY IN TEST N otify Edit Manifest Project Channel Deploy Notify TEST • Unit-test • CheckStyle • SpotBugs • PMD • Build • Autotests • …
  13. 18 • Unit-test • CheckStyle • SpotBugs • PMD •

    Build • Autotests • … • Get Dependencies • Compile • Pack TEST Pull Request Status Comment Review, Merge, Tag BUILD TEST • Prepare DEPLOY IN TEST N otify Edit Manifest Project Channel Deploy Notify TEST PRODUCTION • Prepare DEPLOY IN PROD Deploy Deploy Channel N otify Edit Manifest Build & Push • Unit-test • CheckStyle • SpotBugs • PMD • Build • Autotests • …
  14. 19 • Unit-test • CheckStyle • SpotBugs • PMD •

    Build • Autotests • … • Get Dependencies • Compile • Pack TEST Pull Request Status Comment Review, Merge, Tag BUILD • Unit-test • CheckStyle • SpotBugs • PMD • Build • Autotests • … TEST • Prepare DEPLOY IN TEST N otify Edit Manifest Project Channel Deploy Notify TEST PRODUCTION • Prepare DEPLOY IN PROD Deploy Deploy Channel N otify Edit Manifest Get Task Close Task Get Task Close Task Build & Push
  15. 27 Concourse CI v4.x.x - Resource resources: - name: hello-world

    type: git source: uri: ssh://[email protected]/ex/hello-world.git private_key: {{bitbucket-private-key}} branch: master tag_filter: v*
  16. 28 Concourse CI v4.x.x - Resource resources: - name: hello-world

    type: git source: uri: ssh://[email protected]/ex/hello-world.git private_key: {{bitbucket-private-key}} branch: master tag_filter: v*
  17. 29 Concourse CI v4.x.x - Resource resources: - name: hello-world

    type: git source: uri: ssh://[email protected]/ex/hello-world.git private_key: {{bitbucket-private-key}} branch: master tag_filter: v*
  18. 30 Concourse CI v4.x.x - Resource resources: - name: hello-world

    type: git source: uri: ssh://[email protected]/ex/hello-world.git private_key: | -----BEGIN EC PRIVATE KEY----- ... -----END EC PRIVATE KEY----- branch: master tag_filter: v*
  19. 32 Concourse CI v4.x.x - Resource (community) resource_types: - name:

    bitbucket-pullrequest type: docker-image source: {repository: laurentverbruggen/concourse-bitbucket-pullrequest-resource} resources: - name: hello-world-pullrequest type: bitbucket-pullrequest source: uri: https://git.example.com/scm/ex/hello-world.git username: {{bitbucket-username}} password: {{bitbucket-password}} only_for_branch: master only_without_conflicts: true rebuild_when_target_changed: true
  20. 33 Concourse CI v4.x.x - Resource (community) resource_types: - name:

    bitbucket-pullrequest type: docker-image source: {repository: laurentverbruggen/concourse-bitbucket-pullrequest-resource} resources: - name: hello-world-pullrequest type: bitbucket-pullrequest source: uri: https://git.example.com/scm/ex/hello-world.git username: {{bitbucket-username}} password: {{bitbucket-password}} only_for_branch: master only_without_conflicts: true rebuild_when_target_changed: true
  21. 34 Concourse CI v4.x.x - Resource (community) resource_types: - name:

    bitbucket-pullrequest type: docker-image source: {repository: laurentverbruggen/concourse-bitbucket-pullrequest-resource} resources: - name: hello-world-pullrequest type: bitbucket-pullrequest source: uri: https://git.example.com/scm/ex/hello-world.git username: {{bitbucket-username}} password: {{bitbucket-password}} only_for_branch: master only_without_conflicts: true rebuild_when_target_changed: true
  22. 35 Concourse CI v4.x.x - Resource (community) resource_types: - name:

    bitbucket-pullrequest type: docker-image source: {repository: laurentverbruggen/concourse-bitbucket-pullrequest-resource} resources: - name: hello-world-pullrequest type: bitbucket-pullrequest source: uri: https://git.example.com/scm/ex/hello-world.git username: {{bitbucket-username}} password: {{bitbucket-password}} only_for_branch: master only_without_conflicts: true rebuild_when_target_changed: true
  23. 36 Concourse CI v4.x.x - Resource (community) resource_types: - name:

    bitbucket-pullrequest type: docker-image source: {repository: laurentverbruggen/concourse-bitbucket-pullrequest-resource} resources: - name: hello-world-pullrequest type: bitbucket-pullrequest source: uri: https://git.example.com/scm/ex/hello-world.git username: {{bitbucket-username}} password: {{bitbucket-password}} only_for_branch: master only_without_conflicts: true rebuild_when_target_changed: true
  24. 37 Concourse CI v4.x.x - Resource (community) resource_types: - name:

    bitbucket-pullrequest type: docker-image source: {repository: laurentverbruggen/concourse-bitbucket-pullrequest-resource} resources: - name: hello-world-pullrequest type: bitbucket-pullrequest source: uri: https://git.example.com/scm/ex/hello-world.git username: concourse password: #sEcrEt_pAss-&1 only_for_branch: master only_without_conflicts: true rebuild_when_target_changed: true
  25. 40 Concourse CI v4.x.x - Resource Types Provided With Concourse

    Community https://concourse-ci.org/community-resources.html
  26. 41 Concourse CI v4.x.x - Resource (community) $ docker run

    --rm --entrypoint ls devinotelecom/concourse-slack-alert-resource -l /opt/resource total 19340 -rwxr-xr-x 1 root root 6451874 Nov 1 09:57 check -rwxr-xr-x 1 root root 6452080 Nov 1 09:57 in -rwxr-xr-x 1 root root 6879238 Nov 1 09:57 out https://concourse-ci.org/implementing-resources.html
  27. 44 Concourse CI v4.x.x - Job "*_build" jobs: - name:

    hello-world_build plan: - get: hello-world passed: ["hello-world_test"] trigger: true - task: build file: hello-world/ci/build.yml input_mapping: {source: hello-world} - put: hello-world-docker params: {build: docker, tag: docker/version, tag_as_latest: true} on_failure: put: slack params: {alert_type: failed, message: "Build FAILED"} on_success: put: slack params: {alert_type: success, message: "Build SUCCESS"}
  28. 45 Concourse CI v4.x.x - Job "*_build" jobs: - name:

    hello-world_build plan: - get: hello-world passed: ["hello-world_test"] trigger: true - task: build file: hello-world/ci/build.yml input_mapping: {source: hello-world} - put: hello-world-docker params: {build: docker, tag: docker/version, tag_as_latest: true} on_failure: put: slack params: {alert_type: failed, message: "Build FAILED"} on_success: put: slack params: {alert_type: success, message: "Build SUCCESS"}
  29. 46 Concourse CI v4.x.x - Job "*_build" jobs: - name:

    hello-world_build plan: - get: hello-world passed: ["hello-world_test"] trigger: true - task: build file: hello-world/ci/build.yml input_mapping: {source: hello-world} - put: hello-world-docker params: {build: docker, tag: docker/version, tag_as_latest: true} on_failure: put: slack params: {alert_type: failed, message: "Build FAILED"} on_success: put: slack params: {alert_type: success, message: "Build SUCCESS"}
  30. 47 Concourse CI v4.x.x - Job "*_build" jobs: - name:

    hello-world_build plan: - get: hello-world passed: ["hello-world_test"] trigger: true - task: build file: hello-world/ci/build.yml input_mapping: {source: hello-world} - put: hello-world-docker params: {build: docker, tag: docker/version, tag_as_latest: true} on_failure: put: slack params: {alert_type: failed, message: "Build FAILED"} on_success: put: slack params: {alert_type: success, message: "Build SUCCESS"}
  31. 48 Concourse CI v4.x.x - Task ci/build.yml platform: linux image_resource:

    type: docker-image source: {repository: gradle, tag: 4.10.2-jdk8-alpine} inputs: - name: source outputs: - name: docker caches: - path: source/.gradle/caches run: dir: source user: root path: sh args: - -exc - | gradle --gradle-user-home=.gradle build cp build/libs/source.jar ../docker/application.jar cp ci/Dockerfile > ../docker/Dockerfile apk add --no-cache --no-progress git git describe --tags | sed 's/^v//' > ../docker/version
  32. 50 Concourse CI v4.x.x - Job "*-pullrequest_test" jobs: - name:

    hello-world-pullrequest_test plan: - get: hello-world-pullrequest trigger: true - aggregate: - task: unit file: hello-world-pullrequest/ci/unit.yml input_mapping: {source: hello-world-pullrequest} - task: checkstyle file: hello-world-pullrequest/ci/checkstyle.yml input_mapping: {source: hello-world-pullrequest} on_failure: put: hello-world-pullrequest params: {path: hello-world-pullrequestt, status: failure} on_success: put: hello-world-pullrequest params: {path: hello-world-pullrequest, status: success}
  33. 51 Concourse CI v4.x.x - Job "*-pullrequest_test" jobs: - name:

    hello-world-pullrequest_test plan: - get: hello-world-pullrequest trigger: true - aggregate: - task: unit file: hello-world-pullrequest/ci/unit.yml input_mapping: {source: hello-world-pullrequest} - task: checkstyle file: hello-world-pullrequest/ci/checkstyle.yml input_mapping: {source: hello-world-pullrequest} on_failure: put: hello-world-pullrequest params: {path: hello-world-pullrequestt, status: failure} on_success: put: hello-world-pullrequest params: {path: hello-world-pullrequest, status: success}
  34. 52 Concourse CI v4.x.x - Job "*-pullrequest_test" jobs: - name:

    hello-world-pullrequest_test plan: - get: hello-world-pullrequest trigger: true - aggregate: - task: unit file: hello-world-pullrequest/ci/unit.yml input_mapping: {source: hello-world-pullrequest} - task: checkstyle file: hello-world-pullrequest/ci/checkstyle.yml input_mapping: {source: hello-world-pullrequest} on_failure: put: hello-world-pullrequest params: {path: hello-world-pullrequestt, status: failure} on_success: put: hello-world-pullrequest params: {path: hello-world-pullrequest, status: success}
  35. 53 Concourse CI v4.x.x - Job "*-pullrequest_test" jobs: - name:

    hello-world-pullrequest_test plan: - get: hello-world-pullrequest trigger: true - aggregate: - task: unit file: hello-world-pullrequest/ci/unit.yml input_mapping: {source: hello-world-pullrequest} - task: checkstyle file: hello-world-pullrequest/ci/checkstyle.yml input_mapping: {source: hello-world-pullrequest} on_failure: put: hello-world-pullrequest params: {path: hello-world-pullrequestt, status: failure} on_success: put: hello-world-pullrequest params: {path: hello-world-pullrequest, status: success}
  36. 54 Преимущества! • YAML - удобно, структурировано • CLI для

    управления CI`кой • Интеграция с чем угодно через resource • Просто написать свой resource • Job одновременно выполняет множество task`ов в связке с разными resource`ами • Переиспользуемые файлы task`ов
  37. 55 Недостатки? • Требовательность к ресурсам • Бывает, worker залипает

    • Сложно повторно запустить job на устаревшем ресурсе • Нет разделения доступа по ролям в одной team`е