์ฟ ๋ฒ๋คํฐ์ค ํ๊ฒฝ์์ Action Controller Runner (์ดํ ARC) ๋ฅผ ์ด์ฉํด์ ํ๋๋ฅผ Self Hosted Runner ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค.
ARC ๊ตฌ์กฐ๋ ์์ ๊ฐ์ต๋๋ค. Self Hosted Runner ๋ก ์ฌ์ฉํ ํ๋๋ฅผ RunnerDeployment ๋๋ RunnerSet ์ผ๋ก ๋ฐฐํฌํ ์ ์์ฃ .
RunnerDeployment ๋ ์ฟ ๋ฒ๋คํฐ์ค์์ Deployment ์ ๋์ผํ๊ฒ ๋์ํ๊ณ , RunnerSet ์ StatefulSet ๊ณผ ๋์ผํ๊ฒ ๋์ํฉ๋๋ค.
๋ํ ๋ฐฐํฌํ๊ฒ ๋๋ฉด ํ๋ ์์ 2๊ฐ์ง ์ปจํ ์ด๋ ๋์ํ๊ฒ ๋๋๋ฐ, ํ๋๋ Github Action Job ์ ์ฒ๋ฆฌํ๋ Runner ์ปจํ ์ด๋, ๋ ํ๋๋ Docker ๊ด๋ จ ์ผ์ ์ฒ๋ฆฌํ๋ Docker ์ปจํ ์ด๋์ ๋๋ค.
์ต์ ์ ํตํด Runner ์ปจํ ์ด๋๋ง ์คํ๋๊ฒ๋ ํ ์ ์์ง๋ง, ๊ทธ๋ฆฌ ์ถ์ฒ๋๋ ๋ฐฉ๋ฒ์ ์๋๋๋ค.
์๋ฌดํผ ์ ๋ ARC ๋ฅผ ์ด์ฉํด์ Self Hosted Runner ๋ฅผ RunnerDeployment ๋ก ์ฌ๋ฌ ๊ฐ ๋์ด๋์๊ณ , Github Action ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ๋ฉด RunnerDeployment ์ค ํ๋๋ฅผ ๊ฐ์ ธ๋ค ์ฌ์ฉํ๋๋ก ๊ตฌํํ์ต๋๋ค.
์ด๋ฒ ๊ธ์์๋ ARC ๋ฅผ ์ฌ์ฉํ๋ฉด์ ๋ฐ์ ํ ์๋ฌ ์ค "RUNNER_TOKEN must be set" ์ ๋ํ ํธ๋ฌ๋ธ ์ํ ์ ๊ณต์ ํ๊ณ ์ ํฉ๋๋ค.
๊ฝค๋ ์ง๊ด์ ์ธ ์๋ฌ ๋ฉ์์ง ์์ง๋ง, ์ ์๊ฒ ์์ด ์ง๊ธ๊น์ง ๊ฐ์ฅ ํ๋ค๊ฒ ํ๋ ์๋ฌ ์์ต๋๋ค.
๋ง์น.. ํ๋ ธ์ค๋ฅผ ์๋ํ๋ ์ด๋ฒค์ ธ์ค ์ฒ๋ผ์ !
์ฐ์ RUNNER_TOKEN ๊ฐ ๋ญ๊น?
ARC ๋ฅผ ์ฌ์ฉํด์ Self Hosted Runner ๋ฅผ ์ง์ ํ๋ ค๋ฉด Github ์์ ์ ๊ณตํ TOKEN ์ด ํ์ํ๋ฐ ๋ฐ๋ก ์ด ํ ํฐ์ด RUNNER_TOKEN ์ ๋๋ค.
์๋ฌ ๋ฉ์์ง๋ง ๋ณด๋ฉด ์ด RUNNER_TOKEN ์ ์ง์ ํ๋ฉด ๋ ๊ฒ์ฒ๋ผ ๋ณด์ด์ง๋ง.. printenv ๋ฅผ ํ ๊ฒฐ๊ณผ ๋ถ๋ช RUNNER_TOKEN ๊ฐ์ ์ง์ ๋์ด ์์์ต๋๋ค.
printenv RUNNER_TOKEN
# RUNNER_TOKEN="XXXX"
๋ถ๋ช ์ด ์์์๋ ๋ถ๊ตฌํ๊ณ , Action ์ ๋์ํด๋ณด๋ฉด ์๋์ ๊ฐ์ ์๋ฌ๊ฐ ๋ฐ์ํ์ฃ .
๋ณธ๊ฒฉ์ ์ธ ํธ๋ฌ๋ธ ์ํ ์์ ๐ฅ
Github Action ์์๋ ์๋์ ๊ฐ์ด 2๊ฐ์ง ๋ฐฉ๋ฒ์ผ๋ก action ๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
๋ก์ปฌ์ ์๋ action ์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ ํ๋
jobs:
steps:
- name: use custom action
uses: ./.github/actions/custom-action
github Repo ์ ์กด์ฌํ๋ action ์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ ํ๋
jobs:
steps:
- name: use custom action
uses: kingbj940429/gitops/actions/custom-action@v1.0
์ด ์ค ์ ์๋ก ํ์ ๊ฒฝ์ฐ ์ฑ๊ณต์ ์ผ๋ก action ์ด ์ํ๋๋, ํ์๋ก ํ๋ฉด RUNNER_TOKEN must be set ์๋ฌ๊ฐ ๋ฐ์ํ๋ค.
์ฐจ๋ผ๋ฆฌ ๋ ๋ค ๋ฐ์ํ์ผ๋ฉด ๋ ๋์ ๊ฑธ..
์ดํด๊ฐ ์ ๋ง ์๊ฐ๋ค.. ๋ก์ปฌ์ ์๋ action ์ฝ๋๋ Repo ์ ๋ฐ๋ก ์๋ action ์ฝ๋๋ ์์ ํ ๋์ผํ๊ณ , ARC ์์ ์คํ๋๋ ๊ฒ๋ ๋์ผํ๋ค.
์ฐจ์ด์ ์ด๋ผ๋ฉด ๋ก์ปฌ์ด๋ Repo ๋ฐ์ ์๋ค.. ์ฐ์ ์ด๊ฑธ๋ก๋ ์ค๋ง๋ฆฌ๋ฅผ ์ฐพ๊ธฐ๊ฐ ํ๋ค ๊ฑฐ ๊ฐ์ ๊ตฌ๊ธ์ ๊ด๋ จ ์๋ฌ๋ฅผ ๊ฒ์ํ๊ณ , ๊ด๋ จ ๊ฒ์ ๊ฒฐ๊ณผ๊ฐ ๋ฑ ํ๋๊ฐ ๋์๋ค. ๋ถํผ ๊ธฐ๋๊ฐ์ ์๊ณ ํด๋ฆญํ๋ค.
์ ํํ ์ผ์นํ์ง๋ ์์ผ๋ ํต์ฌ ์๋ฌ์ธ RUNNER ํ๊ฒฝ ๋ณ์๊ฐ Set ๋์ง ์์๋ค๋ ๋งฅ๋ฝ์ ๋น์ทํด์ ์ญ ์ฝ์ด๋ณด์๋ค. (Issued)
ARC ๋ฅผ Helm ์ด์ฉํด์ ๋ฐฐํฌํ ๋ ์์ ๊ฐ์ ์ต์ ์ ์ฃผ๋ผ๊ณ ํ๋ค. ๋ ๊ฒ ๊ฐ๋ค๋ผ๋ ๋๋์ ์ ํ ๋ฐ์ง ์์์ง๋ง.. ์ ํ๊ถ์ด ์์๊ธฐ์ ํ๋ฒ ์๋ํด๋ดค๋ค.
์ ๋ง ํน์ดํ๊ฒ ํธ๋ฌ๋ธ ์ํ ํ๋ฉด์ "์๋ ๊ฑฐ ๊ฐ์๋ฐ.." ๊ฐ์ ๋๋์ ๋ฐ์ผ๋ฉด ์ ๋ง 100% ์๋๋ค.. ์ด๋ฒ์๋ ๋ง์ฐฌ๊ฐ์ง๋ค. ์๋๋ค ๐คฆ
ํน์๋ ํด์ ARC TroubleShooting ๋ฌธ์๋ ์ญ ์ดํด๋ดค๋ค.
๊ด๋ จ๋ ์ด์๋ ์๋ค... ์์ผ๋ก ๋ณด๊ณ , ์๋ก ๋ณด๊ณ , ์๋๋ก ๋ด๋ ์๋ค..
๊ทธ๋ผ ํ๋ฒ ARC ๊ด๋ จ ๋ก๊ทธ๋ฅผ ์ฐ์ด๋ณผ๊น?
๋จผ์ Action Controller ๋ถํฐ ํ์ธํด๋ณด์
k logs action-controller
2023-02-13T06:07:36Z DEBUG runnerreplicaset Created replica(s) {"runnerreplicaset": "actions-runner-system/xxxxxxx", "lastSyncTime": null, "effectiveTime": "<nil>", "templateHashDesired": "54cb5b687f", "replicasDesired": 1, "replicasPending": 0, "replicasRunning": 0, "replicasMaybeRunning": 0, "templateHashObserved": [], "created": 1}
2023-02-13T06:07:36Z DEBUG runnerreplicaset Skipped reconcilation because owner is not synced yet {"runnerreplicaset": "actions-runner-system/xxxxxxx-self-hosted-runner-q546f", "owner": "actions-runner-system/xxxxxxxx", "pods": null}
2023-02-13T06:07:36Z INFO runner Removed finalizer {"runner": "actions-runner-system/xxxxxxxx"}
2023-02-13T06:07:36Z DEBUG runnerreplicaset Skipped reconcilation because owner is not synced yet {"runnerreplicaset": "actions-runner-system/xxxxxxx-self-hosted-runner-q546f", "owner": "actions-runner-system/xxxxxxxx", "pods": null}
2023-02-13T06:07:36Z DEBUG controller-runtime.webhook.webhooks received request {"webhook": "/mutate-actions-summerwind-dev-v1alpha1-runner", "UID": "ba4c43bb-cbba-45b0-8565-144b6323ee18", "kind": "actions.summerwind.dev/v1alpha1, Kind=Runner", "resource": {"group":"actions.summerwind.dev","version":"v1alpha1","resource":"runners"}}
2023-02-13T06:07:36Z DEBUG controller-runtime.webhook.webhooks wrote response {"webhook": "/mutate-actions-summerwind-dev-v1alpha1-runner", "code": 200, "reason": "", "UID": "ba4c43bb-cbba-45b0-8565-144b6323ee18", "allowed": true}
2023-02-13T06:07:36Z DEBUG controller-runtime.webhook.webhooks received request {"webhook": "/validate-actions-summerwind-dev-v1alpha1-runner", "UID": "e1f2936f-bc5a-4636-a475-747ea6292189", "kind": "actions.summerwind.dev/v1alpha1, Kind=Runner", "resource": {"group":"actions.summerwind.dev","version":"v1alpha1","resource":"runners"}}
2023-02-13T06:07:36Z INFO runner-resource validate resource to be updated {"name": "xxxxxxx-self-hosted-runner-q546f-rgpfq"}
2023-02-13T06:07:36Z DEBUG controller-runtime.webhook.webhooks wrote response {"webhook": "/validate-actions-summerwind-dev-v1alpha1-runner", "code": 200, "reason": "", "UID": "e1f2936f-bc5a-4636-a475-747ea6292189", "allowed": true}
2023-02-13T06:07:36Z DEBUG runnerreplicaset Skipped reconcilation because owner is not synced yet {"runnerreplicaset": "actions-runner-system/xxxxxxx-self-hosted-runner-q546f", "owner": "actions-runner-system/xxxxxxx-self-hosted-runner-q546f-rgpfq", "pods": null}
2023-02-13T06:07:36Z DEBUG runnerreplicaset Skipped reconcilation because owner is not synced yet {"runnerreplicaset": "actions-runner-system/xxxxxxx-self-hosted-runner-q546f", "owner": "actions-runner-system/xxxxxxx-self-hosted-runner-q546f-rgpfq", "pods": null}
2023-02-13T06:07:36Z INFO runner Updated registration token {"runner": "xxxxxxx-self-hosted-runner-q546f-rgpfq", "repository": ""}
2023-02-13T06:07:36Z DEBUG events Successfully update registration token {"type": "Normal", "object": {"kind":"Runner","namespace":"actions-runner-system","name":"xxxxxxx-self-hosted-runner-q546f-rgpfq","uid":"8c123ea1-026e-4125-b9cf-9a284bd13c75","apiVersion":"actions.summerwind.dev/v1alpha1","resourceVersion":"45228693"}, "reason": "RegistrationTokenUpdated"}
2023-02-13T06:07:36Z INFO runnerpod Runner pod has been stopped with a successful status. {"runnerpod": "actions-runner-system/xxxxxxx-self-hosted-runner-q546f-rbd2t"}
2023-02-13T06:07:36Z DEBUG controller-runtime.webhook.webhooks received request {"webhook": "/mutate-runner-set-pod", "UID": "0b9a608b-5d3d-4551-9a44-022faf166b5d", "kind": "/v1, Kind=Pod", "resource": {"group":"","version":"v1","resource":"pods"}}
2023-02-13T06:07:36Z DEBUG controller-runtime.webhook.webhooks wrote response {"webhook": "/mutate-runner-set-pod", "code": 200, "reason": "", "UID": "0b9a608b-5d3d-4551-9a44-022faf166b5d", "allowed": true}
2023-02-13T06:07:36Z INFO runner Created runner pod {"runner": "actions-runner-system/xxxxxxx-self-hosted-runner-q546f-rgpfq", "repository": ""}
2023-02-13T06:07:36Z DEBUG events Created pod 'xxxxxxx-self-hosted-runner-q546f-rgpfq' {"type": "Normal", "object": {"kind":"Runner","namespace":"actions-runner-system","name":"xxxxxxx-self-hosted-runner-q546f-rgpfq","uid":"8c123ea1-026e-4125-b9cf-9a284bd13c75","apiVersion":"actions.summerwind.dev/v1alpha1","resourceVersion":"45228695"}, "reason": "PodCreated"}
2023-02-13T06:07:41Z DEBUG runner Runner appears to have been registered and running. {"runner": "actions-runner-system/xxxxxxx-self-hosted-runner-q546f-rgpfq", "podCreationTimestamp": "2023-02-13 06:07:36 +0000 UTC"}
WARN ๋ ๋ฒจ ์ด์์ ๋ก๊ทธ๋ ๋ณด์ด์ง ์๋๋ค.
๊ทธ๋ผ Runner Container ์ Docker Container ๋ ์ด๋จ๊น?
k logs -f xxxxxx -c runner
2023-02-13 06:06:46.371 DEBUG --- Docker enabled runner detected and Docker daemon wait is enabled
2023-02-13 06:06:46.373 DEBUG --- Waiting until Docker is available or the timeout of 120 seconds is reached
}CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2023-02-13 06:06:49.305 NOTICE --- WARNING LATEST TAG HAS BEEN DEPRECATED. SEE GITHUB ISSUE FOR DETAILS:
2023-02-13 06:06:49.307 NOTICE --- https://github.com/actions/actions-runner-controller/issues/2056
√ Connected to GitHub
Current runner version: '2.301.1'
2023-02-13 06:06:52Z: Listening for Jobs
2023-02-13 06:07:22Z: Running job: preview
2023-02-13 06:07:34Z: Job preview completed with result: Succeeded
√ Removed .credentials
Does not exist. Skipping Removing .runner
Runner listener exit with 0 return code, stop the service, no retry needed.
Exiting runner...
2023-02-13 06:07:35.818 NOTICE --- Runner init exited. Exiting this process with code 0 so that the container and the pod is GC'ed Kubernetes soon.
k logs -f xxxxxx -c docker
time="2023-02-13T06:06:46.144961961Z" level=info msg="[core] [Channel #4] Channel switches to new LB policy \"pick_first\"" module=grpc
time="2023-02-13T06:06:46.145019956Z" level=info msg="[core] [Channel #4 SubChannel #5] Subchannel created" module=grpc
time="2023-02-13T06:06:46.145056389Z" level=info msg="[core] [Channel #4 SubChannel #5] Subchannel Connectivity change to CONNECTING" module=grpc
time="2023-02-13T06:06:46.145159337Z" level=info msg="[core] [Channel #4 SubChannel #5] Subchannel picks a new address \"/var/run/docker/containerd/containerd.sock\" to connect" module=grpc
time="2023-02-13T06:06:46.145464937Z" level=info msg="[core] [Channel #4] Channel Connectivity change to CONNECTING" module=grpc
time="2023-02-13T06:06:46.145548880Z" level=info msg="[core] [Channel #4 SubChannel #5] Subchannel Connectivity change to READY" module=grpc
time="2023-02-13T06:06:46.145713463Z" level=info msg="[core] [Channel #4] Channel Connectivity change to READY" module=grpc
time="2023-02-13T06:06:46.147228733Z" level=info msg="[core] [Channel #7] Channel created" module=grpc
time="2023-02-13T06:06:46.147381111Z" level=info msg="[core] [Channel #7] original dial target is: \"unix:///var/run/docker/containerd/containerd.sock\"" module=grpc
time="2023-02-13T06:06:46.147519765Z" level=info msg="[core] [Channel #7] parsed dial target is: {Scheme:unix Authority: Endpoint:var/run/docker/containerd/containerd.sock URL:{Scheme:unix Opaque: User: Host: Path:/var/run/docker/containerd/containerd.sock RawPath: OmitHost:false ForceQuery:false RawQuery: Fragment: RawFragment:}}" module=grpc
time="2023-02-13T06:06:46.147559630Z" level=info msg="[core] [Channel #7] Channel authority set to \"localhost\"" module=grpc
time="2023-02-13T06:06:46.147609375Z" level=info msg="[core] [Channel #7] Resolver state updated: {\n \"Addresses\": [\n {\n \"Addr\": \"/var/run/docker/containerd/containerd.sock\",\n \"ServerName\": \"\",\n \"Attributes\": {},\n \"BalancerAttributes\": null,\n \"Type\": 0,\n \"Metadata\": null\n }\n ],\n \"ServiceConfig\": null,\n \"Attributes\": null\n} (resolver returned new addresses)" module=grpc
time="2023-02-13T06:06:46.147724629Z" level=info msg="[core] [Channel #7] Channel switches to new LB policy \"pick_first\"" module=grpc
time="2023-02-13T06:06:46.147772673Z" level=info msg="[core] [Channel #7 SubChannel #8] Subchannel created" module=grpc
time="2023-02-13T06:06:46.147955997Z" level=info msg="[core] [Channel #7 SubChannel #8] Subchannel Connectivity change to CONNECTING" module=grpc
time="2023-02-13T06:06:46.148195188Z" level=info msg="[core] [Channel #7 SubChannel #8] Subchannel picks a new address \"/var/run/docker/containerd/containerd.sock\" to connect" module=grpc
time="2023-02-13T06:06:46.148546236Z" level=info msg="[core] [Channel #7] Channel Connectivity change to CONNECTING" module=grpc
time="2023-02-13T06:06:46.148761854Z" level=info msg="[core] [Channel #7 SubChannel #8] Subchannel Connectivity change to READY" module=grpc
time="2023-02-13T06:06:46.148830249Z" level=info msg="[core] [Channel #7] Channel Connectivity change to READY" module=grpc
time="2023-02-13T06:06:49.090273681Z" level=info msg="Loading containers: start."
time="2023-02-13T06:06:49.156210525Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
time="2023-02-13T06:06:49.195090470Z" level=info msg="Loading containers: done."
time="2023-02-13T06:06:49.204421258Z" level=info msg="Docker daemon" commit=d7573ab graphdriver=overlay2 version=23.0.0
time="2023-02-13T06:06:49.204556037Z" level=info msg="Daemon has completed initialization"
time="2023-02-13T06:06:49.244085304Z" level=info msg="[core] [Server #10] Server created" module=grpc
time="2023-02-13T06:06:49.250054597Z" level=info msg="API listen on [::]:2376"
2023/02/13 06:06:49 http: TLS handshake error from 127.0.0.1:51708: EOF
time="2023-02-13T06:06:49.284558088Z" level=info msg="API listen on /var/run/docker.sock"
Prestop hook started
Waiting for dockerd to start
1
Prestop hook stopped
time="2023-02-13T06:07:37.836693870Z" level=info msg="Processing signal 'terminated'"
time="2023-02-13T06:07:37.837730502Z" level=info msg="[core] [Channel #4] Channel Connectivity change to SHUTDOWN" module=grpc
time="2023-02-13T06:07:37.837793352Z" level=info msg="[core] [Channel #4 SubChannel #5] Subchannel Connectivity change to SHUTDOWN" module=grpc
time="2023-02-13T06:07:37.837816003Z" level=info msg="[core] [Channel #4 SubChannel #5] Subchannel deleted" module=grpc
time="2023-02-13T06:07:37.837825169Z" level=info msg="[core] [Channel #4] Channel deleted" module=grpc
time="2023-02-13T06:07:37.837917878Z" level=info msg="stopping event stream following graceful shutdown" error="<nil>" module=libcontainerd namespace=moby
time="2023-02-13T06:07:37.838376482Z" level=info msg="Daemon shutdown complete"
์ญ์๋ ๋ ๋ค WARN ๋ ๋ฒจ ์ด์์ ๋ก๊ทธ๋ ๋ณด์ด์ง ์๋๋ค.
๋๋ ๊ทธ๋ ๊ฒ ๊ฐ ๊ธธ์ ์์๊ณ , ํฌ๊ธฐํ๋ ค๊ณ ํ๋ค.
๋ถ๋ช RUNNER_TOKEN ์ ํ๋ ๋ด์์ Set ๋์ด์๊ณ , ๊ด๋ จ ๋ด์ฉ๋ ์ฐพ์ ์ ์์ผ๋ ๋ ์ด์ ์ค๋ง๋ฆฌ๋ฅผ ์ฐพ๊ธฐ๊ฐ ์ด๋ ค์ ๋ค.
๊ทธ๋ฌ๋ ์ค ํน์๋ ํด์ runner container ์ ์ ์ํด์ ๋ฌด์จ ํ๋ก์ธ์ค๋ ๋์ด์ ธ ์๋์ง ๋ณด๋ ค๊ณ ํ๋ค.
k exec -it xxxxxx -c runner -- bash
ps aux
#USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
#runner 1 0.0 0.0 4112 3060 ? Ss 03:51 0:00 /bin/bash /usr/bin/entrypoint.sh
#runner 7 0.0 0.0 220 4 ? S 03:51 0:00 dumb-init bash
#runner 9 0.0 0.0 3980 2872 ? Ss 03:51 0:00 bash
#runner 11 0.0 0.0 3980 2944 ? S 03:51 0:00 /bin/bash ./run.sh
#runner 103 0.0 0.0 3980 3024 ? S 03:51 0:00 /bin/bash /runner/run-helper.sh
#runner 107 0.4 2.1 3458056 88332 ? Sl 03:51 0:02 /runner/bin/Runner.Listener run
#runner 151 0.0 0.0 4244 3420 pts/0 Ss 03:59 0:00 bash
#runner 158 0.0 0.0 5896 2784 pts/0 R+ 03:59 0:00 ps aux
์ถ๋ ฅ๊ฐ์ ๋ณด๊ณ ๊ฐ์๊ธฐ ๋ฌธ๋ฉ ๋ ์ฌ๋๋ค !!
custom action ์์ sh ์ ์คํ์์ผ์ฃผ๋ sh ํ์ผ ์ด๋ฆ์ entrypoint.sh ์ด๋ค. ๊ทธ๋ฆฌ๊ณ PATH ์ ๊ฒฝ๋ก๋ฅผ ๋ฑ๋กํด์ ์ฌ์ฉํ๋ค.
๊ทธ๋ฐ๋ฐ!! runner container ์ PID 1 ๋ entrypoint.sh ๋ค.
์ํ! ์์ธ์ ์ฐพ์๊ฑฐ ๊ฐ๋ค!
๊ทธ๋๋ ๋ญํ๋ ๋ ์์ธ์ง ๊ถ๊ธํด์ ๋ฐ๋ก ์ฝ๋๋ฅผ ๊น๋ดค๋ค.
#!/bin/bash
source logger.sh
source graceful-stop.sh
trap graceful_stop TERM
dumb-init bash <<'SCRIPT' &
source logger.sh
startup.sh
SCRIPT
RUNNER_INIT_PID=$!
log.notice "Runner init started with pid $RUNNER_INIT_PID"
wait $RUNNER_INIT_PID
log.notice "Runner init exited. Exiting this process with code 0 so that the container and the pod is GC'ed Kubernetes soon."
if [ -f /runner/.runner ]; then
# If the runner failed with the following error:
# √ Connected to GitHub
# Failed to create a session. The runner registration has been deleted from the server, please re-configure.
# Runner listener exit with terminated error, stop the service, no retry needed.
# Exiting runner...
# It might have failed to delete the .runner file.
# We use the existence of the .runner file as the indicator that the runner agent has not stopped yet.
# Remove it by ourselves now, so that the dockerd sidecar prestop won't hang waiting for the .runner file to appear.
echo "Removing the .runner file"
rm -f /runner/.runner
fi
trap - TERM
์ฝ๋๋ ์ด๊ฒ ๋ค์ธ๋ฐ ์๋ง ์ค๊ฐ์ ์๋ startup.sh ๊ฐ ํต์ฌ ํ์ผ์ธ ๊ฑฐ ๊ฐ๋ค. ๋ฐ๋ก ๊น๋ณด์!
...
if [ -z "${RUNNER_TOKEN}" ]; then
log.error 'RUNNER_TOKEN must be set'
exit 1
fi
...
์ฐพ์๋ค.. ๊ด๋ จ ์๋ฌ ๋ฉ์์ง..!!
๋ด๊ฐ ์์ฑํ custom action ์ entrypoint.sh ์ runner ๋ฅผ ์คํ์์ผ์ฃผ๋ entrypoint.sh ๋ ๋ค PATH ์ ๋ฑ๋ก๋์ด ์๊ณ , runner ์ entrypoint.sh ๊ฐ ์์ ๋ฑ๋ก๋์๊ธฐ ๋๋ฌธ์ custom action ์ entrypoint.sh ์ ๊ณ์ ๋ฌด์๋์๋ ๊ฒ์ด์๋ค.
runner ์ entrypoint.sh ๋ง 2๋ฒ ์คํ๋์๋ ๊ฒ์ด๋ค.
๋ฐ๋ผ์ custom action ์ entrypoint.sh ์ด๋ฆ์ ๋ณ๊ฒฝํ๊ฑฐ๋ ์ ๋ ๊ฒฝ๋ก๋ฅผ ์ด์ฉํด์ entrypoint.sh ๋ฅผ ์คํ์์ผ์ฃผ๋ฉด ์ด ๋ฌธ์ ๋ ๊น๋ํ ํด๊ฒฐ๋๋ค.
๋ง๋ฌด๋ฆฌ
entrypoint.sh ์ ์ด๋ฆ์ด ์ค๋ณต๋์ ๋ฐ์ํ ๋ฌธ์ ์๋ค. ํด๊ฒฐ ๋ฐฉ๋ฒ์ ๋งค์ฐ ๊ฐ๋จํ์ผ๋, ์ด๋ฅผ ์ฐพ๊ธฐ๊น์ง๊ฐ ์ ๋ง ์ ๋ง ์ ๋ง ํ๋ค์๋ ์ด๋ฒ ์๋ฌ์๋ค.
ps aux ๋ฅผ ํด๋ณด์ง ์์๋ค๋ฉด ์๋ง ์ง๊ธ๋ ํด๊ฒฐํ์ง ๋ชปํ์ ๊ฒ์ด๋ค.
์๋ฌดํผ ์ด๋ฒ ์๋ฌ๋ ๋ฌด์ฌํ ํด๊ฒฐํ๋ค ๐