From cbbd6713eba11c5ce6f3802936b518bfa366458f Mon Sep 17 00:00:00 2001 From: drew0ps Date: Mon, 29 Sep 2025 13:20:42 +0200 Subject: [PATCH] feat(examples): Polishes AKS Cluster example --- examples/aks-cluster/README.md | 99 ++++++++++++++++++- examples/aks-cluster/aks/kubernetescluster.py | 2 +- .../cluster-function-pythonic.yaml | 2 +- examples/aks-cluster/composition.yaml | 2 +- examples/aks-cluster/definition.yaml | 2 + examples/aks-cluster/functions.yaml | 2 +- examples/aks-cluster/xr.yaml | 1 + 7 files changed, 105 insertions(+), 5 deletions(-) diff --git a/examples/aks-cluster/README.md b/examples/aks-cluster/README.md index efbb56b..d989a8f 100644 --- a/examples/aks-cluster/README.md +++ b/examples/aks-cluster/README.md @@ -29,4 +29,101 @@ This example demonstrates how to provision an AKS cluster using Crossplane v1. 4. **Apply the manifests:** ```sh ./install.sh - ``` \ No newline at end of file + ``` + + +## Architecture + +```mermaid +graph TD + A[User] -->|Orders a cluster| B[AzureKubernetesCluster XR] + + subgraph "Crossplane Control Plane" + B -->|Processed by| C[Crossplane] + C -->|Uses| D[Composition] + D -->|Translates to| E[Managed Resources] + end + + subgraph "Azure Providers" + P1[Azure Provider] + P2[provider-azure-containerservice] + end + + E -->|ResourceGroup| P1 + E -->|KubernetesCluster| P2 + + P1 -->|Creates| R1[Azure Resource Group] + P2 -->|Creates| R2[Azure AKS Cluster] + + + + classDef crossplane fill:#326ce5,stroke:#fff,stroke-width:2px,color:#fff; + classDef provider fill:#ff6b6b,stroke:#fff,stroke-width:2px,color:#fff; + classDef azure fill:#0072C6,stroke:#fff,stroke-width:2px,color:#fff; + classDef config fill:#ddd,stroke:#333,stroke-width:1px; + + class B,C,D,E crossplane; + class P1,P2 provider; + class R1,R2 azure; + class N1,N2,N3,N4 config; +``` + +## Technical Architecture + +### Implementation Flow + +1. **Python Functions** + - Python code defines the resource configuration logic + - Functions are packaged into ConfigMaps + - ConfigMaps are labeled with ```function-pythonic.package: ''``` + +2. **Crossplane Integration** + - XR Definition describes the custom resource structure + - Composition references the Python functions + - Function pipeline executes the Python code + +3. **Resource Management** + - Python functions generate Managed Resources + - Managed Resources create actual cloud resources + - Resources are managed through provider controllers + +### Diagram + +```mermaid +graph TD + subgraph "Python Function Components" + PY[Python Functions] + CM[ConfigMap] + PY -->|Packaged into| CM + CM -->|Label: python-module| K8S[Kubernetes] + end + + subgraph "Crossplane Components" + XR[XR Definition] + COMP[Composition] + FN[Function Pipeline] + + XR -->|References| COMP + COMP -->|Uses| FN + FN -->|Imports| CM + end + + subgraph "Resource Creation" + FN -->|Generates| MR[Managed Resources] + MR -->|Creates| AKS[AKS Cluster] + end + + subgraph "Legend" + L1[Python Code] + L2[Kubernetes Resources] + L3[Generated Resources] + end + + classDef python fill:#306998,stroke:#fff,stroke-width:2px,color:#fff; + classDef k8s fill:#326ce5,stroke:#fff,stroke-width:2px,color:#fff; + classDef generated fill:#ff6b6b,stroke:#fff,stroke-width:2px,color:#fff; + + class PY,L1 python; + class CM,XR,COMP,FN,K8S,L2 k8s; + class MR,AKS,L3 generated; +``` diff --git a/examples/aks-cluster/aks/kubernetescluster.py b/examples/aks-cluster/aks/kubernetescluster.py index 66f5f9c..14789be 100644 --- a/examples/aks-cluster/aks/kubernetescluster.py +++ b/examples/aks-cluster/aks/kubernetescluster.py @@ -22,7 +22,7 @@ def compose(self): else: aks.spec.forProvider.defaultNodePool.nodeCount = self.spec.nodeCount - aks.spec.forProvider.defaultNodePool.name = 'systempool1' + aks.spec.forProvider.defaultNodePool.name = self.spec.defaultNodePool.name aks.spec.forProvider.defaultNodePool.vmSize = self.spec.vmSize aks.spec.forProvider.dnsPrefix = self.metadata.name diff --git a/examples/aks-cluster/cluster-function-pythonic.yaml b/examples/aks-cluster/cluster-function-pythonic.yaml index d72f13b..a4e6bf9 100644 --- a/examples/aks-cluster/cluster-function-pythonic.yaml +++ b/examples/aks-cluster/cluster-function-pythonic.yaml @@ -3,7 +3,7 @@ kind: Function metadata: name: function-pythonic spec: - package: ghcr.io/fortra/function-pythonic:v0.0.10 + package: ghcr.io/fortra/function-pythonic:v0.0.11 runtimeConfigRef: name: function-pythonic --- diff --git a/examples/aks-cluster/composition.yaml b/examples/aks-cluster/composition.yaml index ee3334a..c4449dc 100644 --- a/examples/aks-cluster/composition.yaml +++ b/examples/aks-cluster/composition.yaml @@ -19,6 +19,6 @@ spec: functionRef: name: function-pythonic input: - apiVersion: paks.ythonic.fn.fortra.com/v1alpha1 + apiVersion: aks.pythonic.fn.fortra.com/v1alpha1 kind: Composite composite: aks.kubernetescluster.KubernetesClusterComposite diff --git a/examples/aks-cluster/definition.yaml b/examples/aks-cluster/definition.yaml index 380b6bf..682df4e 100644 --- a/examples/aks-cluster/definition.yaml +++ b/examples/aks-cluster/definition.yaml @@ -24,6 +24,8 @@ spec: defaultNodePool: type: object properties: + name: + type: string autoScaling: type: object properties: diff --git a/examples/aks-cluster/functions.yaml b/examples/aks-cluster/functions.yaml index 064538f..5ab99a7 100644 --- a/examples/aks-cluster/functions.yaml +++ b/examples/aks-cluster/functions.yaml @@ -5,6 +5,6 @@ metadata: annotations: render.crossplane.io/runtime: Development spec: - package: ghcr.io/fortra/function-pythonic:v0.0.8 + package: ghcr.io/fortra/function-pythonic:v0.0.11 runtimeConfigRef: name: function-pythonic diff --git a/examples/aks-cluster/xr.yaml b/examples/aks-cluster/xr.yaml index a567ddf..f6a0ae4 100644 --- a/examples/aks-cluster/xr.yaml +++ b/examples/aks-cluster/xr.yaml @@ -5,6 +5,7 @@ metadata: name: my-aks-cluster spec: defaultNodePool: + name: systempool1 autoScaling: enabled: False minCount: 1