[CI/CD] HyperCloud CICD Operator + Tekton Pipeline Controller ์์ ์ ๋ฆฌ
๐ ๋ค์ด๊ฐ๋ฉฐ
์ด๋ฒ ๊ธ์์๋ HyperCloud์ CICD Operator๋ฅผ ์ ๋ฆฌํ๋ค. IntegrationConfig(IC) ๋ฆฌ์์ค๋ฅผ ๊ฐ์ํ๋ค๊ฐ, Git ์ด๋ฒคํธ๊ฐ ์ค๋ฉด Tekton PipelineRun์ ์๋ ์์ฑํ๋ ์ฟ ๋ฒ๋คํฐ์ค Operator๋ค. IC โ PipelineRun โ TaskRun โ Pod๋ก ์ด์ด์ง๋ ์๋ํ ๊ณ์ธต์ ๋ฐ๋ผ๊ฐ๋ค.
CICD Operator๋? IntegrationConfig๋ฅผ ๊ฐ์ํด Git ์ด๋ฒคํธ ๋ฐ์ ์ Tekton PipelineRun์ ์๋ ์์ฑํ๋ Operator. GitLab Webhook ๋ฑ๋ก, SecretยทpodTemplate ์ฃผ์ , ํ๊ฒฝ ๋ณ์(CI_*) ์ถ๊ฐ๊น์ง ์๋์ผ๋ก ์ฒ๋ฆฌํ๋ค.
๋น์ โ IntegrationConfig = ํ์ดํ๋ผ์ธ ์ค๊ณ๋, CICD Operator = ์ค๊ณ๋๋ฅผ ๋ณด๊ณ ์๋์ผ๋ก ๊ณต์ฅ(PipelineRun)์ ๊ฐ๋์ํค๋ ๊ด๋ฆฌ์.
1. ์๋ ์์ฑ ๊ณ์ธต ๊ตฌ์กฐ
์ฌ์ฉ์๋ IC์ Task๋ง ์์ฑํ๊ณ , ๋๋จธ์ง(PipelineRunโTaskRunโPod)๋ ์ปจํธ๋กค๋ฌ๋ค์ด ์๋ ์์ฑํ๋ค.
flowchart TD
IC["IntegrationConfig<br/>(์ฌ์ฉ์ ์์ฑ)"] -- "Git Push/Tag" --> Op["CICD Operator"]
Op -- ์๋ ์์ฑ --> PR["PipelineRun<br/>(jobs ๋ณํยทpodTemplateยทSecretยทCI_*)"]
PR --> TR["TaskRun<br/>(Tekton Pipeline Controller)"]
TR --> Pod["Pod<br/>(Tekton TaskRun Controller)"]
OwnerReference๋ก cascade ์ญ์ :
1
IC ์ญ์ โ PipelineRun ์ญ์ โ TaskRun ์ญ์ โ Pod ์ญ์
๐ก OwnerReference ๋๋ถ์ IC ํ๋๋ง ์ง์ฐ๋ฉด ํ์ ๋ฆฌ์์ค๊ฐ ์ ๋ถ ์ ๋ฆฌ๋๋ค. ์๋์ผ๋ก ๋ง๋ค๋ฉด PipelineRunยทPod๋ฅผ ๋ฐ๋ก ์ง์์ผ ํ์ง๋ง, Operator๊ฐ ์์ ๊ด๊ณ๋ฅผ ๊ฑธ์ด๋์ด ์ต์์(IC)๋ง ๊ด๋ฆฌํ๋ฉด ๋๋ค.
2. ์คํ ํ๋ฆ 5๋จ๊ณ
โ IntegrationConfig ์์ฑ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
apiVersion: cicd.tmax.io/v1
kind: IntegrationConfig
metadata:
name: aic-src-lata-shs-ic05
spec:
git:
repository: aic/src/aic-src-lata-shs
apiUrl: https://gitlab.example.com/api/v4
jobs:
postSubmit: # Tag Push ์ด๋ฒคํธ ์
- name: build-image
tektonTask: {taskRef: {name: build-image-prd}}
when:
branch: (0|1|2|3|4|5|6|7|8|9)* # ์ซ์๋ก ์์ํ๋ ํ๊ทธ๋ง
secrets:
- name: shg-harbor-cicdmgr-sec-aic
podTemplate:
nodeSelector: {node: aicmgp}
tolerations:
- {key: node, value: aicmgp, effect: NoSchedule}
โก Operator๊ฐ Webhook ์๋ ๋ฑ๋ก
IC ์์ฑ์ ๊ฐ์ง โ git.repository ์ถ์ถ โ GitLab API๋ก Webhook ๋ฑ๋ก(pushยทtag_pushยทmerge_request).
โข Git ์ด๋ฒคํธ โ โฃ PipelineRun ์๋ ์์ฑ
git push origin 1.0.0 โ GitLab์ด Webhook ์ ์ก โ Operator๊ฐ IC์ jobs๋ฅผ tasks๋ก ๋ณํํ๊ณ podTemplateยทSecretยทํ๊ฒฝ ๋ณ์๋ฅผ ์ฃผ์
ํ PipelineRun ์์ฑ.
โค Tekton์ด TaskRun โ Pod ์์ฑ
PipelineRun์ ์ค์ (nodeSelectorยทtolerationsยทimagePullSecrets)์ด ํ์๋ก ์์๋์ด ์ต์ข Pod์ ๋ฐ์๋๋ค.
3. ์ฃผ์ ์๋ํ ๊ธฐ๋ฅ
| ๊ธฐ๋ฅ | ์ค๋ช |
|---|---|
| Webhook ์๋ ๊ด๋ฆฌ | IC ์์ฑ ์ ๋ฑ๋ก, ์ญ์ ์ ํด์ |
| ์กฐ๊ฑด๋ถ ์คํ(when) | ๋ธ๋์น/ํ๊ทธ ํจํด ๋งค์นญ(์ ๊ท์) |
| Secret ์๋ ์ฃผ์ | imagePullSecrets + Volume ๋ง์ดํธ |
| ํ๊ฒฝ ๋ณ์ ์ฃผ์ | CI_SERVER_URLยทCI_REPOSITORYยทCI_HEAD_REFยทCI_COMMIT_SHA |
์กฐ๊ฑด๋ถ ์คํ ์์:
1
2
3
4
5
6
7
jobs:
preSubmit: # MR ์
- name: test
when: {branch: (dev|stg).*}
postSubmit: # Tag Push ์
- name: deploy
when: {branch: (0|1|2|3|4|5|6|7|8|9)*}
๐ก preSubmit(MR ๊ฒ์ฆ) vs postSubmit(๋จธ์ง/ํ๊ทธ ํ ๋ฐฐํฌ)๋ก ๋จ๊ณ๋ฅผ ๋๋๋ค.
when์ ์ ๊ท์์ผ๋ก โdev/stg ๋ธ๋์น๋ ํ ์คํธ๋งโ, โ์ซ์ ํ๊ทธ๋ ๋ฐฐํฌโ์ฒ๋ผ ์ด๋ฒคํธ๋ณ ์คํ์ ์ ๊ตํ๊ฒ ์ ์ดํ๋ค.
4. CICD Operator vs ์๋
| ํญ๋ชฉ | CICD Operator | ์๋ PipelineRun |
|---|---|---|
| PipelineRun ์์ฑ | ์๋(Git ์ด๋ฒคํธ) | kubectl apply |
| Webhook | ์๋ ๋ฑ๋ก/ํด์ | ์๋ |
| Secret/ํ๊ฒฝ๋ณ์ | ์๋ ์ฃผ์ | ์๋ ์์ฑ |
| ์กฐ๊ฑด๋ถ ์คํ | when ์๋ ํ๊ฐ | ๋ถ๊ฐ |
| ์ฌ์ฌ์ฉ์ฑ | IC ํ๋๋ก ๋ฌดํ | ๋งค๋ฒ ์์ฑ |
5. ํ์ธ & ํธ๋ฌ๋ธ์ํ
1
2
3
4
kubectl get ic -n shg-cicd-aic # IntegrationConfig
kubectl get pr -n shg-cicd-aic -l cicd.tmax.io/integration-config=<ic> # PipelineRun
kubectl get tr -n shg-cicd-aic -l tekton.dev/pipelineRun=<pr> # TaskRun
kubectl logs -n cicd-system deploy/cicd-operator -f # Operator ๋ก๊ทธ
โ ๏ธ Webhook์ ์๋๋ฐ PipelineRun์ด ์ ์๊ธฐ๋ฉด
when์กฐ๊ฑด(๋ธ๋์น/ํ๊ทธ ํจํด)์ด ์ ๋ง์ ๊ฐ๋ฅ์ฑ์ด ๋๋ค.kubectl get ic <ic> -o yaml | grep -A3 when์ผ๋ก ํจํด์ ํ์ธํ์. Secret ๋ง์ดํธ ์คํจยท๋ ธ๋ ์ค๋ฐฐ์น๋ ๊ฐ๊ฐ Secret ์กด์ฌ ์ฌ๋ถ์ podTemplate ๋ฐ์์ ์ ๊ฒํ๋ค.
๐ ์ ๋ฆฌ
1
2
3
4
5
CICD Operator
โโ ์ญํ IC ๊ฐ์ โ PipelineRun ์๋ ์์ฑ
โโ ๊ณ์ธต IC โ PipelineRun โ TaskRun โ Pod(OwnerRef cascade)
โโ ์๋ํ WebhookยทSecretยทํ๊ฒฝ๋ณ์ยทpodTemplate ์ฃผ์
โโ ์กฐ๊ฑด when(์ ๊ท์)์ผ๋ก ์ด๋ฒคํธ๋ณ ์คํ ์ ์ด
| ๊ฐ๋ | ํ ์ค ์ ์ |
|---|---|
| IntegrationConfig | ํ์ดํ๋ผ์ธ ์ค๊ณ๋ |
| CICD Operator | IC โ PipelineRun ๋ณํ๊ธฐ |
| OwnerReference | ๊ณ์ธต cascade ์ญ์ |
CICD Operator์ ํต์ฌ์ ์ฌ์ฉ์๊ฐ IC๋ง ์์ฑํ๋ฉด, Webhook๋ถํฐ Pod ์คํ๊น์ง ์ ๋ถ ์๋ํ๋๋ค๋ ๊ฒ์ด๋ค. Git ์ด๋ฒคํธ โ PipelineRun โ TaskRun โ Pod์ ๊ณ์ธต์ ์ดํดํ๋ฉด, ๋ฌธ์ ๋ฐ์ ์ ์ด๋ ๋จ๊ณ๋ฅผ ๋ด์ผ ํ ์ง ๋ช ํํด์ง๋ค.
๐ ์ฐธ๊ณ
- HyperCloud ์ ์ฉ Operator(Tmax ๊ฐ๋ฐ). ์คํ์์ค ๋์์ ArgoCD Events + Tekton Triggers.
Comments powered by Disqus.