From 73ca8f8e7aac80010c837b6fd2f2d797db414dea Mon Sep 17 00:00:00 2001 From: Debjit Sarkar <225563802+deba310984@users.noreply.github.com> Date: Wed, 25 Nov 2026 15:48:02 +0530 Subject: [PATCH] Add Crossplane topic (IaC / Platform Engineering) Adds topics/crossplane with README, a kind-based demo script (Crossplane + provider-kubernetes managed resource) and practice exercises. Wired into README topics table, mkdocs nav, topics index and ROADMAP. Closes #802. --- README.md | 8 + ROADMAP.md | 2 +- mkdocs.yml | 1 + topics/crossplane/README.md | 146 ++++++++++++++++++ topics/crossplane/basics/README.md | 22 +++ .../basics/crossplane_kubernetes_demo.sh | 116 ++++++++++++++ topics/crossplane/practice/README.md | 11 ++ topics/index.md | 8 + 8 files changed, 313 insertions(+), 1 deletion(-) create mode 100644 topics/crossplane/README.md create mode 100644 topics/crossplane/basics/README.md create mode 100644 topics/crossplane/basics/crossplane_kubernetes_demo.sh create mode 100644 topics/crossplane/practice/README.md diff --git a/README.md b/README.md index 9995bfdd..c1756a72 100755 --- a/README.md +++ b/README.md @@ -274,6 +274,14 @@ We cover a wide range of DevOps topics in our content library, explore them unde โœ”๏ธ Explore ๐Ÿƒ Explore + + + Crossplane + crossplane + ๐Ÿ“– View + โœ”๏ธ Explore + โœ”๏ธ Explore + SQL diff --git a/ROADMAP.md b/ROADMAP.md index 6af05059..edd43d26 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -8,6 +8,7 @@ This document outlines the planned improvements and upcoming content for DevOps | Topic | Description | |-------|-------------| +| Crossplane | Kubernetes-native infrastructure management | | FluxCD | CNCF-graduated GitOps engine, complement to ArgoCD | | Grafana | Metrics visualization and dashboards | | Vault | HashiCorp Vault secrets management | @@ -21,7 +22,6 @@ These are planned or in-progress based on community demand and industry relevanc | Topic | Category | Priority | Notes | |-------|----------|----------|-------| -| **Crossplane** | IaC / Platform Eng | High | Kubernetes-native infrastructure management | | **Backstage** | Platform Engineering | High | Developer portal framework by Spotify | | **Dagger** | CI/CD | Medium | Portable CI/CD pipelines as code | | **Pulumi** | IaC | Medium | IaC with real programming languages | diff --git a/mkdocs.yml b/mkdocs.yml index 5ebe94e6..48513a8b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -143,6 +143,7 @@ nav: - OpenTofu: topics/opentofu/README.md - Ansible: topics/ansible/README.md - Packer: topics/packer/README.md + - Crossplane: topics/crossplane/README.md - Cloud Platforms: - AWS: topics/aws/README.md - Azure: topics/azure/README.md diff --git a/topics/crossplane/README.md b/topics/crossplane/README.md new file mode 100644 index 00000000..256ab8d9 --- /dev/null +++ b/topics/crossplane/README.md @@ -0,0 +1,146 @@ +## 1. What is Crossplane? + +- https://docs.crossplane.io/ + +### Overview + +Crossplane is a CNCF project that extends Kubernetes so you can provision and manage cloud infrastructure (databases, networks, buckets, ...) the same way you manage Pods and Deployments: with declarative YAML, `kubectl`, and a control loop that continuously reconciles reality to match what you declared. + +Core ideas: + +- **Provider** โ€” a package that installs CRDs and a controller for an external system (AWS, Azure, GCP, Kubernetes itself, Helm, ...). +- **Managed Resource (MR)** โ€” a Kubernetes object that represents one real external resource (e.g. an S3 bucket). Created by a Provider. +- **Composite Resource Definition (XRD)** โ€” defines your own platform API (e.g. `XDatabase`) as a new CRD. +- **Composition** โ€” a template describing which managed resources are created when someone requests your XRD. +- **Composition Function** โ€” a small program (e.g. `function-patch-and-transform`) that renders the resources for a Composition. + +Platform teams publish simple APIs (XRDs + Compositions); application teams consume them without needing to know the cloud details. This is why Crossplane is a common building block of platform engineering (see also the [`argocd`](../argocd/) and [`fluxcd`](../fluxcd/) topics, which can deliver Crossplane YAML from Git). + +### Crossplane Architecture + +``` + kubectl / GitOps (ArgoCD, Flux) + โ”‚ applies YAML + โ–ผ + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ Kubernetes API server โ”‚ + โ”‚ Claim / XR (your API) โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ Composition + Functions render... + โ–ผ + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ Managed Resources โ”‚ (Bucket, RDSInstance, Object, ...) + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ Provider controllers reconcile + โ–ผ + Cloud APIs / external systems +``` + +### Official Documentation + +- https://docs.crossplane.io/ +- GitHub: https://github.com/crossplane/crossplane + +## 2. Prerequisites + +- A Kubernetes cluster (this topic uses a local [`kind`](../k8s/) cluster โ€” no cloud account needed) +- `kubectl` and `helm` +- Familiarity with the [`k8s`](../k8s/) topic helps, but isn't required + +## 3. Installation + +### How to install Crossplane? + +```bash +helm repo add crossplane-stable https://charts.crossplane.io/stable +helm repo update + +helm install crossplane crossplane-stable/crossplane \ + --namespace crossplane-system --create-namespace + +# Verify +kubectl get pods -n crossplane-system +``` + +- Official install guide: https://docs.crossplane.io/latest/software/install/ + +## 4. Basics of Crossplane + +### Install a Provider + +```yaml +apiVersion: pkg.crossplane.io/v1 +kind: Provider +metadata: + name: provider-kubernetes +spec: + package: xpkg.upbound.io/crossplane-contrib/provider-kubernetes:v0.15.0 +``` + +```bash +kubectl get providers +``` + +Wait until `INSTALLED` and `HEALTHY` are `True`. + +### Create a Managed Resource + +With `provider-kubernetes`, an `Object` managed resource wraps any Kubernetes manifest. This is a handy way to learn Crossplane without cloud credentials: + +```yaml +apiVersion: kubernetes.crossplane.io/v1alpha2 +kind: Object +metadata: + name: hello-config +spec: + providerConfigRef: + name: default + forProvider: + manifest: + apiVersion: v1 + kind: ConfigMap + metadata: + namespace: default + name: hello-from-crossplane + data: + greeting: hello +``` + +```bash +kubectl get objects +kubectl get configmap hello-from-crossplane +``` + +Delete the `Object` and Crossplane deletes the ConfigMap too; edit it and Crossplane reconciles the change. Run the full walkthrough with the [basics demo](./basics/). + +## 5. Beyond the Basics + +### XRDs and Compositions + +A Composition turns one high-level request into several managed resources. Sketch of the flow: + +1. Install a composition function, e.g. `function-patch-and-transform`. +2. Define an XRD (your new API kind and its schema). +3. Write a Composition that maps the XRD fields onto managed resources. +4. Users create an instance of your API; Crossplane creates and manages everything underneath. + +Guide: https://docs.crossplane.io/latest/composition/compositions/ + +### Cloud providers + +For real infrastructure, install a cloud provider (for example the AWS, Azure or GCP provider families from the Upbound Marketplace) and configure a `ProviderConfig` with credentials. Prefer short-lived / workload identity credentials over long-lived keys. + +### Useful commands + +```bash +kubectl get managed # all managed resources +kubectl describe # conditions: Ready / Synced +kubectl get providers,functions # installed packages +kubectl get composite # composite resources +``` + +## 6. More + +- [Crossplane docs](https://docs.crossplane.io/) +- [Upbound Marketplace](https://marketplace.upbound.io/) โ€” providers and configurations +- [Crossplane contrib providers](https://github.com/crossplane-contrib) diff --git a/topics/crossplane/basics/README.md b/topics/crossplane/basics/README.md new file mode 100644 index 00000000..643a88a4 --- /dev/null +++ b/topics/crossplane/basics/README.md @@ -0,0 +1,22 @@ +# Basics of Crossplane + +## Demo + +Run `./crossplane_kubernetes_demo.sh` to spin up (or reuse) a local `kind` cluster, install Crossplane with Helm, install `provider-kubernetes`, and create a managed resource (`Object`) that makes Crossplane create a ConfigMap. No cloud account or credentials are needed. + +### Requirements + +- `docker` +- `kind` (the script creates a `crossplane-demo` cluster if one doesn't already exist โ€” https://kind.sigs.k8s.io/docs/user/quick-start/#installation) +- `kubectl` +- `helm` + +> Note: for simplicity the demo grants the provider `cluster-admin` on the throwaway local cluster. Don't do this in a real cluster. + +### Cleanup + +The script prints the teardown command at the end rather than running it automatically: + +```bash +kind delete cluster --name crossplane-demo +``` diff --git a/topics/crossplane/basics/crossplane_kubernetes_demo.sh b/topics/crossplane/basics/crossplane_kubernetes_demo.sh new file mode 100644 index 00000000..fdde8605 --- /dev/null +++ b/topics/crossplane/basics/crossplane_kubernetes_demo.sh @@ -0,0 +1,116 @@ +#!/bin/bash +# Crossplane Demo - installs Crossplane on a local kind cluster, installs +# provider-kubernetes and provisions a managed resource (a ConfigMap) with it. +# No cloud account required. + +set -e + +CLUSTER_NAME="crossplane-demo" + +echo "==> Tool versions:" +kubectl version --client +helm version --short + +echo "" +echo "==============================" +echo "1. Ensuring a local cluster exists" +echo "==============================" +if kubectl config get-contexts "kind-${CLUSTER_NAME}" >/dev/null 2>&1; then + echo "Reusing existing kind cluster: ${CLUSTER_NAME}" + kubectl config use-context "kind-${CLUSTER_NAME}" +else + echo "Creating kind cluster: ${CLUSTER_NAME}" + kind create cluster --name "${CLUSTER_NAME}" +fi + +echo "" +echo "==============================" +echo "2. Installing Crossplane" +echo "==============================" +helm repo add crossplane-stable https://charts.crossplane.io/stable +helm repo update +helm upgrade --install crossplane crossplane-stable/crossplane \ + --namespace crossplane-system --create-namespace --wait + +echo "" +echo "==============================" +echo "3. Installing provider-kubernetes" +echo "==============================" +# A DeploymentRuntimeConfig gives the provider a predictable ServiceAccount name +# so we can grant it permissions below. +kubectl apply -f - < Done! Crossplane created the ConfigMap from the 'Object' managed resource." +echo "==> Tip: 'kubectl delete object hello-config' removes the ConfigMap too." +echo "" +echo "==> Cleanup:" +echo " kind delete cluster --name ${CLUSTER_NAME}" diff --git a/topics/crossplane/practice/README.md b/topics/crossplane/practice/README.md new file mode 100644 index 00000000..0b83ee1c --- /dev/null +++ b/topics/crossplane/practice/README.md @@ -0,0 +1,11 @@ +## Crossplane practice + +1. **Reconcile drift**: after running the [basics demo](../basics/), edit the ConfigMap directly (`kubectl edit configmap hello-from-crossplane`, change `greeting`). Wait for the next reconcile and observe whether Crossplane restores the value declared in the `Object`. Then change `greeting` in the `Object` itself and confirm the ConfigMap follows. + +2. **Delete propagation**: run `kubectl delete object hello-config` and confirm the ConfigMap is gone. Now re-create the `Object` with `spec.deletionPolicy: Orphan` and repeat โ€” what happens to the ConfigMap this time? + +3. **Break it, then read the status**: change `providerConfigRef.name` to a name that doesn't exist and run `kubectl describe object hello-config`. Find the `Synced`/`Ready` conditions and the error message, then fix it and confirm it recovers. + +4. **Your first Composition**: install `function-patch-and-transform`, define an XRD such as `XGreeting` with a `message` field, and write a Composition that creates an `Object` ConfigMap using that value. Create an `XGreeting` and verify the ConfigMap appears (see https://docs.crossplane.io/latest/composition/compositions/). + +- Crossplane docs: https://docs.crossplane.io/ diff --git a/topics/index.md b/topics/index.md index 7580079f..d2be3606 100644 --- a/topics/index.md +++ b/topics/index.md @@ -137,6 +137,14 @@ Browse **40+ topics** organized by category. Each topic includes official docs, [:octicons-book-16: Docs](https://www.packer.io/)  ยท  [:octicons-code-16: Basics](packer/basics/) +- :octicons-cross-reference-16: **Crossplane** + + --- + + Manage cloud infrastructure as Kubernetes resources with providers and compositions. + + [:octicons-book-16: Docs](https://docs.crossplane.io/)  ยท  [:octicons-code-16: Basics](crossplane/basics/)  ยท  [:octicons-beaker-16: Practice](crossplane/practice/) + ---