متقدم
البحث فيأدلة التثبيت
طريقة البحث
  • الصق رسالة الخطأ بين علامتي تنصيص، مثل "permission denied"، لتجد جدول الحل.
  • اختر مجالًا وجزءًا من الدليل (التثبيت، أول الإعدادات، الاستخدام اليومي، الأمان، الحلول) لتصل مباشرة إلى الخطوة الصحيحة.
  • "كلمتان" تجد العبارة بالضبط.
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث
جرّب:

الدليل 99Crossplane · IaC and automation

Install and set up Crossplane (cloud resources from Kubernetes)

Crossplane turns Kubernetes into a control plane for cloud resources: an S3 bucket, an RDS database or a VPC becomes a Kubernetes object, and Crossplane keeps the real cloud resource equal to it — all the time, like a controller (not only when you run apply). Platform teams build their own simple APIs on top ("give me a PostgresInstance, size small") with Compositions. This guide installs Crossplane with Helm, adds an AWS provider with safe credentials, creates a managed resource, explains compositions, and covers the risks and fixes.

  • 10 الدروس
  • 8 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

99.1

Know it before you install

Providers add CRDs for one cloud service (for example AWS S3) and controllers that call the cloud API. A ProviderConfig says which credentials to use. A managed resource (MR) is one cloud resource. Composite resources (XRs) defined by a CompositeResourceDefinition (XRD) and a Composition bundle many MRs behind one simple API for app teams.

ItemValue
InstallHelm chart crossplane-stable/crossplane
Namespacecrossplane-system
Providerspackages from xpkg.crossplane.io (community) or vendor registries
ObjectsProvider, ProviderConfig, MRs (Bucket, …), CompositeResourceDefinition, Composition, Function
CLIcrossplane (optional: crossplane beta trace, render and validate tools)

Compared with Terraform: Crossplane reconciles continuously inside the cluster and uses Kubernetes RBAC, GitOps and policies; Terraform runs on demand from a CLI or pipeline. Many teams use both.

99.2

Install with Helm

helm repo add crossplane-stable https://charts.crossplane.io/stable
helm repo update
helm upgrade --install crossplane crossplane-stable/crossplane -n crossplane-system --create-namespace --wait
kubectl -n crossplane-system get pods
kubectl api-resources | grep crossplane.io | head

99.3

First configuration: an AWS provider with safe credentials

