Feb 2026 • CNCF Project

Crossplane

Kubernetes Infrastructure as Code แบบใหม่ที่ใช้ Kubernetes เป็น Universal Control Plane

จัดการทุกอย่างด้วย kubectl ตั้งแต่ AWS, Azure, GCP ไปจนถึง Database และ SaaS ด้วยวิธี Declarative

AWS
Azure
GCP
Kubernetes

1. Crossplane คืออะไร

Crossplane เป็น open-source framework ที่พัฒนาโดย Cloud Native Computing Foundation (CNCF) ช่วยให้คุณสามารถจัดการ infrastructure, applications และ services ที่อยู่ภายนอก Kubernetes cluster ได้โดยใช้ native Kubernetes tooling

กล่าวอีกนัยหนึ่ง Crossplane ช่วยให้คุณใช้ Kubernetes cluster เป็น Universal Control Plane ที่สามารถจัดการได้ทั้ง pods, nodes และ external servers, applications ที่อยู่นอก cluster

Key Concept: ทุกอย่างที่สามารถจัดการผ่าน API ได้ สามารถจัดการผ่าน Crossplane ได้!

2. Crossplane vs Terraform

หากคุณคิดว่า Crossplane คล้ายกับ Terraform คุณคิดถูกแล้ว! แต่มีความแตกต่างสำคัญบางอย่าง:

Feature Crossplane Terraform
Configuration Language YAML + Kubernetes API HCL (HashiCorp Configuration Language)
Tooling kubectl, Helm terraform CLI
Approach Declarative (continuous reconciliation) Imperative (plan & apply)
State Management Kubernetes etcd Remote state file (S3, etc.)
Drift Detection Automatic (continuous) Manual (terraform plan)
Integration Native Kubernetes Standalone tool

3. คุณสมบัติหลักของ Crossplane

Kubernetes-Native

จัดการ external resources เหมือน native Kubernetes resources ด้วย kubectl

Extensibility via CRDs

ใช้ CRDs เพื่อเพิ่ม support สำหรับ resources ใหม่ๆ

Multi-Cloud Support

ทำงานได้กับ AWS, Azure, GCP และ providers อื่นๆ พร้อมกัน

Continuous Reconciliation

ตรวจสอบและแก้ไข drift โดยอัตโนมัติตลอดเวลา

Policy Enforcement

กำหนดและบังคับใช้ governance policies อัตโนมัติ

API-First Design

ทุกอย่างจัดการผ่าน APIs เหมาะสำหรับ developers

4. Crossplane Architecture

Crossplane Architecture ประกอบด้วย components หลักๆ ดังนี้:

👤 Developer kubectl Kubernetes Cluster Crossplane Control Plane AWS Azure GCP Managed Resources (MR) • S3 Buckets • RDS Instances • VPCs • VMs • SQL Databases • Storage Accounts • Redis Cache • Kafka ☁️ AWS S3, EC2, RDS... ☁️ Azure VM, SQL, Storage... ☁️ GCP GCE, Cloud SQL...

Control Plane

Crossplane ทำงานเป็น pods ใน Kubernetes cluster ทำหน้าที่เป็น central control plane

Providers

เชื่อมต่อกับ external services เช่น AWS, Azure, GCP ผ่าน APIs

Managed Resources (MR)

CRDs ที่แทน external infrastructure เช่น S3 buckets, RDS instances

Compositions

รวมหลาย resources เป็น single unit เพื่อให้ reuse ได้ง่าย

5. ขั้นตอนการติดตั้ง Crossplane

1 ติดตั้ง Crossplane ด้วย Helm

Terminal
# เพิ่ม Helm repository
helm repo add crossplane-stable https://charts.crossplane.io/stable
helm repo update

# ติดตั้ง Crossplane
helm install crossplane \
  --namespace crossplane-system \
  --create-namespace \
  crossplane-stable/crossplane

# ตรวจสอบการติดตั้ง
kubectl get pods -n crossplane-system

2 ตั้งค่า AWS Provider Credentials

สร้างไฟล์ credentials สำหรับ AWS:

credentials.txt
[default]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY

สร้าง Kubernetes Secret:

Terminal
kubectl create secret generic aws-creds \
  -n crossplane-system \
  --from-file=creds=./credentials.txt

3 ติดตั้ง AWS Provider

provider-aws.yaml
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
  name: provider-aws
spec:
  package: xpkg.upbound.io/upbound/provider-aws:v0.47.0
Terminal
kubectl apply -f provider-aws.yaml

# รอ provider พร้อม
kubectl get providers

4 ตั้งค่า ProviderConfig

provider-config-aws.yaml
apiVersion: aws.upbound.io/v1beta1
kind: ProviderConfig
metadata:
  name: default
spec:
  credentials:
    source: Secret
    secretRef:
      namespace: crossplane-system
      name: aws-creds
      key: creds
Terminal
kubectl apply -f provider-config-aws.yaml

6. ตัวอย่างการใช้งานจริง

สร้าง S3 Bucket บน AWS

s3-bucket.yaml
apiVersion: s3.aws.upbound.io/v1beta1
kind: Bucket
metadata:
  name: my-crossplane-bucket
  labels:
    environment: production
spec:
  forProvider:
    region: us-east-1
  providerConfigRef:
    name: default
Terminal - Apply
# สร้าง bucket
kubectl apply -f s3-bucket.yaml

# ตรวจสอบสถานะ
kubectl get buckets

# ดูรายละเอียด
kubectl describe bucket my-crossplane-bucket

สร้าง RDS PostgreSQL Instance

