0. ๐ ์ โCrossplane ๊ธฐ๋ฐ IDPโ์ธ๊ฐ์?
Terraform์ ํ๋ฅญํ IaC ๋๊ตฌ์ด์ง๋ง, ํ๋ก๋น์ ๋ ์๋ฃ ํ ํด๋ผ์ฐ๋ ๋ฆฌ์์ค์ ์ํ ๋๋ฆฌํํธ(Drift)๋ฅผ 24์๊ฐ ๊ฐ์ํด ์๋ ๋ณต๊ตฌํ์ง๋ ๋ชปํฉ๋๋ค. Crossplane v2.5.0์ Kubernetes ์ปจํธ๋กค ๋ฃจํ(Reconciliation Loop)๋ฅผ ํด๋ผ์ฐ๋ API๋ก ํ์ฅํ์ฌ, ํ๋ซํผ ํ์ด ๋ณต์กํ AWS/GCP ๋ฆฌ์์ค๋ฅผ ๊ณ ์์ค ์ถ์ API(XRD) ๋ก ๊ฐ์ธ๊ณ ์ฑ ํ์ GitOps Claim/๋ค์์คํ์ด์ค XR๋ง์ผ๋ก ์ธํ๋ผ๋ฅผ ์์ ํ๊ฒ ์
ํ์๋น์ค ๋ฐฐํฌํ๊ฒ ํฉ๋๋ค.
1. ํ์ ์ฌ์ ์๊ฑด & ์์คํ ์๊ตฌ์ฌ์ (Prerequisites & System Requirements)
๐ป ์์คํ ์ค์น ๋ฐ ์คํ ์๊ตฌ์ฌ์ (System Requirements)
| ํญ๋ชฉ | ์ต์ ์ฌ์ (Minimum) | ๊ถ์ฅ ์ฌ์ (Recommended) | ์ฐธ๊ณ ๋ฐ ๋น๊ณ |
|---|---|---|---|
| ํด๋ฌ์คํฐ / ๋๊ตฌ | Kubernetes 1.29+ (kind ๋ก์ปฌ ๊ฐ๋ฅ), helm v3.14+ | EKS / GKE / Talos Linux + Crossplane v2.5.0 | crossplane CLI (crank) ๊ถ์ฅ |
| CPU / RAM | 2 vCPU / 4 GB RAM | 4 vCPU / 8 GB+ RAM | Provider ํ๋๋ณ ๋ฉ๋ชจ๋ฆฌ ํ ๋น ํ์ธ |
# 1. Helm์ผ๋ก Crossplane v2.5.0 ์ค์น
helm repo add crossplane-stable https://charts.crossplane.io/stable
helm repo update
helm install crossplane crossplane-stable/crossplane \
--namespace crossplane-system --create-namespace \
--version 2.5.0
kubectl wait --for=condition=Available deployment/crossplane -n crossplane-system --timeout=120s
[1๊ฐ] Crossplane ์ํคํ ์ฒ & Provider / Managed Resource ์ดํด
Crossplane์ 4๊ณ์ธต ์ถ์ํ ๋ชจ๋ธ๋ก ํ๋ซํผ ํ(๊ณต๊ธ์)๊ณผ ์๋น์ค ํ(์๋น์)์ ์ฑ ์์ ๋ช ํํ ๋ถ๋ฆฌํฉ๋๋ค.
[๊ฐ๋ฐ์: ๋ค์์คํ์ด์ค XR / Claim] ("PostgreSQL small ํ๋ ์ฃผ์ธ์")
โ
โผ
[ํ๋ซํผ ํ: XRD (API ์คํค๋ง ์ ์)] + [Composition (๊ตฌํ ๋ ์ํผ + Function)]
โ
โผ
[Crossplane Provider (provider-aws-rds, provider-aws-s3)] โโโถ [์ค์ AWS / GCP ํด๋ผ์ฐ๋ API]
# 1. AWS S3 Provider ์ค์น (v2 Upbound Official Provider)
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: provider-aws-s3
spec:
package: xpkg.upbound.io/upbound/provider-aws-s3:v1.14.0
[2๊ฐ] ํ๋ซํผ ํ์ API ์ค๊ณ: CompositeResourceDefinition (XRD)
๊ฐ๋ฐ์๊ฐ ์ ํ์ ์๋ VPC, Subnet Group, KMS ํค, ์ํธํ ์ต์
์ ์จ๊ธฐ๊ณ , tier(small/medium)์ storageGB๋ง ๋ฐ๋ ๊น๋ํ ์ฌ๋ด ํ์ค API(XAppDatabase)๋ฅผ ์ ์ํฉ๋๋ค.
# xrd-app-database.yaml
apiVersion: apiextensions.crossplane.io/v2
kind: CompositeResourceDefinition
metadata:
name: xappdatabases.platform.example.com
spec:
scope: Namespaced # Crossplane v2 ๋ค์ดํฐ๋ธ ๋ค์์คํ์ด์ค XR ์ง์
group: platform.example.com
names:
kind: XAppDatabase
plural: xappdatabases
versions:
- name: v1alpha1
served: true
referenceable: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
required: ["tier", "storageGB"]
properties:
tier:
type: string
enum: ["small", "medium", "large"]
storageGB:
type: integer
minimum: 20
maximum: 1000
[3๊ฐ] Composition & function-patch-and-transform ๊ตฌํ ๋ ์ํผ
XRD ์์ฒญ์ ์ค์ AWS RDS Instance์ ๋ณด์ Bucket ๋ฑ ๋ค์์ Managed Resource๋ก ๋ณํํ๋ Composition์ ์์ฑํฉ๋๋ค.
# composition-aws-rds.yaml
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: aws-postgres-standard
spec:
compositeTypeRef:
apiVersion: platform.example.com/v1alpha1
kind: XAppDatabase
mode: Pipeline
pipeline:
- step: patch-and-transform
functionRef:
name: function-patch-and-transform
input:
apiVersion: pt.fn.crossplane.io/v1beta1
kind: Resources
resources:
- name: rds-instance
base:
apiVersion: rds.aws.upbound.io/v1beta1
kind: Instance
spec:
forProvider:
region: ap-northeast-2
engine: postgres
engineVersion: "17"
storageEncrypted: true
publiclyAccessible: false # ์ฌ๋ด ๋ณด์ ๊ฐ๋๋ ์ผ ๊ฐ์ !
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.storageGB
toFieldPath: spec.forProvider.allocatedStorage
- type: FromCompositeFieldPath
fromFieldPath: spec.tier
toFieldPath: spec.forProvider.instanceClass
transforms:
- type: map
map:
small: db.t4g.micro
medium: db.t4g.medium
large: db.r6g.large
[4๊ฐ] ๊ฐ๋ฐ์ ์ ํ์๋น์ค ๋ฐฐํฌ & ArgoCD/Flux GitOps ํตํฉ
๊ฐ๋ฐ์๋ ์ด์ ๋จ 10์ค์ YAML์ ์์ ์ ์๋น์ค GitOps ์ ์ฅ์์ ์ปค๋ฐํ๊ธฐ๋ง ํ๋ฉด ํ์ค ๋ณด์ ์ ์ฑ ์ด ์ ์ฉ๋ ํ๋ก๋์ DB๋ฅผ ์ฆ์ ํ๋ก๋น์ ๋๋ฐ์ต๋๋ค.
# apps/order-service/database.yaml
apiVersion: platform.example.com/v1alpha1
kind: XAppDatabase
metadata:
name: order-db
namespace: order-prod
spec:
tier: medium
storageGB: 100
# ๋ฆฌ์์ค ๋๊ธฐํ ์ํ ๋ฐ ์ค์ ํด๋ผ์ฐ๋ ๋ฆฌ์์ค ํธ๋ฆฌ ํ๋์ ํ์ธ
kubectl get xappdatabase -n order-prod
crossplane beta trace xappdatabase order-db -n order-prod
์๊ฒฌ ๋ฐ ์ง๋ฌธ
0์์ง ๋ฑ๋ก๋ ์๊ฒฌ์ด ์์ต๋๋ค. ์ฒซ ๋ฒ์งธ ๋๊ธ์ ๋จ๊ฒจ๋ณด์ธ์!
๋๊ธ ์์
๋๊ธ ์ญ์