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

 

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ํ™˜๊ฒฝ์—์„  Action Controller Runner (์ดํ•˜ ARC) ๋ฅผ ์ด์šฉํ•ด์„œ ํŒŒ๋“œ๋ฅผ Self Hosted Runner ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Action Controller Runner - Deployment

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 ๋ฐ–์— ์—†๋‹ค.. ์šฐ์„  ์ด๊ฑธ๋กœ๋Š” ์‹ค๋งˆ๋ฆฌ๋ฅผ ์ฐพ๊ธฐ๊ฐ€ ํž˜๋“ค ๊ฑฐ ๊ฐ™์•„ ๊ตฌ๊ธ€์— ๊ด€๋ จ ์—๋Ÿฌ๋ฅผ ๊ฒ€์ƒ‰ํ–ˆ๊ณ , ๊ด€๋ จ ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๊ฐ€ ๋”ฑ ํ•˜๋‚˜๊ฐ€ ๋‚˜์™”๋‹ค. ๋ถ€ํ‘ผ ๊ธฐ๋Œ€๊ฐ์„ ์•ˆ๊ณ  ํด๋ฆญํ–ˆ๋‹ค.

RunnerSet Runners fail to start with "RUNNER_NAME must be set" after upgrade to 0.22.1 #1305

 

์ •ํ™•ํžˆ ์ผ์น˜ํ•˜์ง€๋Š” ์•Š์œผ๋‚˜ ํ•ต์‹ฌ ์—๋Ÿฌ์ธ RUNNER ํ™˜๊ฒฝ ๋ณ€์ˆ˜๊ฐ€ Set ๋˜์ง€ ์•Š์•˜๋‹ค๋Š” ๋งฅ๋ฝ์€ ๋น„์Šทํ•ด์„œ ์ญ‰ ์ฝ์–ด๋ณด์•˜๋‹ค. (Issued)

 

 

ARC ๋ฅผ Helm ์ด์šฉํ•ด์„œ ๋ฐฐํฌํ•  ๋•Œ ์œ„์™€ ๊ฐ™์€ ์˜ต์…˜์„ ์ฃผ๋ผ๊ณ  ํ•œ๋‹ค. ๋  ๊ฒƒ ๊ฐ™๋‹ค๋ผ๋Š” ๋Š๋‚Œ์€ ์ „ํ˜€ ๋ฐ›์ง€ ์•Š์•˜์ง€๋งŒ.. ์„ ํƒ๊ถŒ์ด ์—†์—ˆ๊ธฐ์— ํ•œ๋ฒˆ ์‹œ๋„ํ•ด๋ดค๋‹ค.

 

์ •๋ง ํŠน์ดํ•˜๊ฒŒ ํŠธ๋Ÿฌ๋ธ” ์ŠˆํŒ… ํ•˜๋ฉด์„œ "์•ˆ๋ ๊ฑฐ ๊ฐ™์€๋ฐ.." ๊ฐ™์€ ๋Š๋‚Œ์„ ๋ฐ›์œผ๋ฉด ์ •๋ง 100% ์•ˆ๋œ๋‹ค.. ์ด๋ฒˆ์—๋„ ๋งˆ์ฐฌ๊ฐ€์ง€๋‹ค. ์•ˆ๋œ๋‹ค ๐Ÿคฆ

 

ํ˜น์‹œ๋‚˜ ํ•ด์„œ ARC TroubleShooting ๋ฌธ์„œ๋„ ์ญ‰ ์‚ดํŽด๋ดค๋‹ค.

actions-runner-controller/TROUBLESHOOTING.md

 

๊ด€๋ จ๋œ ์ด์Šˆ๋Š” ์—†๋‹ค... ์˜†์œผ๋กœ ๋ณด๊ณ , ์œ„๋กœ ๋ณด๊ณ , ์•„๋ž˜๋กœ ๋ด๋„ ์—†๋‹ค..

 

๊ทธ๋Ÿผ ํ•œ๋ฒˆ 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 ๋ฅผ ํ•ด๋ณด์ง€ ์•Š์•˜๋‹ค๋ฉด ์•„๋งˆ ์ง€๊ธˆ๋„ ํ•ด๊ฒฐํ•˜์ง€ ๋ชปํ–ˆ์„ ๊ฒƒ์ด๋‹ค.

 

์•„๋ฌดํŠผ ์ด๋ฒˆ ์—๋Ÿฌ๋„ ๋ฌด์‚ฌํžˆ ํ•ด๊ฒฐํ–ˆ๋‹ค ๐Ÿ‘

profile on loading

Loading...