rds-postgres.yaml
apiVersion: rds.aws.upbound.io/v1beta1
kind: Instance
metadata:
  name: my-postgres-db
spec:
  forProvider:
    region: us-east-1
    engine: postgres
    engineVersion: "15.4"
    instanceClass: db.t3.micro
    allocatedStorage: 20
    dbName: myappdb
    username: admin
    passwordSecretRef:
      key: password
      name: db-password
      namespace: crossplane-system
  providerConfigRef:
    name: default
  writeConnectionSecretToRef:
    name: my-postgres-conn
    namespace: crossplane-system

Pro Tip: Crossplane สามารถเก็บ connection secrets ไว้ใน Kubernetes Secrets โดยอัตโนมัติ!

สร้าง Composite Resource (XRD)

Composite Resources ช่วยให้คุณรวมหลาย resources เป็น single unit:

composite-definition.yaml
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
  name: xpostgresqlinstances.example.org
spec:
  group: example.org
  names:
    kind: XPostgreSQLInstance
    plural: xpostgresqlinstances
  claimNames:
    kind: PostgreSQLInstance
    plural: postgresqlinstances
  versions:
  - name: v1alpha1
    served: true
    referenceable: true
    schema:
      openAPIV3Schema:
        type: object
        properties:
          spec:
            type: object
            properties:
              parameters:
                type: object
                properties:
                  storageGB:
                    type: integer
                  region:
                    type: string
                required:
                - storageGB
                - region
composition.yaml
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: xpostgresqlinstances.aws.example.org
spec:
  compositeTypeRef:
    apiVersion: example.org/v1alpha1
    kind: XPostgreSQLInstance
  resources:
  - name: rdsinstance
    base:
      apiVersion: rds.aws.upbound.io/v1beta1
      kind: Instance
      spec:
        forProvider:
          region: us-east-1
          engine: postgres
          engineVersion: "15.4"
          instanceClass: db.t3.micro
    patches:
    - fromFieldPath: spec.parameters.storageGB
      toFieldPath: spec.forProvider.allocatedStorage
    - fromFieldPath: spec.parameters.region
      toFieldPath: spec.forProvider.region
my-db-claim.yaml
apiVersion: example.org/v1alpha1
kind: PostgreSQLInstance
metadata:
  name: my-app-database
  namespace: default
spec:
  parameters:
    storageGB: 20
    region: us-east-1
  compositionRef:
    name: xpostgresqlinstances.aws.example.org

7. Use Cases ที่แนะนำ

🌐

Multi-Cloud Resource Provisioning

จัดการ resources ข้าม AWS, Azure และ GCP จาก Kubernetes cluster เดียว โดยใช้ kubectl เท่านั้น

แนะนำสำหรับองค์กรที่ใช้หลาย Cloud
🔄

CI/CD Pipeline Automation

รวมกับ GitOps tools เช่น ArgoCD หรือ Flux เพื่อสร้าง infrastructure อัตโนมัติจาก Git commits

เหมาะสำหรับ DevOps Teams
🛠️

Platform Engineering

สร้าง self-service platform ให้ developers สร้าง infrastructure ที่ต้องการได้เองด้วย abstraction layers

ลด workload ของ Ops Team
🔧

Simplified Tooling

ทีมต้องการเรียนรู้เพียง kubectl และ YAML แทนที่จะต้องเรียนรู้หลาย tools สำหรับแต่ละ cloud

ลด Learning Curve

8. Best Practices

Efficient API & Schema Design

ออกแบบ custom APIs ให้มีประสิทธิภาพและเรียบง่าย หลีกเลี่ยง over-engineering

Monitor Resource Usage

ติดตาม CPU, Memory และ Storage usage กำหนด Resource Quotas เพื่อป้องกัน over-provisioning

Documentation & Collaboration

เอกสารประกอบ Crossplane resources และ policies ให้ทีมเข้าใจการใช้งานร่วมกัน

Secure Secrets Management

ใช้ External Secrets Operator หรือ Vault เพื่อจัดการ credentials อย่างปลอดภัย

Version Control Everything

เก็บ Crossplane resource definitions ใน Git เพื่อ track changes และ rollback ได้ง่าย

9. ข้อจำกัดของ Crossplane

Learning Curve

การใช้งานพื้นฐานไม่ยาก แต่การสร้าง custom APIs และ Compositions ต้องใช้เวลาเรียนรู้

Varying Provider Capabilities

ความสามารถของแต่ละ provider ไม่เท่ากัน ขึ้นอยู่กับ API ที่ provider รองรับ

Importing Existing Infrastructure

การนำเข้า resources ที่สร้างไว้แล้วเข้า Crossplane ค่อนข้างซับซ้อน

Kubernetes Dependency

ถ้า Kubernetes cluster ล่ม Crossplane ก็จะหยุดทำงานด้วย อาจเป็น single point of failure

Observability Complexity

การ debug ปัญหาที่เกิดจาก external resources อาจยาก เพราะต้องแยกว่าปัญหามาจาก Crossplane หรือ provider

สรุป

Crossplane เป็นเครื่องมือ Infrastructure as Code ที่ทรงพลังสำหรับทีมที่ใช้ Kubernetes เป็นหลัก โดยเฉพาะองค์กรที่ต้องการ:

  • จัดการ Multi-cloud หรือ Hybrid Cloud Infrastructure
  • สร้าง Self-service Platform สำหรับ Developers
  • รวม Infrastructure Management เข้ากับ GitOps Workflows
  • ลดจำนวน Tools ที่ต้องเรียนรู้และดูแล
CNCF Project Open Source Production Ready

แชร์บทความนี้