Skip to content

Commit

Permalink
Roughly finish EKS definitions and compositions, so they will be acce…
Browse files Browse the repository at this point in the history
…pted by crossplane validation
  • Loading branch information
jonashackt committed Mar 7, 2024
1 parent beb1a0c commit 6aa89f2
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 65 deletions.
2 changes: 1 addition & 1 deletion upbound/provider-aws/apis/claim.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Use the spec.group/spec.versions[0].name defined in the XRD
apiVersion: crossplane.jonashackt.io/v1alpha1
apiVersion: k8s.crossplane.jonashackt.io/v1alpha1
# Use the spec.claimName or spec.name specified in the XRD
kind: EKSCluster
metadata:
Expand Down
47 changes: 22 additions & 25 deletions upbound/provider-aws/apis/composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,32 @@ metadata:
spec:
writeConnectionSecretsToNamespace: crossplane-system
compositeTypeRef:
apiVersion: crossplane.jonashackt.io
apiVersion: k8s.crossplane.jonashackt.io
kind: XKubernetesCluster
resources:
### Nested use of XNetworking XR
- name: compositeNetworkEKS
base:
apiVersion: net.aws.crossplane.jonashackt.io/v1alpha1
kind: XNetworking
patches:
- fromFieldPath: spec.id
toFieldPath: spec.id
- type: ToCompositeFieldPath
fromFieldPath: status.subnetIds
toFieldPath: status.subnetIds
policy:
fromFieldPath: Required
- type: ToCompositeFieldPath
fromFieldPath: status.securityGroupIds
toFieldPath: status.securityGroupIds
policy:
fromFieldPath: Required

### Nested use of XEKSCluster XR
- name: compositeClusterEKS
base:
apiVersion: crossplane.jonashackt.io/v1alpha1
apiVersion: eks.aws.crossplane.jonashackt.io/v1alpha1
kind: XEKSCluster
connectionDetails:
- fromConnectionSecretKey: kubeconfig
Expand All @@ -30,33 +49,11 @@ spec:
toFieldPath: spec.writeConnectionSecretToRef.namespace
- fromFieldPath: spec.parameters.nodes.count
toFieldPath: spec.parameters.nodes.count
- fromFieldPath: spec.parameters.nodes.size
toFieldPath: spec.parameters.nodes.size
- fromFieldPath: status.subnetIds
toFieldPath: spec.parameters.subnetIds
policy:
fromFieldPath: Required
- fromFieldPath: status.securityGroupIds
toFieldPath: spec.parameters.securityGroupIds
policy:
fromFieldPath: Required

### Nested use of XNetworking XR
- name: compositeNetworkEKS
base:
apiVersion: crossplane.jonashackt.io/v1alpha1
kind: XNetworking
patches:
- fromFieldPath: spec.id
toFieldPath: spec.id
- type: ToCompositeFieldPath
fromFieldPath: status.subnetIds
toFieldPath: status.subnetIds
policy:
fromFieldPath: Required
- type: ToCompositeFieldPath
fromFieldPath: status.securityGroupIds
toFieldPath: status.securityGroupIds
policy:
fromFieldPath: Required

fromFieldPath: Required
4 changes: 2 additions & 2 deletions upbound/provider-aws/apis/definition.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
name: xkubernetesclusters.crossplane.jonashackt.io
name: xkubernetesclusters.k8s.crossplane.jonashackt.io
spec:
group: crossplane.jonashackt.io
group: k8s.crossplane.jonashackt.io
names:
kind: XKubernetesCluster
plural: xkubernetesclusters
Expand Down
6 changes: 1 addition & 5 deletions upbound/provider-aws/apis/eks/composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
provider: aws
spec:
compositeTypeRef:
apiVersion: crossplane.jonashackt.io/v1alpha1
apiVersion: eks.aws.crossplane.jonashackt.io/v1alpha1
kind: XEKSCluster

writeConnectionSecretsToNamespace: crossplane-system
Expand Down Expand Up @@ -49,10 +49,6 @@ spec:
- fromFieldPath: spec.parameters.subnetIds
toFieldPath: spec.forProvider.vpcConfig[0].subnetIds

# ToCompositeFieldPath patches the patched MR again :)
- type: ToCompositeFieldPath
fromFieldPath: metadata.name
toFieldPath: status.clusterName
- type: ToCompositeFieldPath
fromFieldPath: status.atProvider.status
toFieldPath: status.clusterStatus
Expand Down
7 changes: 4 additions & 3 deletions upbound/provider-aws/apis/eks/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
# XRDs must be named 'x<plural>.<group>'
name: xeks.aws.crossplane.jonashackt.io
name: xeksclusters.eks.aws.crossplane.jonashackt.io
spec:
# This XRD defines an XR in the 'crossplane.jonashackt.io' API group.
# The XR or Claim must use this group together with the spec.versions[0].name as it's apiVersion, like this:
# 'crossplane.jonashackt.io/v1alpha1'
group: crossplane.jonashackt.io
group: eks.aws.crossplane.jonashackt.io

# XR names should always be prefixed with an 'X'
names:
kind: XEKSCluster
plural: xekscluster
plural: xeksclusters
# This type of XR offers a claim, which should have the same name without the 'X' prefix
claimNames:
kind: EKSCluster
Expand Down Expand Up @@ -70,6 +70,7 @@ spec:
- region
- nodes
required:
- id
- parameters
# defining return values
status:
Expand Down
55 changes: 28 additions & 27 deletions upbound/provider-aws/apis/networking/composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
provider: aws
spec:
compositeTypeRef:
apiVersion: crossplane.jonashackt.io/v1alpha1
apiVersion: net.aws.crossplane.jonashackt.io/v1alpha1
kind: XNetworking