Install one small provider per service you need (not a giant all-in-one). Pin the version you tested (see the provider's releases):

provider-aws-s3.yaml
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
  name: provider-aws-s3
spec:
  package: xpkg.crossplane.io/crossplane-contrib/provider-aws-s3:v2.1.0
kubectl apply -f provider-aws-s3.yaml
kubectl get providers
NAME              INSTALLED   HEALTHY   PACKAGE
provider-aws-s3   True        True      xpkg.crossplane.io/crossplane-contrib/provider-aws-s3:v2.1.0

Credentials: on EKS the best way is IRSA/Pod Identity for the provider's service account (no keys). For a lab, a Secret with keys of a user that may only manage S3:

printf '[default]\naws_access_key_id = %s\naws_secret_access_key = %s\n' "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" > aws-creds.ini
kubectl -n crossplane-system create secret generic aws-creds --from-file=credentials=aws-creds.ini
rm aws-creds.ini
providerconfig.yaml
apiVersion: aws.upbound.io/v1beta1
kind: ProviderConfig
metadata:
  name: default
spec:
  credentials:
    source: Secret
    secretRef:
      namespace: crossplane-system
      name: aws-creds
      key: credentials

99.4

A managed resource

bucket.yaml
apiVersion: s3.aws.upbound.io/v1beta1
kind: Bucket
metadata:
  name: acme-shop-assets-prod
  annotations:
    crossplane.io/external-name: acme-shop-assets-prod
spec:
  forProvider:
    region: eu-central-1
    tags:
      team: shop
      managed-by: crossplane
  deletionPolicy: Orphan
  providerConfigRef:
    name: default
kubectl apply -f bucket.yaml
kubectl get bucket
NAME                    SYNCED   READY   EXTERNAL-NAME           AGE
acme-shop-assets-prod   True     True    acme-shop-assets-prod   2m
kubectl describe bucket acme-shop-assets-prod
FieldWhy
forProviderThe wanted settings of the cloud resource.
deletionPolicy: OrphanDeleting the Kubernetes object does not delete the bucket — safe for important data (default Delete removes it!).
external-nameThe real name in the cloud; also used to import existing resources.
providerConfigRefWhich credentials/account to use.

If someone changes the bucket by hand in the console, Crossplane changes it back (drift correction).

الأوامر في هذا الدرس

99.5

Compositions: your own platform API

Instead of giving app teams raw cloud objects, the platform team defines a simple API — for example XPostgresInstance with only size: small|medium and version — with an XRD, and a Composition (a pipeline of functions, for example function-patch-and-transform) that creates the real resources: subnet group, security group, RDS instance, secret with the connection details. App teams then create one small object (in GitOps), and policies (Kyverno) can check it. Start with the official "getting started" composition for your cloud, then adapt it.

99.6

Daily use: the commands and the real uses

kubectl get managed
kubectl get providers,providerrevisions
kubectl get composite
kubectl get events --sort-by=.lastTimestamp | tail
crossplane beta trace bucket acme-shop-assets-prod
kubectl -n crossplane-system logs deploy/crossplane --tail 50
kubectl annotate bucket acme-shop-assets-prod crossplane.io/paused=true

crossplane.io/paused=true stops reconciling one resource (for an emergency change); remove the annotation to continue.

Real uses at work:

  • A self-service internal platform: teams order databases, buckets and queues as Kubernetes objects.
  • GitOps for infrastructure (Argo CD/Flux apply Crossplane objects).
  • Continuous drift correction for important cloud resources.

99.7

Make it safe

Security checklist:

  • Provider credentials: Pod Identity/IRSA or workload identity; if keys, least privilege and rotation.
  • deletionPolicy: Orphan for data resources; RBAC on who may delete managed resources.
  • Only install providers you need, pinned to versions; review their permissions.
  • Give app teams composite APIs, not raw MRs — fewer ways to create unsafe resources.
  • Policies (Kyverno/OPA) on claims/XRs (sizes, regions, encryption).
  • Keep Crossplane and providers updated; watch provider health.

99.8

Update and remove

helm repo update
helm upgrade crossplane crossplane-stable/crossplane -n crossplane-system --wait
kubectl patch provider provider-aws-s3 --type merge -p '{"spec":{"package":"xpkg.crossplane.io/crossplane-contrib/provider-aws-s3:v2.2.0"}}'

انتبه

Before you uninstall a provider or Crossplane, decide what happens to the cloud resources. Deleting MRs with deletionPolicy: Delete deletes the real resources.

99.9

Fix common problems

ProblemCauseFix
Provider HEALTHY FalseImage pull failed, or CRD conflicts.kubectl describe provider; check the package address and version.
MR SYNCED False: … AccessDeniedThe credentials can not do this.Fix the IAM policy / identity of the ProviderConfig.
MR READY False for a long timeThe cloud is still creating it, or an error.kubectl describe events; crossplane beta trace.
cannot get referenced ProviderConfigWrong name or not created.Create ProviderConfig default (or set providerConfigRef).
The bucket was deleted with the objectdeletionPolicy: Delete (the default).Use Orphan for data; restore from backup/versioning.
Manual cloud change is undoneCrossplane corrects drift (as designed).Change the Kubernetes object, or pause the resource.

الأوامر في هذا الدرس

99.10

Next steps

1What is the difference between Crossplane and running terraform apply?

Crossplane reconciles continuously in the cluster and fixes drift; Terraform changes things only when you run it.

2Why set deletionPolicy: Orphan on a bucket or database?

So deleting the Kubernetes object does not delete the real cloud resource and its data.

الأوامر في هذا الدرس

كل الأوامر في هذا الفصل