Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Crossplane/demo-storage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: platform.example.org/v1alpha1
kind: StorageAccount
metadata:
name: zone-storage-account
spec:
parameters:
name: democrossplane123zone
geoRedundant: false
tags:
environment: demo
owner: platform
---
apiVersion: platform.example.org/v1alpha1
kind: StorageAccount
metadata:
name: geo-storage-account
spec:
parameters:
name: democrossplane123geo
geoRedundant: true
tags:
environment: demo
owner: platform
120 changes: 120 additions & 0 deletions Crossplane/kubernetes/platform/storage-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
apiVersion: pkg.crossplane.io/v1
kind: Function
metadata:
name: function-patch-and-transform
spec:
package: xpkg.crossplane.io/crossplane-contrib/function-patch-and-transform:v0.8.2
---
apiVersion: apiextensions.crossplane.io/v2
kind: CompositeResourceDefinition
metadata:
name: storageaccounts.platform.example.org
spec:
group: platform.example.org
names:
kind: StorageAccount
plural: storageaccounts
defaultCompositionRef:
name: storageaccounts.azure.storage.platform.example.org
versions:
- name: v1alpha1
served: true
referenceable: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
parameters:
type: object
properties:
name:
type: string
description: Storage name.
minLength: 3
maxLength: 24
pattern: '^[a-z0-9]+$'
geoRedundant:
type: boolean
description: Whether the backing implementation should use geo-redundant replication.
tags:
type: object
description: Arbitrary tags to apply to the backing storage account.
additionalProperties:
type: string
required:
- name
- geoRedundant
required:
- parameters
status:
type: object
properties:
accountName:
type: string
additionalPrinterColumns:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Move printer columns under the XRD version

additionalPrinterColumns is a field of each spec.versions[] entry in the Crossplane v2 XRD API, not a top-level spec field (see CompositeResourceDefinitionVersion in the Crossplane v2 API). With this indentation, strict Kubernetes validation can reject the XRD or the columns are pruned/ignored, so the new platform manifest is not installed as intended; move the block under the v1alpha1 version.

Useful? React with 👍 / 👎.

- name: Name
type: string
jsonPath: .spec.parameters.name
- name: Geo
type: boolean
jsonPath: .spec.parameters.geoRedundant
Comment thread
Copilot marked this conversation as resolved.
---
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: storageaccounts.azure.storage.platform.example.org
spec:
compositeTypeRef:
apiVersion: platform.example.org/v1alpha1
kind: StorageAccount
mode: Pipeline
pipeline:
- step: patch-and-transform
functionRef:
name: function-patch-and-transform
input:
apiVersion: pt.fn.crossplane.io/v1beta1
kind: Resources
resources:
- name: storage-account
base:
apiVersion: storage.azure.m.upbound.io/v1beta1
kind: Account
spec:
forProvider:
accountKind: StorageV2
accountTier: Standard
accountReplicationType: ZRS
location: swedencentral
resourceGroupName: rg-crossplanedemo

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parameterize the composed resource group

The composed storage account is always sent to rg-crossplanedemo, while the existing deploy path replaces <RESOURCE_GROUP_NAME> and grants the provider identity access to the -ResourceGroupName value (default rg-crossplane). In the normal demo deployment this resource group either does not exist or is not the one the identity was scoped to, so StorageAccount claims fail even after the platform API is installed; make this a parameter/placeholder or match the deployment resource group.

Useful? React with 👍 / 👎.

tags: {}
providerConfigRef:
kind: ClusterProviderConfig
name: default
Comment on lines +94 to +96
Comment on lines +95 to +96

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Create the matching ClusterProviderConfig

This composition creates a v2 namespaced Account whose providerConfigRef must point at an azure.m.upbound.io provider config (the v2 Account CRD requires kind and name), but the deploy flow only applies Crossplane/kubernetes/providers/provider-config.yaml as azure.upbound.io/v1beta1, kind: ProviderConfig. Because no azure.m.upbound.io/v1beta1 ClusterProviderConfig named default is created, any demo-storage.yaml XR will compose an Account that cannot resolve credentials; add the matching ClusterProviderConfig or reference a matching namespaced ProviderConfig.

Useful? React with 👍 / 👎.

Comment on lines +94 to +96
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.name
toFieldPath: metadata.annotations["crossplane.io/external-name"]
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.tags
toFieldPath: spec.forProvider.tags
policy:
fromFieldPath: Optional
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.geoRedundant
toFieldPath: spec.forProvider.accountReplicationType
transforms:
- type: convert
convert:
toType: string
- type: map
map:
"true": GRS
"false": ZRS
- type: ToCompositeFieldPath
fromFieldPath: metadata.annotations["crossplane.io/external-name"]
toFieldPath: status.accountName
---
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ kind: Provider
metadata:
name: provider-azure-storage
spec:
package: xpkg.upbound.io/upbound/provider-azure-storage:v1.11.0
package: xpkg.upbound.io/upbound/provider-azure-storage:v2.6.0
runtimeConfigRef:
name: provider-azure
2 changes: 1 addition & 1 deletion Crossplane/kubernetes/providers/provider-family-azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ kind: Provider
metadata:
name: provider-family-azure
spec:
package: xpkg.upbound.io/upbound/provider-family-azure:v1.11.0
package: xpkg.upbound.io/upbound/provider-family-azure:v2.6.0
runtimeConfigRef:
name: provider-azure