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

GitHub Actions Runner 빌드 실전 적용기

kakao
PRO
December 08, 2022

GitHub Actions Runner 빌드 실전 적용기

#GithubActions #ArgoCD #CI/CD #KIC #Docker #Container

GitHub Actions Runner를 카카오엔터프라이즈 환경에 맞춰 적용하며 발생했던 이슈들과 그에 따른 Runner 환경 개선 사항들에 대해서
소개하고자 합니다.

발표자 : miguel.lee
카카오엔터프라이즈 기슬플랫폼팀 미겔입니다. 전사공통 DevOps 체계를 만들고 있습니다.

kakao
PRO

December 08, 2022
Tweet

More Decks by kakao

Other Decks in Programming

Transcript

  1. ੉୍࢚ miguel.lee
    ஠஠য়ূఠ೐ۄ੉ૉ
    GitHub Actions Runner
    ࠽٘ प੹ ੸ਊӝ
    if(kakao)2022
    Copyright 2022. Kakao Corp. All rights reserved. Redistribution or public display is not permitted without written permission from Kakao.

    View Slide

  2. GitHub ੉ҙҗ ׮নೠ ജ҃
    GitHub Actions ӒܻҊ GitHub Actions Runner
    Docker in Docker vs Docker Out of Docker
    exit code 137
    GitHub Custom Actions ҳഅ
    ೱറ ҅ദ

    View Slide

  3. GitHub ੉ҙ
    ୨ ੉ҙ ؘ੉ఠ ௼ӝ : 185 GB
    ୨ ੉ҙ Org ѐࣻ : 172 ѐ
    ୨ ੉ҙ Repo ѐࣻ : 6,384 ѐ

    View Slide

  4. ஠஠য়ਕ௼
    kakaowork
    ஠஠য় i ௿ۄ਋٘
    kakao i cloud
    ஠஠য় i ۄझ
    kakao i LaaS
    ஠஠য় i ழ֏౟ ࣃఠ
    kakao i connect Center
    ஠஠য় i ழ֏౟ స
    kakao i connect Talk
    ஠஠য় i ழ֏౟ ࠺ૉݫࣁ૑
    kakao i connect Biz Message
    ஠஠য় i ழ֏౟ ۄ੉࠳
    kakao i connect Live
    ׮নೠ ജ҃

    View Slide

  5. ׮নೠ CI/CD بҳٜ

    View Slide

  6. ೠ о૑ CI/CD بҳ݅ ࢎਊೡ ࣻח হਸө?

    View Slide

  7. GitHub ੉ҙҗ ׮নೠ ജ҃
    GitHub Actions ӒܻҊ GitHub Actions Runner
    Docker in Docker vs Docker Out of Docker
    exit code 137
    GitHub Custom Actions ҳഅ
    Wrap up ߂ ೱറ ҅ദ

    View Slide

  8. GitHub Actions

    View Slide

  9. GitHub
    Events
    GitHub Actions ࠽٘ ߑध
    GitHub
    Actions
    Runner

    View Slide

  10. Triggering
    GitHub
    Events
    GitHub Actions ࠽٘ ߑध
    GitHub
    Actions
    Runner

    View Slide

  11. GitHub
    Events
    Workflows
    GitHub Actions ࠽٘ ߑध
    GitHub Actions Runner
    Workflows ೡ׼

    View Slide

  12. GitHub
    Events
    Workflows
    Jobs
    Steps
    GitHub Actions ࠽٘ ߑध
    Workflows ೡ׼
    GitHub Actions Runner

    View Slide

  13. GitHub Actions Runner

    View Slide

  14. MacOS Linux Windows
    GitHub Actions Runner
    Provisioning
    GitHub Actions Runner

    View Slide

  15. Provisioning
    Linux Windows
    MacOS
    GitHub Actions Runner
    GitHub Actions Runner

    View Slide

  16. Windows
    Virtual Machine
    Docker
    Linux
    MacOS
    GitHub Actions Runner
    VM or Docker
    GitHub Actions Runner

    View Slide

  17. Windows
    Virtual Machine
    Docker
    Linux
    MacOS
    GitHub Actions Runner
    VM or Docker
    GitHub Actions Runner
    - п Workflow ݃׮ زੌೠ ജ҃ ࠁ੢

    View Slide

  18. Virtual Machine
    Docker
    GitHub Actions Runner
    - п Workflow ݃׮ زੌೠ ജ҃ ࠁ੢
    - ࠽٘ द ܻࣗझ ಩ૐ ઁয
    Linux
    MacOS
    GitHub Actions Runner
    VM or Docker
    Windows

    View Slide

  19. Virtual Machine
    Docker
    GitHub Actions Runner
    - п Workflow ݃׮ زੌೠ ജ҃ ࠁ੢
    - ࠽٘ द ܻࣗझ ಩ૐ ઁয
    - ೙ਃী ٮۄ ۞ց झாੌ݂ оמ೧ঠ ೣ
    Linux
    MacOS
    GitHub Actions Runner
    VM or Docker
    Windows

    View Slide

  20. Docker
    Linux
    MacOS
    Virtual Machine
    GitHub Actions Runner
    Runner in Docker
    GitHub Actions Runner
    Windows

    View Slide

  21. Docker
    GitHub Actions Runner
    Linux
    MacOS
    Virtual Machine
    kakao i cloud
    GitHub Actions Runner
    Runner in Docker
    Windows

    View Slide

  22. Runner in Docker
    GitHub Actions Runner
    Docker
    GitHub Actions Runner
    Linux
    MacOS
    Virtual Machine
    kakao i cloud
    Windows

    View Slide

  23. GitHub ੉ҙҗ ׮নೠ ജ҃
    GitHub Actions ӒܻҊ GitHub Actions Runner
    Docker in Docker vs Docker Out of Docker
    exit code 137
    GitHub Custom Actions ҳഅ
    ೱറ ҅ദ

    View Slide

  24. GitHub
    Events
    Workflows
    Jobs
    Steps
    Docker in Docker vs Docker Out of Docker
    ੌ߈੸ੋ Workflow
    GitHub Actions Runner

    View Slide

  25. GitHub
    Events
    Docker in Docker vs Docker Out of Docker
    Containers in Workflows
    Workflows
    Jobs
    Steps
    GitHub Actions Runner

    View Slide

  26. jobs:
    build-and-test:
    runs-on: k8s
    container:
    image: [IMAGE]
    services:
    redis:
    image: [REDIS_IMAGE]
    ports:
    - 6379
    Docker in Docker vs Docker Out of Docker
    Containers in Workflows

    View Slide

  27. jobs:
    build-and-test:
    runs-on: k8s
    container:
    image: [IMAGE]
    services:
    redis:
    image: [REDIS_IMAGE]
    ports:
    - 6379
    Docker in Docker vs Docker Out of Docker
    Containers in Workflows
    container:
    image: [IMAGE]

    View Slide

  28. Docker in Docker vs Docker Out of Docker
    Containers in Workflows
    jobs:
    build-and-test:
    runs-on: k8s
    container:
    image: [IMAGE]
    services:
    redis:
    image: [REDIS_IMAGE]
    ports:
    - 6379
    services:
    redis:
    image: [REDIS_IMAGE]
    ports:
    - 6379

    View Slide

  29. Docker in Docker vs Docker Out of Docker
    Containers in Workflows
    jobs:
    build-and-test:
    runs-on: k8s
    container:
    image: [IMAGE]
    services:
    redis:
    image: [REDIS_IMAGE]
    ports:
    - 6379

    View Slide

  30. Docker in Docker vs Docker Out of Docker
    Containers in Workflows
    jobs:
    build-and-test:
    runs-on: k8s
    container:
    image: [IMAGE]
    services:
    redis:
    image: [REDIS_IMAGE]
    ports:
    - 6379

    View Slide

  31. Docker in Docker
    Docker in Docker vs Docker Out of Docker
    Docker Host
    Create
    Runner Container
    Job Container Job Container
    %PDLFS
    Create
    Create
    (JU)VC"DUJPOT3VOOFS

    View Slide

  32. Docker in Docker vs Docker Out of Docker
    ੌ߈੸ੋ ਕ௼೒۽਋ ೡ׼
    Docker Host
    Create
    Runner Container
    %PDLFS Workflows
    Jobs
    Steps
    File System
    Mount
    (JU)VC
    "DUJPOT
    3VOOFS

    View Slide

  33. Docker in Docker vs Docker Out of Docker
    ஶప੉ցо ҳزغח ਕ௼೒۽਋ ೡ׼
    Docker Host
    Create
    Runner Container
    Job Container1
    %PDLFS Workflows
    Jobs
    Steps
    Job Container2
    Create
    Create
    File System
    Mount ???
    (JU)VC
    "DUJPOT
    3VOOFS

    View Slide

  34. var initProcessCgroup = File.ReadLines(“/proc/1/cgroup”);
    if (initProcessCgroup.Any{x => x.IndexOf(“:/docker/”,
    StringComparison.OrdinalIgnoreCase) >= 0})
    {
    throw new NotSupportedException(“Container feature is not supported when
    runner is already running inside container.”);
    }
    Docker in Docker vs Docker Out of Docker
    Early container in GitHub Actions Runner

    View Slide

  35. Docker in Docker vs Docker Out of Docker
    Early container in GitHub Actions Runner
    var initProcessCgroup = File.ReadLines(“/proc/1/cgroup”);
    if (initProcessCgroup.Any{x => x.IndexOf(“:/docker/”,
    StringComparison.OrdinalIgnoreCase) >= 0})
    {
    throw new NotSupportedException(“Container feature is not supported when
    runner is already running inside container.”);
    }
    Docker in docker
    ૑ਗೞ૑ ঋ਺

    View Slide

  36. Docker in Docker vs Docker Out of Docker
    Docker Out of Docker
    Docker Host
    Create
    Create
    Runner Container
    %PDLFS
    Mount
    Job Container Job Container
    Create Create
    (JU)VC"DUJPOT3VOOFS

    View Slide

  37. Docker in Docker vs Docker Out of Docker
    Docker Host
    3VOOFS
    Create
    Runner Container
    Job Container
    %PDLFS
    Create
    Create
    DinD (Docker in Docker)
    Docker Host
    3VOOFS
    Create
    Create
    Runner Container
    %PDLFS
    Mount
    Job Container
    Create
    DooD (Docker out of Docker)

    View Slide

  38. GitHub ੉ҙҗ ׮নೠ ജ҃
    GitHub Actions ӒܻҊ GitHub Actions Runner
    Docker in Docker vs Docker Out of Docker
    exit code 137
    GitHub Custom Actions ҳഅ
    ೱറ ҅ദ

    View Slide

  39. Workflows
    SIGTERM SIGKILL Workflows
    exit code 137
    exit code 137

    View Slide

  40. Docker Host
    Create
    Create
    Runner Container
    %PDLFS
    Mount
    Job Container1 Job Container2
    Create Create
    exit code 137
    2ѐ੄ Job Container प೯
    प೯઺
    प೯઺
    (JU)VC"DUJPOT3VOOFS

    View Slide

  41. jobs:
    build-and-test:
    runs-on: k8s
    container:
    image: [IMAGE]
    services:
    redis:
    image: [REDIS_IMAGE]
    ports:
    - 6379
    exit code 137
    Clean up

    View Slide

  42. public override void Initialize(IHostContext hostContext)
    {

    _binPath = HostContext.GetDirectory(WellKnownDirectory.Bin);
    Trace.Info(“binPath: {0}”, _binPath);
    RootFolder = HostContext.GetDirectory(WellKnownDirectory.Root);
    Trace.Info(“RootFolder: {0}”, _RootFolder);

    }
    exit code 137
    initialize runner

    View Slide

  43. public class DockerCommandManager : RunnerService, IDockCommandManager
    {

    public override void Initialize(IHostContext hostContext)
    {
    base.Initialize(hostContext);
    DockerPath = WhichUtil.Which(“docker”, true, Trace);
    DockerInstanceLabel =
    IOUtil.GetSha256Hash(hostContext.GetDirectory(WellKnownDirectory.Root)).S
    ubstring(0, 6);
    }
    }
    exit code 137
    DockerCommandManager - Initialize
    DockerInstanceLabel =
    IOUtil.GetSha256Hash(hostContext.GetDirectory(WellKnownDirectory.Root)).S
    ubstring(0, 6);

    View Slide

  44. exit code 137
    زੌೠ بழ ੋझఢझ ۨ੉࠶
    Docker Host
    Create
    Create
    Runner Container
    %PDLFS
    Mount
    Job Container1 Job Container2
    Create Create
    प೯઺
    प೯઺
    label=60e226
    (JU)VC"DUJPOT3VOOFS

    View Slide

  45. exit code 137
    Clean up
    Docker Host
    Create
    Create
    Runner Container
    %PDLFS
    Mount
    Job Container1 Job Container2
    Create Create
    प೯઺
    प೯઺
    label=60e226
    (JU)VC"DUJPOT3VOOFS

    View Slide

  46. Docker Host
    Create
    Create
    Runner Container
    %PDLFS
    Mount
    Job Container1 Job Container2
    Create Create
    प೯઺
    label=60e226
    exit code 137
    ஶప੉ց ъઁ ઙܐ ߊࢤ
    ъઁઙܐ
    (JU)VC"DUJPOT3VOOFS

    View Slide

  47. exit code 137
    ۽Ӓ୹۱

    View Slide

  48. Docker Host
    Create
    Create
    Runner Container
    %PDLFS
    Mount
    Job Container1 Job Container2
    Create Create
    प೯઺
    प೯઺
    unique_pod_name
    exit code 137
    RUNNER_BINDIR ч ߸҃
    RUNNER_BINDIR = RUNNER_BINDIR =
    unique_pod_name
    (JU)VC"DUJPOT3VOOFS

    View Slide

  49. Docker Host
    Create
    Create
    Runner Container
    %PDLFS
    Mount
    Job Container1 Job Container2
    Create Create
    प೯઺
    प೯઺
    fd26bd
    exit code 137
    RUNNER_BINDIR ч ߸҃
    RUNNER_BINDIR = RUNNER_BINDIR =
    0cab5a
    (JU)VC"DUJPOT3VOOFS

    View Slide

  50. GitHub ੉ҙҗ ׮নೠ ജ҃
    GitHub Actions ӒܻҊ GitHub Actions Runner
    Docker in Docker vs Docker Out of Docker
    exit code 137
    GitHub Custom Actions ҳഅ
    ೱറ ҅ദ

    View Slide

  51. Workflow A
    25࠙
    GitHub Custom Actions ҳഅ
    ঘ࣌ ۞ց ࠽٘

    View Slide

  52. Workflow A
    25࠙
    GitHub Custom Actions ҳഅ
    ঘ࣌ ۞ց ࠽٘

    View Slide

  53. Workflow A
    25࠙
    GitHub Custom Actions ҳഅ
    ঘ࣌ ۞ց ࠽٘

    View Slide

  54. ࠽٘ दрਸ ѐࢶೡ ࣻ হਸө?

    View Slide

  55. GitHub Custom Actions ҳഅ
    GitHub Enterprise <3.5

    View Slide

  56. 2022.1ਘ
    GitHub Actions بੑ
    GitHub 3.3.x ߡ੹
    2202.8ਘ
    GitHub 3.6-RC Release
    2022.8ਘ
    GitHub 3.5.3 Upgrade
    9ਘ
    kep-actions/cache ҳഅ
    GitHub Custom Actions ҳഅ
    ߡ੹ ఋ੐ۄੋ

    View Slide

  57. Workflow A
    jobs:
    [JOB_NAME]:
    steps:
    - name: Gradle cache
    uses: kep-actions/cache@v1
    id: cache
    with:
    path: |
    ~/.gradle/caches
    GitHub Custom Actions ҳഅ
    kep-actions/cache

    View Slide

  58. 2. ࠽٘நद ؘ੉ఠ ੷੢
    3. ؘ੉ఠ ࠂਗ
    1. ૑੿ػ ঘ࣌ ࢎਊ
    4. ࠽٘ ࣘب ѐࢶ
    GitHub Custom Actions ҳഅ
    kep-actions/cache
    object
    storage
    2. ࠽٘நद ؘ੉ఠ ੷੢
    kakao i cloud
    File
    Storage
    minio
    GitHub
    Enterprise
    Workflow A

    View Slide

  59. Workflow A
    5࠙
    kep-
    actions/
    cache
    GitHub Custom Actions ҳഅ
    kep-actions/cache
    object
    storage
    kakao i cloud
    File
    Storage
    minio
    GitHub
    Enterprise

    View Slide

  60. GitHub ੉ҙҗ ׮নೠ ജ҃
    GitHub Actions ӒܻҊ GitHub Actions Runner
    Docker in Docker vs Docker Out of Docker
    exit code 137
    GitHub Custom Actions ҳഅ
    ೱറ ҅ദ

    View Slide

  61. ೱറ ҅ദ
    - Runner য়షझாੌ݂ ҳഅ
    - ࠽٘ ؀एࠁ٘ ҳഅ
    - CI ࠽٘दझమ ѐߊ

    View Slide

  62. хࢎ೤פ׮.

    View Slide