Skip to content

Commit

Permalink
feat(backport): caas backport (#44)
Browse files Browse the repository at this point in the history
* feat(backport): caas backport

Signed-off-by: Christopher Haar <[email protected]>

* style(doc): add comments

Signed-off-by: Christopher Haar <[email protected]>

* style(doc): add comments

Signed-off-by: Christopher Haar <[email protected]>

* style(doc): add comments

Signed-off-by: Christopher Haar <[email protected]>

---------

Signed-off-by: Christopher Haar <[email protected]>
  • Loading branch information
haarchri authored Oct 30, 2023
1 parent 9b6d54c commit 38d0d15
Show file tree
Hide file tree
Showing 25 changed files with 695 additions and 253 deletions.
35 changes: 27 additions & 8 deletions apis/app/composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,38 @@ spec:
- fromFieldPath: metadata.annotations
toFieldPath: metadata.annotations
# All Helm releases derive the ProviderConfig to use from the XR.
- fromFieldPath: spec.providerConfigRef.name
- fromFieldPath: spec.parameters.providerConfigName
toFieldPath: spec.providerConfigRef.name
- fromFieldPath: spec.helm.chart.version
- fromFieldPath: spec.parameters.deletionPolicy
toFieldPath: spec.deletionPolicy
- fromFieldPath: spec.parameters.helm.chart.version
toFieldPath: spec.forProvider.chart.version
- fromFieldPath: spec.passwordSecretRef.namespace
- fromFieldPath: spec.parameters.passwordSecretRef.namespace
toFieldPath: spec.forProvider.set[0].valueFrom.secretKeyRef.namespace
- fromFieldPath: spec.passwordSecretRef.name
- fromFieldPath: spec.parameters.passwordSecretRef.name
toFieldPath: spec.forProvider.set[0].valueFrom.secretKeyRef.name
- fromFieldPath: spec.passwordSecretRef.namespace
- fromFieldPath: spec.parameters.passwordSecretRef.namespace
toFieldPath: spec.forProvider.set[1].valueFrom.secretKeyRef.namespace
- fromFieldPath: spec.passwordSecretRef.name
- fromFieldPath: spec.parameters.passwordSecretRef.name
toFieldPath: spec.forProvider.set[1].valueFrom.secretKeyRef.name
- fromFieldPath: spec.passwordSecretRef.namespace
- fromFieldPath: spec.parameters.passwordSecretRef.namespace
toFieldPath: spec.forProvider.set[2].valueFrom.secretKeyRef.namespace
- fromFieldPath: spec.passwordSecretRef.name
- fromFieldPath: spec.parameters.passwordSecretRef.name
toFieldPath: spec.forProvider.set[2].valueFrom.secretKeyRef.name

- name: usageXEksByXApp
base:
apiVersion: apiextensions.crossplane.io/v1alpha1
kind: Usage
spec:
of:
apiVersion: azure.platformref.upbound.io/v1alpha1
kind: XAKS
by:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
resourceSelector:
matchControllerRef: true
patches:
- fromFieldPath: spec.parameters.providerConfigName
toFieldPath: spec.of.resourceSelector.matchLabels[xaks.azure.platformref.upbound.io/cluster-id]
81 changes: 44 additions & 37 deletions apis/app/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ kind: CompositeResourceDefinition
metadata:
name: xapps.azure.platformref.upbound.io
spec:
# We require Foreground Deletion
# in such situations, XApp is deleted right away,
# taking the Usage and XAKS with it,
# which causes issues for Release.helm's deletion process.
defaultCompositeDeletePolicy: Foreground
group: azure.platformref.upbound.io
names:
kind: XApp
Expand All @@ -21,45 +26,47 @@ spec:
spec:
type: object
properties:
helm:
type: object
description: Configuration for operators.
properties:
chart:
type: object
description: Configuration for the Helm Chart
properties:
name:
type: string
description: chart name
repo:
type: string
description: chart repo
version:
type: string
description: chart version
passwordSecretRef:
parameters:
type: object
description: "A reference to the Secret object containing database credentials"
description: App configuration parameters.
properties:
namespace:
deletionPolicy:
description: Delete the external resources when the Claim/XR is deleted. Defaults to Delete
enum:
- Delete
- Orphan
type: string
name:
default: Delete
providerConfigName:
description: Crossplane ProviderConfig to use for provisioning this resources
type: string
helm:
type: object
description: Configuration for operators.
properties:
chart:
type: object
description: Configuration for the Helm Chart
properties:
name:
type: string
description: chart name
repo:
type: string
description: chart repo
version:
type: string
description: chart version
passwordSecretRef:
type: object
description: "A reference to the Secret object containing database credentials"
properties:
namespace:
type: string
name:
type: string
required:
- namespace
- name
required:
- namespace
- name
providerConfigRef:
type: object
description: "A reference to the ProviderConfig of the cluster that services should
be deployed to."
properties:
name:
type: string
description: "Name of the Helm provider configuration.
This will typically be the name of the cluster with a
five character suffix appended."
required:
- name
required:
- providerConfigRef
- providerConfigName
96 changes: 65 additions & 31 deletions apis/cluster/aks/composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,69 @@ spec:
compositeTypeRef:
apiVersion: azure.platformref.upbound.io/v1alpha1
kind: XAKS
patchSets:
- name: providerConfigRef
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.providerConfigName
toFieldPath: spec.providerConfigRef.name
- name: deletionPolicy
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.deletionPolicy
toFieldPath: spec.deletionPolicy
- name: region
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.region
toFieldPath: spec.forProvider.location
resources:
- name: kubernetes-cluster
- name: kubernetesCluster
base:
apiVersion: containerservice.azure.upbound.io/v1beta1
kind: KubernetesCluster
spec:
forProvider:
location: West US 2
kubernetesVersion: "1.26.3"
defaultNodePool:
- name: default
nodeCount: 1 #patched
vmSize: Standard_B2s #patched
identity:
- type: "SystemAssigned"
patches:
- fromFieldPath: spec.id
- type: PatchSet
patchSetName: providerConfigRef
- type: PatchSet
patchSetName: deletionPolicy
- type: PatchSet
patchSetName: region
- fromFieldPath: spec.parameters.version
toFieldPath: spec.forProvider.kubernetesVersion
- fromFieldPath: spec.parameters.id
toFieldPath: metadata.name
transforms:
- type: string
string:
fmt: "%s-aks"
- fromFieldPath: spec.id
- type: string
string:
fmt: "%s-aks"
- fromFieldPath: spec.parameters.id
toFieldPath: spec.forProvider.resourceGroupNameSelector.matchLabels[azure.platformref.upbound.io/network-id]
- fromFieldPath: spec.id
- fromFieldPath: spec.parameters.id
toFieldPath: spec.forProvider.defaultNodePool[0].vnetSubnetIdSelector.matchLabels[azure.platformref.upbound.io/network-id]
- fromFieldPath: spec.id
- fromFieldPath: spec.parameters.id
toFieldPath: spec.forProvider.dnsPrefix
- fromFieldPath: spec.parameters.nodes.size
- fromFieldPath: spec.parameters.nodes.instanceType
toFieldPath: spec.forProvider.defaultNodePool[0].vmSize
transforms:
- type: map
map:
small: Standard_B2s
medium: Standard_B4ms
large: Standard_B8ms
- fromFieldPath: spec.parameters.nodes.count
toFieldPath: spec.forProvider.defaultNodePool[0].nodeCount
- fromFieldPath: spec.writeConnectionSecretToRef.namespace
toFieldPath: spec.writeConnectionSecretToRef.namespace
- fromFieldPath: spec.writeConnectionSecretToRef.name
- fromFieldPath: metadata.uid
toFieldPath: spec.writeConnectionSecretToRef.name
transforms:
- type: string
string:
fmt: "%s-aks"
- type: string
string:
fmt: "%s-akscluster"
connectionDetails:
- fromConnectionSecretKey: kubeconfig
- name: provider-config-helm
- name: providerConfigHelm
base:
apiVersion: helm.crossplane.io/v1beta1
kind: ProviderConfig
Expand All @@ -66,17 +80,37 @@ spec:
secretRef:
key: kubeconfig
patches:
- fromFieldPath: spec.id
- fromFieldPath: spec.parameters.id
toFieldPath: metadata.name
- fromFieldPath: spec.writeConnectionSecretToRef.namespace
toFieldPath: spec.credentials.secretRef.namespace
- fromFieldPath: metadata.uid
toFieldPath: spec.credentials.secretRef.name
transforms:
- type: string
string:
fmt: "%s-akscluster"
readinessChecks:
- type: None
- name: providerConfigKubernetes
base:
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: ProviderConfig
spec:
credentials:
source: Secret
secretRef:
key: kubeconfig
patches:
- fromFieldPath: spec.parameters.id
toFieldPath: metadata.name
- fromFieldPath: spec.writeConnectionSecretToRef.namespace
toFieldPath: spec.credentials.secretRef.namespace
# This ProviderConfig uses the above AKS cluster's connection secret as
# its credentials secret.
- fromFieldPath: spec.writeConnectionSecretToRef.name
- fromFieldPath: metadata.uid
toFieldPath: spec.credentials.secretRef.name
transforms:
- type: string
string:
fmt: "%s-aks"
- type: string
string:
fmt: "%s-akscluster"
readinessChecks:
- type: None
49 changes: 36 additions & 13 deletions apis/cluster/aks/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,57 @@ spec:
spec:
type: object
properties:
id:
type: string
description: ID of this Cluster that other objects will use to refer to it.
parameters:
type: object
description: AKS configuration parameters.
properties:
id:
type: string
description: ID of this Cluster that other objects will use to refer to it.
region:
type: string
description: Region is the region you'd like your resource to be created in.
deletionPolicy:
description: Delete the external resources when the Claim/XR is deleted. Defaults to Delete
enum:
- Delete
- Orphan
type: string
default: Delete
providerConfigName:
description: Crossplane ProviderConfig to use for provisioning this resources
type: string
default: default
version:
description: Kubernetes version
type: string
enum:
- "1.27.3"
- "1.26.6"
- "1.25.11"
default: "1.27.3"
nodes:
type: object
description: AKS node configuration parameters.
properties:
count:
type: integer
description: Desired node count
size:
instanceType:
type: string
description: Size of node.
enum:
- small
- medium
- large
description: instance types associated with the Node Group.
default: Standard_B2s
required:
- count
- size
- count
- instanceType
required:
- nodes
- id
- region
- deletionPolicy
- providerConfigName
- nodes
required:
- parameters
- parameters
status:
description: A Status represents the observed state
properties:
Expand Down
Loading

0 comments on commit 38d0d15

Please sign in to comment.