apiVersion : apiextensions.crossplane.io/v1
kind : Composition
metadata :
name : xvpcsubnets.network.awsblueprints.io
labels :
awsblueprints.io/provider : aws
crossplane.io/xrd : xvpcsubnets.network.awsblueprints.io
spec :
writeConnectionSecretsToNamespace : crossplane - system
compositeTypeRef :
apiVersion : network.awsblueprints.io/v1alpha1
kind : XVpcSubnet
patchSets :
- name : common - parameters
patches :
- type : FromCompositeFieldPath
fromFieldPath : spec.resourceConfig.providerConfigName
toFieldPath : spec.providerConfigRef.name
- type : FromCompositeFieldPath
fromFieldPath : spec.resourceConfig.region
toFieldPath : spec.forProvider.region
resources :
- name : vpc
base :
apiVersion : ec2.aws.crossplane.io/v1beta1
kind : VPC
spec :
forProvider :
enableDnsSupport : true
enableDnsHostNames : true
tags :
- key : Name
patches :
- type : PatchSet
patchSetName : common - parameters
- type : FromCompositeFieldPath
fromFieldPath : spec.parameters.vpc - cidrBlock
toFieldPath : spec.forProvider.cidrBlock
- type : FromCompositeFieldPath
fromFieldPath : spec.parameters.vpc - Name
toFieldPath : spec.forProvider.tags [ 0 ] .value
- name : public - subnet1
base :
apiVersion : ec2.aws.crossplane.io/v1beta1
kind : Subnet
metadata :
labels :
type : subnet
visibility : public
spec :
forProvider :
mapPublicIpOnLaunch : true
vpcIdSelector :
matchControllerRef : true
tags :
- key : Name
- key : kubernetes.io/role/elb
value : "1"
patches :
- type : PatchSet
patchSetName : common - parameters
- type : FromCompositeFieldPath
fromFieldPath : spec.parameters.vpc - Name
toFieldPath : spec.forProvider.tags [ 0 ] .value
transforms :
- type : string
string :
fmt : 'public-subnet1-%s'
- type : FromCompositeFieldPath
fromFieldPath : spec.parameters.publicSubnet1 - cidrBlock
toFieldPath : spec.forProvider.cidrBlock
- type : FromCompositeFieldPath
fromFieldPath : spec.parameters.publicSubnet1 - availabilityZone
toFieldPath : spec.forProvider.availabilityZone
- name : private - subnet1
base :
apiVersion : ec2.aws.crossplane.io/v1beta1
kind : Subnet
metadata :
labels :
type : subnet
visibility : private
spec :
forProvider :
mapPublicIpOnLaunch : false
vpcIdSelector :
matchControllerRef : true
tags :
- key : Name
- key : kubernetes.io/role/internal - elb
value : "1"
patches :
- type : PatchSet
patchSetName : common - parameters
- type : FromCompositeFieldPath
fromFieldPath : spec.parameters.vpc - Name
toFieldPath : spec.forProvider.tags [ 0 ] .value
transforms :
- type : string
string :
fmt : 'private-subnet1-%s'
- type : FromCompositeFieldPath
fromFieldPath : spec.parameters.privateSubnet1 - cidrBlock
toFieldPath : spec.forProvider.cidrBlock apiVersion : apiextensions.crossplane.io/v1
kind : CompositeResourceDefinition
metadata :
name : xvpcsubnets.network.awsblueprints.io
spec :
group : network.awsblueprints.io
names :
kind : XVpcSubnet
plural : xvpcsubnets
versions :
- name : v1alpha1
served : true
referenceable : true
schema :
openAPIV3Schema :
type : object
properties :
spec :
type : object
properties :
resourceConfig :
type : object
properties :
providerConfigName :
type : string
region :
type : string
parameters :
type : object
properties :
vpc-Name :
type : string
vpc-cidrBlock :
type : string
publicSubnet1-cidrBlock :
type : string
publicSubnet1-availabilityZone :
type : string # Aplicar XRD e Composition
kubectl apply -f xrd.yaml
kubectl apply -f composition.yaml
# Criar VPC
cat << EOF | kubectl apply -f -
apiVersion: network.awsblueprints.io/v1alpha1
kind: XVpcSubnet
metadata:
name: my-vpc
spec:
resourceConfig:
providerConfigName: default
region: us-east-1
parameters:
vpc-Name: my-app-vpc
vpc-cidrBlock: 10.0.0.0/16
publicSubnet1-cidrBlock: 10.0.1.0/24
publicSubnet1-availabilityZone: us-east-1a
privateSubnet1-cidrBlock: 10.0.101.0/24
privateSubnet1-availabilityZone: us-east-1a
EOF
# Verificar recursos
kubectl get xvpcsubnet
kubectl get vpc
kubectl get subnetAspecto Crossplane kro Foco Infraestrutura cloud-agnostic Kubernetes-native resources Complexidade Mais verboso (XRD + Composition) Mais simples (RGD único) Maturidade Produção-ready, CNCF Mais novo, SIG Cloud Provider Use case Multi-cloud, GitOps avançado Abstrações rápidas K8s+Cloud