๋กœ์ผ“๐Ÿพ
article thumbnail

 

 

์ค‘์š”!!
ARC ๊ฐ€ Github Official ํ”„๋กœ์ ํŠธ๊ฐ€ ๋จ์— ๋”ฐ๋ผ ์•„๋ž˜์—์„œ ๋ณด์—ฌ๋“œ๋ฆฐ ARC ๊ด€๋ จํ•œ ๋ฆฌ์†Œ์Šค๋“ค์€ ์ „๋ถ€ ๊ตฌ ๋ฒ„์ „์ž…๋‹ˆ๋‹ค.
์—ฌ๊ธฐ๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”!

 

 

Action Controller Runner (์ดํ•˜ ARC) ๋Š” ํŒŒ๋“œ ๋‹จ์œ„ Self Hosted Runner ์ž…๋‹ˆ๋‹ค. 

 

์ฆ‰, ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ํ™˜๊ฒฝ์—์„œ ํŒŒ๋“œ๋ฅผ Self Hosted Runner ๋กœ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ฃผ๋Š” ์˜คํ”ˆ์†Œ์Šค์ฃ .

 

ARC ์— ๋Œ€ํ•œ ์ •๋ณด๋Š” ์—ฌ๊ธฐ๋ฅผ ํ™•์ธํ•ด์ฃผ์„ธ์š”.

 

๊ทผ๋ฐ ARC ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ํ•˜๋‚˜ ๊ณ ๋ คํ•ด์•ผ ํ•  ์‚ฌํ•ญ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

๋ฐ”๋กœ ARC ์— ์˜ํ•ด ๋งŒ๋“ค์–ด์ง€๋Š” ํŒŒ๋“œ๋Š” Github Action ์˜ Job ์ด ์ข…๋ฃŒ๋  ๊ฒฝ์šฐ ์ œ๊ฑฐ๋˜๊ณ  ๋‹ค์‹œ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.

 

Job ๋‹จ์œ„๋งˆ๋‹ค Runner ๋ฅผ ์‚ญ์ œํ•˜๊ณ  ์ƒ์„ฑ

 

 

๋”ฐ๋ผ์„œ HostPath ๋‚˜ EFS ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์œผ๋ฉด Job ์„ ์‹คํ–‰ํ•  ๋•Œ ์ƒ์„ฑํ–ˆ๋˜ Java SDK, Node, Build File ๋“ฑ ๋˜ํ•œ ๊ฐ™์ด ์‚ญ์ œ๋ฉ๋‹ˆ๋‹ค.

๊ทธ ๋ง์€ ์ฆ‰์Šจ, caching ์„ ํ•  ์ˆ˜ ์—†์œผ๋ฉฐ, ๋งค๋ฒˆ ํ•„๋“œํ•  ๋•Œ ๋งˆ๋‹ค ์ƒˆ๋กญ๊ฒŒ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜๊ธฐ ๋•Œ๋ฌธ์— Job ์„ ์ˆ˜ํ–‰ํ•˜๋Š”๋ฐ ๋ณด๋‹ค ๋” ๋งŽ์€ ์‹œ๊ฐ„์ด ์†Œ์š” ๋œ๋‹ค๋Š” ๊ฒƒ์ด์ฃ .

 

๋”ฐ๋ผ์„œ ์ด๋ฒˆ ๊ธ€์—์„œ๋Š” ARC ๋ฅผ ์ด์šฉํ•  ๋•Œ ํŒŒ๋“œ์— EFS ๋ฅผ ๋งˆ์šดํŠธํ•˜์—ฌ caching ์ด ๊ฐ€๋Šฅํ•˜๋„๋ก ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

build file ์„ EFS ์— ์ €์žฅํ•˜์—ฌ caching

 

 

์‚ฌ์ „์กฐ๊ฑด

  • Build ํ•  Kotlin Project
  • Action Runner Controller Helm Chart
  • EFS CSI Driver

 

ARC ์„ค์น˜๋Š” ์—ฌ๊ธฐ๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”.

 

Runner ์˜ ์ข…๋ฅ˜๋กœ๋Š” RunnerDeploy, RunnerSet ์ด ์žˆ๊ณ , ์—ฌ๊ธฐ์„œ๋Š” RunnerDeploy ๋ฅผ ํ†ตํ•ด ๋ฐฐํฌํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv
spec:
  capacity:
    storage: 10Ei
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  storageClassName: ""
  persistentVolumeReclaimPolicy: Retain
  csi:
    driver: efs.csi.aws.com
    volumeHandle: <EFS ID>::<Access Point ID>
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc
  namespace: actions-runner-system
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: ""
  resources:
    requests:
      storage: 1Ei

 

PV ์™€ PVC ๋ฅผ ์œ„์™€ ๊ฐ™์ด ๋ฐฐํฌํ•ด์ค๋‹ˆ๋‹ค. 

์ดํ›„ ๋ฐฐํฌํ•œ PV ๋ฅผ RunnerDeploy ์— ๋งˆ์šดํŠธ ํ•ด์ค๋‹ˆ๋‹ค. ์ž์„ธํ•œ ์‚ฌํ•ญ์€ ์—ฌ๊ธฐ๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”.

apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
  name: runner
  namespace: actions-runner-system
spec:
  replicas: 2
  template:
    spec:
      serviceAccountName: ""
      organization: <organization name>
      ephemeral: true 
      dockerEnabled: true
      dockerRegistryMirror: <docker registry url>
      workDir: /runner/_work
      labels:
        - runner
        - al2_x86_64
      resources:
        requests:
          cpu: "500m"
          memory: "1000Mi"
      nodeSelector:
        purpose: self-hosted-runner
      tolerations:
        - key: "self-hosted-runner"
          value: "true"
          operator: "Equal"
          effect: "NoExecute"
      volumeMounts:
        - mountPath: /build-cache
          name: runner-pv # ์œ„์—์„œ ์ƒ์„ฑํ•œ pv ์ด๋ฆ„
      volumes:
        - name: runner-pv
          persistentVolumeClaim:
            claimName: pvc # ์œ„์—์„œ ์ƒ์„ฑํ•œ pvc ์ด๋ฆ„
  • ephemeral: true 
    • Job ์ด ๋๋‚˜๋ฉด ๊ธฐ์กด Runner ๋Š” ์‚ญ์ œํ•˜๊ณ  ์ƒˆ๋กœ์šด Runner ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค (true ๊ฐ€ ๊ถŒ์žฅ๋จ)
  • dockerEnabled: true
    • Job ์„ ์ˆ˜ํ–‰ํ•  ๋•Œ Docker Engine ์„ ํ†ตํ•ด ์ˆ˜ํ–‰ ๋ฉ๋‹ˆ๋‹ค
  • dockerRegistryMirror
    • Image ๋ฅผ ๊ฐ€์ ธ์˜ฌ Registry URL ์„ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค
  • workDir
    • Job ์ด ์ˆ˜ํ–‰๋˜๋Š” Directory ์ž…๋‹ˆ๋‹ค (default ๊ฐ€ /runner/_work)

 

EFS ์˜  /build-cache ๋””๋ ‰ํ„ฐ๋ฆฌ์— caching ์„ ์ง„ํ–‰ํ•  ๊ฒ๋‹ˆ๋‹ค.

 

์ดํ›„ kotlin Project ๋ฅผ gradle ๋ฅผ ํ†ตํ•ด build ํ•ด๋ด…์‹œ๋‹ค.

์•„๋ž˜์™€ ๊ฐ™์€ ๋ช…๋ น์–ด๋กœ gradle build ์‹œ caching ๋  ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ๋ช…์‹œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

./gradlew build \
    --no-daemon \
    --build-cache \
    --project-cache-dir=/build-cache/.gradle \
    --gradle-user-home=/build-cache/.gradle

 

gradle ์€ ๊ธฐ๋ณธ์ ์œผ๋กœ ํ•ด๋‹น ํ”„๋กœ์ ํŠธ ์œ„์น˜์— caching ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์„ ํƒํ•˜๊ธฐ ๋•Œ๋ฌธ์— --gradle-user-home ์„ ํ†ตํ•ด gradle ์ด ๋ฐ”๋ผ๋ณผ ๊ณณ์€ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

 

Github Action ์œผ๋กœ ์˜ฎ๊ธฐ๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์“ธ ์ˆ˜ ์žˆ์ฃ .

runs:
  using: "composite"
  steps:
    - uses: actions/setup-java@v3
      with:
        distribution: 'zulu' # See 'Supported distributions' for available options
        java-version: '11'

    - run: ./gradlew build --no-daemon --build-cache --project-cache-dir=/build-cache/gradle --gradle-user-home=/build-cache/gradle
      shell: bash

 

๋ชจ๋“  ์ค€๋น„๋Š” ๋๋‚ฌ์Šต๋‹ˆ๋‹ค. 

 

Action ์„ ์‹คํ–‰ํ•˜์—ฌ ์–ผ๋งˆ๋‚˜ ์†๋„ ์ฐจ์ด๊ฐ€ ๋‚˜๋Š” ์ง€ ํ™•์ธํ•ด๋ณด์ฃ !

 

ํ…Œ์ŠคํŠธํ•œ ํŒŒ๋“œ์˜ ์ŠคํŽ™์€ ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  • cpu : 400Mi
  • memory : 1Gi

 

caching ์ „

caching ์ „ - 4๋ถ„9์ดˆ ์†Œ์š”

 

caching ํ›„

caching ํ›„ - 1๋ถ„1์ดˆ ์†Œ์š”

 

ํ™•์—ฐํžˆ Build ์†๋„๊ฐ€ ๋นจ๋ผ์ง„ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋” ๋‚˜์•„๊ฐ€ Docker Build ๋˜ํ•œ caching ํ•ด ์†๋„๋ฅผ ๋†’์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๊ฑด ๊ฐ์ž์—๊ฒŒ ๋งก๊ธฐ๋„๋ก ํ•˜์ฃ !

 

๊ทธ๋Ÿผ ์˜ค๋Š˜์€ ์—ฌ๊ธฐ๊นŒ์ง€!

profile on loading

Loading...