writeConnectionSecretsToNamespace: crossplane-system
Expand All @@ -16,10 +16,11 @@ spec:
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.id
toFieldPath: metadata.labels[aws.crossplane.jonashackt.io/network-id] # the network-id other components will use
- fromFieldPath: "spec.parameters.region"
toFieldPath: "spec.forProvider.region"

toFieldPath: metadata.labels[net.aws.crossplane.jonashackt.io/network-id] # the network-id other components will use
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.region
toFieldPath: spec.forProvider.region

resources:
### VPC and InternetGateway
- name: platform-vcp
Expand Down Expand Up @@ -72,25 +73,25 @@ spec:
patches:
- type: PatchSet
patchSetName: networkconfig
# provide the subnetId for later use as status.subnetIds entry
- type: ToCompositeFieldPath
fromFieldPath: metadata.annotations[crossplane.io/external-name]
toFieldPath: status.subnetIds[0]
# define eu-central-1a as zone & availabilityZone
- type: ToCompositeFieldPath
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.region
toFieldPath: metadata.labels.zone
transforms:
- type: string
string:
fmt: "%sa"
- type: ToCompositeFieldPath
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.region
toFieldPath: spec.forProvider.availabilityZone
transforms:
- type: string
string:
fmt: "%sa"
# provide the subnetId for later use as status.subnetIds entry
- type: ToCompositeFieldPath
fromFieldPath: metadata.annotations[crossplane.io/external-name]
toFieldPath: status.subnetIds[0]

- name: subnet-public-eu-central-1b
base:
Expand All @@ -110,25 +111,25 @@ spec:
patches:
- type: PatchSet
patchSetName: networkconfig
# provide the subnetId for later use as status.subnetIds entry
- type: ToCompositeFieldPath
fromFieldPath: metadata.annotations[crossplane.io/external-name]
toFieldPath: status.subnetIds[1]
# define eu-central-1b as zone & availabilityZone
- type: ToCompositeFieldPath
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.region
toFieldPath: metadata.labels.zone
transforms:
- type: string
string:
fmt: "%sb"
- type: ToCompositeFieldPath
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.region
toFieldPath: spec.forProvider.availabilityZone
transforms:
- type: string
string:
fmt: "%sb"
# provide the subnetId for later use as status.subnetIds entry
- type: ToCompositeFieldPath
fromFieldPath: metadata.annotations[crossplane.io/external-name]
toFieldPath: status.subnetIds[1]

- name: subnet-public-eu-central-1c
base:
Expand All @@ -148,25 +149,25 @@ spec:
patches:
- type: PatchSet
patchSetName: networkconfig
# provide the subnetId for later use as status.subnetIds entry
- type: ToCompositeFieldPath
fromFieldPath: metadata.annotations[crossplane.io/external-name]
toFieldPath: status.subnetIds[2]
# define eu-central-1c as zone & availabilityZone
- type: ToCompositeFieldPath
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.region
toFieldPath: metadata.labels.zone
transforms:
- type: string
string:
fmt: "%sc"
- type: ToCompositeFieldPath
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.region
toFieldPath: spec.forProvider.availabilityZone
transforms:
- type: string
string:
fmt: "%sc"
fmt: "%sc"
# provide the subnetId for later use as status.subnetIds entry
- type: ToCompositeFieldPath
fromFieldPath: metadata.annotations[crossplane.io/external-name]
toFieldPath: status.subnetIds[2]

### SecurityGroups & Rules
- name: securitygroup-nodepool
Expand Down Expand Up @@ -268,7 +269,7 @@ spec:
- type: PatchSet
patchSetName: networkconfig
# define eu-central-1a as subnetIdSelector.matchLabels.zone
- type: ToCompositeFieldPath
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.region
toFieldPath: spec.forProvider.subnetIdSelector.matchLabels.zone
transforms:
Expand All @@ -292,7 +293,7 @@ spec:
- type: PatchSet
patchSetName: networkconfig
# define eu-central-1b as subnetIdSelector.matchLabels.zone
- type: ToCompositeFieldPath
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.region
toFieldPath: spec.forProvider.subnetIdSelector.matchLabels.zone
transforms:
Expand All @@ -316,7 +317,7 @@ spec:
- type: PatchSet
patchSetName: networkconfig
# define eu-central-1c as subnetIdSelector.matchLabels.zone
- type: ToCompositeFieldPath
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.region
toFieldPath: spec.forProvider.subnetIdSelector.matchLabels.zone
transforms:
Expand Down
13 changes: 11 additions & 2 deletions upbound/provider-aws/apis/networking/definition.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
name: xnetworking.aws.crossplane.jonashackt.io
name: xnetworkings.net.aws.crossplane.jonashackt.io
spec:
group: crossplane.jonashackt.io
group: net.aws.crossplane.jonashackt.io
names:
kind: XNetworking
plural: xnetworkings
Expand All @@ -22,8 +22,17 @@ spec:
id:
type: string
description: ID of this Network that other objects will use to refer to it.
parameters:
type: object
description: Network configuration parameters.
properties:
region:
type: string
required:
- region
required:
- id
- parameters
# defining return values
status:
type: object
Expand Down

0 comments on commit 6aa89f2

Please sign in to comment.