diff --git a/apis/app/composition.yaml b/apis/app/composition.yaml index 559c06f..f2f1cc2 100644 --- a/apis/app/composition.yaml +++ b/apis/app/composition.yaml @@ -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] diff --git a/apis/app/definition.yaml b/apis/app/definition.yaml index 3e1c627..549ad36 100644 --- a/apis/app/definition.yaml +++ b/apis/app/definition.yaml @@ -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 @@ -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 diff --git a/apis/cluster/aks/composition.yaml b/apis/cluster/aks/composition.yaml index 326622a..5ad9e48 100644 --- a/apis/cluster/aks/composition.yaml +++ b/apis/cluster/aks/composition.yaml @@ -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 @@ -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 diff --git a/apis/cluster/aks/definition.yaml b/apis/cluster/aks/definition.yaml index 8626940..1069b2a 100644 --- a/apis/cluster/aks/definition.yaml +++ b/apis/cluster/aks/definition.yaml @@ -20,13 +20,35 @@ 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. @@ -34,20 +56,21 @@ spec: 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: diff --git a/apis/cluster/composition.yaml b/apis/cluster/composition.yaml index cd71f63..f42ede3 100644 --- a/apis/cluster/composition.yaml +++ b/apis/cluster/composition.yaml @@ -8,35 +8,88 @@ spec: apiVersion: azure.platformref.upbound.io/v1alpha1 kind: XCluster resources: - - base: + - name: compositeNetworkAKS + base: apiVersion: azure.platformref.upbound.io/v1alpha1 kind: XNetwork patches: - - fromFieldPath: spec.id - toFieldPath: spec.id - - base: + - fromFieldPath: spec.parameters.id + toFieldPath: spec.parameters.id + - fromFieldPath: spec.parameters.region + toFieldPath: spec.parameters.region + - fromFieldPath: spec.parameters.deletionPolicy + toFieldPath: spec.parameters.deletionPolicy + - fromFieldPath: spec.parameters.providerConfigName + toFieldPath: spec.parameters.providerConfigName + - fromFieldPath: spec.parameters.networkSelector + toFieldPath: spec.compositionSelector.matchLabels[type] + - name: compositeClusterEKS + base: apiVersion: azure.platformref.upbound.io/v1alpha1 kind: XAKS connectionDetails: - fromConnectionSecretKey: kubeconfig patches: - - fromFieldPath: spec.id - toFieldPath: spec.id - - fromFieldPath: spec.id + - fromFieldPath: spec.parameters.id + toFieldPath: metadata.labels[xaks.azure.platformref.upbound.io/cluster-id] + - fromFieldPath: spec.parameters.id + toFieldPath: spec.parameters.id + - fromFieldPath: spec.parameters.region + toFieldPath: spec.parameters.region + - fromFieldPath: spec.parameters.deletionPolicy + toFieldPath: spec.parameters.deletionPolicy + - fromFieldPath: spec.parameters.providerConfigName + toFieldPath: spec.parameters.providerConfigName + - fromFieldPath: metadata.uid toFieldPath: spec.writeConnectionSecretToRef.name + transforms: + - type: string + string: + fmt: "%s-aks" - fromFieldPath: spec.writeConnectionSecretToRef.namespace toFieldPath: spec.writeConnectionSecretToRef.namespace + - fromFieldPath: spec.parameters.version + toFieldPath: spec.parameters.version - fromFieldPath: spec.parameters.nodes.count toFieldPath: spec.parameters.nodes.count - - fromFieldPath: spec.parameters.nodes.size - toFieldPath: spec.parameters.nodes.size - - base: + - fromFieldPath: spec.parameters.nodes.instanceType + toFieldPath: spec.parameters.nodes.instanceType + - name: compositeClusterServices + base: apiVersion: azure.platformref.upbound.io/v1alpha1 kind: XServices patches: - - fromFieldPath: spec.id - toFieldPath: metadata.name - - fromFieldPath: spec.id + - fromFieldPath: spec.parameters.deletionPolicy + toFieldPath: spec.deletionPolicy + - fromFieldPath: spec.parameters.id toFieldPath: spec.providerConfigRef.name + - fromFieldPath: spec.parameters.services.operators.flux.version + toFieldPath: spec.operators.flux.version - fromFieldPath: spec.parameters.services.operators.prometheus.version toFieldPath: spec.operators.prometheus.version + - fromFieldPath: spec.parameters.gitops.url + toFieldPath: spec.gitops.url + - fromFieldPath: spec.parameters.gitops.path + toFieldPath: spec.gitops.path + - fromFieldPath: spec.parameters.gitops.kubeConfigSecretRef.name + toFieldPath: spec.gitops.kubeConfigSecretRef.name + - fromFieldPath: spec.parameters.gitops.kubeConfigSecretRef.namespace + toFieldPath: spec.gitops.kubeConfigSecretRef.namespace + - fromFieldPath: spec.parameters.serviceSelector + toFieldPath: spec.compositionSelector.matchLabels[type] + + - name: usageXAksByXService + base: + apiVersion: apiextensions.crossplane.io/v1alpha1 + kind: Usage + spec: + of: + apiVersion: azure.platformref.upbound.io/v1alpha1 + kind: XAKS + resourceSelector: + matchControllerRef: true + by: + apiVersion: azure.platformref.upbound.io/v1alpha1 + kind: XServices + resourceSelector: + matchControllerRef: true diff --git a/apis/cluster/definition.yaml b/apis/cluster/definition.yaml index 64941b0..1a5d3a4 100644 --- a/apis/cluster/definition.yaml +++ b/apis/cluster/definition.yaml @@ -3,6 +3,11 @@ kind: CompositeResourceDefinition metadata: name: xclusters.azure.platformref.upbound.io spec: + # We require Foreground Deletion for cases where XRs are generated without a Claim, like in XServices. + # In such situations, XService 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: XCluster @@ -23,13 +28,48 @@ 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: Cluster 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. + networkSelector: + type: string + description: NetworkSelector employs a specific type of network architecture. + enum: + - basic + default: basic + serviceSelector: + type: string + description: ServiceSelector employs a specific type of service architecture. + enum: + - default + - gitops + default: default + 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: + type: string + description: Kubernetes version of the Cluster + enum: + - "1.27.3" + - "1.26.6" + - "1.25.11" + default: "1.27.3" nodes: type: object description: Cluster node configuration parameters. @@ -37,16 +77,38 @@ spec: count: type: integer description: Desired node count, from 1 to 100. - 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 + gitops: + type: object + description: GitOps configure gitops system + properties: + url: + type: string + description: Url for GitOps Sync. + path: + type: string + description: path in Repo for GitOps Sync. + kubeConfigSecretRef: + type: object + description: location for kubeconfig + properties: + name: + type: string + description: Name of the secret. + namespace: + type: string + description: Namespace of the secret. + required: + - name + - namespace + required: + - url services: type: object description: Services configuration parameters. @@ -55,6 +117,14 @@ spec: type: object description: Configuration for operators. properties: + flux: + type: object + description: Configuration for the Flux GitOps operator. + properties: + version: + type: string + description: Flux operator version to run. + default: "2.9.2" prometheus: type: object description: Configuration for the Prometheus operator. @@ -62,8 +132,12 @@ spec: version: type: string description: Prometheus operator version to run. + default: "41.4.1" required: - - nodes + - nodes + - id + - region + - deletionPolicy + - providerConfigName required: - - id - - parameters + - parameters diff --git a/apis/cluster/network/composition.yaml b/apis/cluster/network/default/composition.yaml similarity index 56% rename from apis/cluster/network/composition.yaml rename to apis/cluster/network/default/composition.yaml index e9b2c85..a4707bf 100644 --- a/apis/cluster/network/composition.yaml +++ b/apis/cluster/network/default/composition.yaml @@ -4,34 +4,48 @@ metadata: name: xnetworks.azure.platformref.upbound.io labels: provider: azure + type: basic spec: + writeConnectionSecretsToNamespace: upbound-system compositeTypeRef: apiVersion: azure.platformref.upbound.io/v1alpha1 kind: XNetwork 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: network-id patches: - type: FromCompositeFieldPath - fromFieldPath: spec.id + fromFieldPath: spec.parameters.id toFieldPath: metadata.labels[azure.platformref.upbound.io/network-id] + - name: region + patches: + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.region + toFieldPath: spec.forProvider.location resources: - - name: resource-group + - name: resourceGroup base: apiVersion: azure.upbound.io/v1beta1 kind: ResourceGroup - spec: - forProvider: - location: West US 2 patches: + - type: PatchSet + patchSetName: providerConfigRef + - type: PatchSet + patchSetName: deletionPolicy - type: PatchSet patchSetName: network-id - - fromFieldPath: spec.id - toFieldPath: metadata.name - transforms: - - type: string - string: - fmt: "%s-rg" - - name: virtual-network + - type: PatchSet + patchSetName: region + - name: virtualNetwork base: apiVersion: network.azure.upbound.io/v1beta1 kind: VirtualNetwork @@ -39,13 +53,18 @@ spec: forProvider: resourceGroupNameSelector: matchControllerRef: true - location: West US 2 addressSpace: - 192.168.0.0/16 patches: + - type: PatchSet + patchSetName: providerConfigRef + - type: PatchSet + patchSetName: deletionPolicy - type: PatchSet patchSetName: network-id - - fromFieldPath: spec.id + - type: PatchSet + patchSetName: region + - fromFieldPath: spec.parameters.id toFieldPath: metadata.name transforms: - type: string @@ -66,9 +85,13 @@ spec: serviceEndpoints: - Microsoft.Sql patches: + - type: PatchSet + patchSetName: providerConfigRef + - type: PatchSet + patchSetName: deletionPolicy - type: PatchSet patchSetName: network-id - - fromFieldPath: spec.id + - fromFieldPath: spec.parameters.id toFieldPath: metadata.name transforms: - type: string diff --git a/apis/cluster/network/definition.yaml b/apis/cluster/network/definition.yaml index a0ba8a6..3221009 100644 --- a/apis/cluster/network/definition.yaml +++ b/apis/cluster/network/definition.yaml @@ -18,8 +18,31 @@ spec: spec: type: object properties: - id: - type: string - description: ID of this Network that other objects will use to refer to it. + parameters: + description: Network Parameters + properties: + id: + type: string + description: ID of this Network 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 + required: + - deletionPolicy + - providerConfigName + - id + - region + type: object required: - - id + - parameters diff --git a/apis/cluster/services/composition.yaml b/apis/cluster/services/composition.yaml deleted file mode 100644 index 9ba7c65..0000000 --- a/apis/cluster/services/composition.yaml +++ /dev/null @@ -1,47 +0,0 @@ -apiVersion: apiextensions.crossplane.io/v1 -kind: Composition -metadata: - name: xservices.azure.platformref.upbound.io - labels: - provider: helm -spec: - compositeTypeRef: - apiVersion: azure.platformref.upbound.io/v1alpha1 - kind: XServices - resources: - - name: release - base: - apiVersion: helm.crossplane.io/v1beta1 - kind: Release - spec: - rollbackLimit: 3 - forProvider: - namespace: prometheus - chart: - # from https://github.com/prometheus-community/helm-charts - # Note that default values are overridden by the patches below. - name: prometheus - repository: https://prometheus-community.github.io/helm-charts - version: "15.0.2" - values: {} - patches: - - fromFieldPath: metadata.name - toFieldPath: metadata.name - transforms: - - type: string - string: - fmt: "%s-prometheus" - # All Helm releases derive their labels and annotations from the XR. - - fromFieldPath: metadata.labels - toFieldPath: metadata.labels - - fromFieldPath: metadata.annotations - toFieldPath: metadata.annotations - # All Helm releases derive the ProviderConfig to use from the XR. - - fromFieldPath: spec.providerConfigRef.name - toFieldPath: spec.providerConfigRef.name - # Derive the Prometheus operator image and tag from the XR. - - fromFieldPath: spec.operators.prometheus.version - toFieldPath: spec.forProvider.chart.version - # Pass XR namespace to write connection secrets namespace - - fromFieldPath: spec.writeConnectionSecretToRef.namespace - toFieldPath: spec.writeConnectionSecretToRef.namespace diff --git a/apis/cluster/services/definition.yaml b/apis/cluster/services/definition.yaml index 74831f9..18781d0 100644 --- a/apis/cluster/services/definition.yaml +++ b/apis/cluster/services/definition.yaml @@ -18,10 +18,50 @@ spec: spec: type: object properties: + deletionPolicy: + description: Delete the external resources when the Claim/XR is deleted. Defaults to Delete + enum: + - Delete + - Orphan + type: string + default: Delete + gitops: + type: object + description: GitOps configure gitops system + properties: + url: + type: string + description: Url for GitOps Sync. + path: + type: string + description: path in Repo for GitOps Sync. + kubeConfigSecretRef: + type: object + description: location for kubeconfig + properties: + name: + type: string + description: Name of the secret. + namespace: + type: string + description: Namespace of the secret. + required: + - name + - namespace + required: + - url operators: type: object description: Configuration for operators. properties: + flux: + type: object + description: Configuration for the Flux GitOps operator. + properties: + version: + type: string + description: Flux operator version to run. + default: "2.9.2" prometheus: type: object description: Configuration for the Prometheus operator. @@ -29,16 +69,16 @@ spec: version: type: string description: Prometheus operator version to run. + default: "41.4.1" 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 Kubernetes provider configuration. - This will typically be the name of the cluster with a - five character suffix appended." + description: "Name of the Kubernetes provider configuration. This will typically be the name of the cluster with a five character suffix appended." required: - name required: - - providerConfigRef + - providerConfigRef + - deletionPolicy diff --git a/apis/cluster/services/flux/composition.yaml b/apis/cluster/services/flux/composition.yaml new file mode 100644 index 0000000..cc7d46f --- /dev/null +++ b/apis/cluster/services/flux/composition.yaml @@ -0,0 +1,98 @@ +apiVersion: apiextensions.crossplane.io/v1 +kind: Composition +metadata: + name: xservicesflux.azure.platformref.upbound.io + labels: + type: gitops +spec: + writeConnectionSecretsToNamespace: upbound-system + compositeTypeRef: + apiVersion: azure.platformref.upbound.io/v1alpha1 + kind: XServices + patchSets: + - name: Common + patches: + - type: FromCompositeFieldPath + fromFieldPath: metadata.labels + toFieldPath: metadata.labels + - type: FromCompositeFieldPath + fromFieldPath: metadata.annotations + toFieldPath: metadata.annotations + - type: FromCompositeFieldPath + fromFieldPath: spec.providerConfigRef.name + toFieldPath: spec.providerConfigRef.name + - type: FromCompositeFieldPath + fromFieldPath: spec.deletionPolicy + toFieldPath: spec.deletionPolicy + resources: + - name: releaseFlux + base: + apiVersion: helm.crossplane.io/v1beta1 + kind: Release + spec: + rollbackLimit: 3 + forProvider: + namespace: flux-system + chart: + name: flux2 + url: https://github.com/fluxcd-community/helm-charts/releases/download/flux2-2.9.2/flux2-2.9.2.tgz + version: 2.9.2 + values: + imageAutomationController: + create: false + imageReflectionController: + create: false + patches: + - type: PatchSet + patchSetName: Common + - fromFieldPath: spec.operators.flux.version + toFieldPath: spec.forProvider.chart.version + - type: CombineFromComposite + combine: + variables: + - fromFieldPath: spec.operators.flux.version + - fromFieldPath: spec.operators.flux.version + strategy: string + string: + fmt: https://github.com/fluxcd-community/helm-charts/releases/download/flux2-%s/flux2-%s.tgz + toFieldPath: spec.forProvider.chart.url + - name: syncFlux + base: + apiVersion: helm.crossplane.io/v1beta1 + kind: Release + spec: + rollbackLimit: 3 + forProvider: + namespace: flux-system + chart: + name: flux2-sync + repository: https://fluxcd-community.github.io/helm-charts + version: "1.6.2" + values: + gitRepository: + spec: + timeout: 20s + interval: 10m0s + gitImplementation: go-git + ref: + branch: main + kustomization: + spec: + interval: 10m + sourceRef: + kind: GitRepository + patches: + - type: PatchSet + patchSetName: Common + - fromFieldPath: spec.providerConfigRef.name + toFieldPath: metadata.annotations[crossplane.io/external-name] + - fromFieldPath: spec.gitops.url + toFieldPath: spec.forProvider.values.gitRepository.spec.url + - fromFieldPath: spec.providerConfigRef.name + toFieldPath: spec.forProvider.values.kustomization.spec.path + transforms: + - type: string + string: + fmt: "./infrastructure/%s" + - fromFieldPath: spec.gitops.path + toFieldPath: spec.forProvider.values.kustomization.spec.path diff --git a/apis/cluster/services/prometheus/composition.yaml b/apis/cluster/services/prometheus/composition.yaml new file mode 100644 index 0000000..9ee94d2 --- /dev/null +++ b/apis/cluster/services/prometheus/composition.yaml @@ -0,0 +1,45 @@ +apiVersion: apiextensions.crossplane.io/v1 +kind: Composition +metadata: + name: xservices.azure.platformref.upbound.io + labels: + type: default +spec: + writeConnectionSecretsToNamespace: upbound-system + compositeTypeRef: + apiVersion: azure.platformref.upbound.io/v1alpha1 + kind: XServices + patchSets: + - name: Common + patches: + - type: FromCompositeFieldPath + fromFieldPath: metadata.labels + toFieldPath: metadata.labels + - type: FromCompositeFieldPath + fromFieldPath: metadata.annotations + toFieldPath: metadata.annotations + - type: FromCompositeFieldPath + fromFieldPath: spec.providerConfigRef.name + toFieldPath: spec.providerConfigRef.name + - type: FromCompositeFieldPath + fromFieldPath: spec.deletionPolicy + toFieldPath: spec.deletionPolicy + resources: + - name: releasePrometheus + base: + apiVersion: helm.crossplane.io/v1beta1 + kind: Release + spec: + rollbackLimit: 3 + forProvider: + namespace: operators + chart: + name: kube-prometheus-stack + repository: https://prometheus-community.github.io/helm-charts + version: "41.4.1" + values: {} + patches: + - type: PatchSet + patchSetName: Common + - fromFieldPath: spec.operators.prometheus.version + toFieldPath: spec.forProvider.chart.version diff --git a/apis/database/sqlinstance/definition.yaml b/apis/database/sqlinstance/definition.yaml index 37e1786..dbb98f9 100644 --- a/apis/database/sqlinstance/definition.yaml +++ b/apis/database/sqlinstance/definition.yaml @@ -29,6 +29,20 @@ spec: parameters: type: object properties: + 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 storageGB: type: integer passwordSecretRef: diff --git a/apis/database/sqlinstance/composition-mariadb.yaml b/apis/database/sqlinstance/mariadb/composition.yaml similarity index 76% rename from apis/database/sqlinstance/composition-mariadb.yaml rename to apis/database/sqlinstance/mariadb/composition.yaml index 0ef4a0c..5fcf8ca 100644 --- a/apis/database/sqlinstance/composition-mariadb.yaml +++ b/apis/database/sqlinstance/mariadb/composition.yaml @@ -10,6 +10,22 @@ spec: compositeTypeRef: apiVersion: azure.platformref.upbound.io/v1alpha1 kind: XSQLInstance + 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: mariadlserver base: @@ -19,14 +35,19 @@ spec: forProvider: version: "10.3" administratorLogin: xp-admin - location: West US 2 skuName: GP_Gen5_2 storageMb: 5120 sslEnforcementEnabled: false sslMinimalTlsVersionEnforced: TLSEnforcementDisabled identity: - - type: SystemAssigned + - type: SystemAssigned patches: + - type: PatchSet + patchSetName: providerConfigRef + - type: PatchSet + patchSetName: deletionPolicy + - type: PatchSet + patchSetName: region - fromFieldPath: spec.parameters.clusterRef.id toFieldPath: metadata.name transforms: @@ -38,15 +59,15 @@ spec: - fromFieldPath: metadata.uid toFieldPath: spec.writeConnectionSecretToRef.name transforms: - - type: string - string: - fmt: "%s-mariadb" + - type: string + string: + fmt: "%s-mariadb" - fromFieldPath: spec.parameters.storageGB toFieldPath: spec.forProvider.storageMb transforms: - - type: math - math: - multiply: 1024 + - type: math + math: + multiply: 1024 - fromFieldPath: spec.parameters.clusterRef.id toFieldPath: spec.forProvider.resourceGroupNameSelector.matchLabels[azure.platformref.upbound.io/network-id] - fromFieldPath: spec.parameters.passwordSecretRef.namespace @@ -68,7 +89,6 @@ spec: - type: FromConnectionSecretKey name: port fromConnectionSecretKey: port - # db-server vnet-rule for subnet where AKS lives in - name: vnetrule base: apiVersion: dbformariadb.azure.upbound.io/v1beta1 @@ -78,6 +98,10 @@ spec: serverNameSelector: matchControllerRef: true patches: + - type: PatchSet + patchSetName: providerConfigRef + - type: PatchSet + patchSetName: deletionPolicy - fromFieldPath: spec.parameters.clusterRef.id toFieldPath: metadata.name transforms: @@ -99,6 +123,10 @@ spec: serverNameSelector: matchControllerRef: true patches: + - type: PatchSet + patchSetName: providerConfigRef + - type: PatchSet + patchSetName: deletionPolicy - fromFieldPath: spec.parameters.clusterRef.id toFieldPath: metadata.name transforms: diff --git a/apis/database/sqlinstance/composition-postgresql.yaml b/apis/database/sqlinstance/postgresql/composition.yaml similarity index 75% rename from apis/database/sqlinstance/composition-postgresql.yaml rename to apis/database/sqlinstance/postgresql/composition.yaml index cfdaa8b..370b49e 100644 --- a/apis/database/sqlinstance/composition-postgresql.yaml +++ b/apis/database/sqlinstance/postgresql/composition.yaml @@ -10,6 +10,22 @@ spec: compositeTypeRef: apiVersion: azure.platformref.upbound.io/v1alpha1 kind: XSQLInstance + 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: postgresqlserver base: @@ -19,16 +35,21 @@ spec: forProvider: version: "11" administratorLogin: psqladmin - location: West US 2 skuName: GP_Gen5_2 storageMb: 5120 sslEnforcementEnabled: false sslMinimalTlsVersionEnforced: TLSEnforcementDisabled identity: - - type: SystemAssigned + - type: SystemAssigned # due to: https://github.com/Azure/azure-rest-api-specs/issues/9571 infrastructureEncryptionEnabled: false patches: + - type: PatchSet + patchSetName: providerConfigRef + - type: PatchSet + patchSetName: deletionPolicy + - type: PatchSet + patchSetName: region - fromFieldPath: spec.parameters.clusterRef.id toFieldPath: metadata.name transforms: @@ -40,15 +61,15 @@ spec: - fromFieldPath: metadata.uid toFieldPath: spec.writeConnectionSecretToRef.name transforms: - - type: string - string: - fmt: "%s-postgresql" + - type: string + string: + fmt: "%s-postgresql" - fromFieldPath: spec.parameters.storageGB toFieldPath: spec.forProvider.storageMb transforms: - - type: math - math: - multiply: 1024 + - type: math + math: + multiply: 1024 - fromFieldPath: spec.parameters.clusterRef.id toFieldPath: spec.forProvider.resourceGroupNameSelector.matchLabels[azure.platformref.upbound.io/network-id] - fromFieldPath: spec.parameters.passwordSecretRef.namespace @@ -70,7 +91,6 @@ spec: - type: FromConnectionSecretKey name: port fromConnectionSecretKey: port - # db-server vnet-rule for subnet where AKS lives in - name: vnetrule base: apiVersion: dbforpostgresql.azure.upbound.io/v1beta1 @@ -80,6 +100,10 @@ spec: serverNameSelector: matchControllerRef: true patches: + - type: PatchSet + patchSetName: providerConfigRef + - type: PatchSet + patchSetName: deletionPolicy - fromFieldPath: spec.parameters.clusterRef.id toFieldPath: metadata.name transforms: diff --git a/crossplane.yaml b/crossplane.yaml index 71194f3..ecff72d 100644 --- a/crossplane.yaml +++ b/crossplane.yaml @@ -37,14 +37,16 @@ spec: version: ">=v1.12.1-0" dependsOn: - provider: xpkg.upbound.io/upbound/provider-family-azure - version: ">=v0.33.0" + version: "v0.37.0" - provider: xpkg.upbound.io/upbound/provider-azure-containerservice - version: ">=v0.33.0" + version: "v0.37.0" - provider: xpkg.upbound.io/upbound/provider-azure-dbformariadb - version: ">=v0.33.0" + version: "v0.37.0" - provider: xpkg.upbound.io/upbound/provider-azure-dbforpostgresql - version: ">=v0.33.0" + version: "v0.37.0" - provider: xpkg.upbound.io/upbound/provider-azure-network - version: ">=v0.33.0" + version: "v0.37.0" - provider: xpkg.upbound.io/crossplane-contrib/provider-helm version: ">=v0.15.0" + - provider: xpkg.upbound.io/crossplane-contrib/provider-kubernetes + version: ">=v0.9.0" diff --git a/examples/app-claim.yaml b/examples/app-claim.yaml index f2cbc5b..b19b1d3 100644 --- a/examples/app-claim.yaml +++ b/examples/app-claim.yaml @@ -3,13 +3,12 @@ kind: App metadata: name: platform-ref-azure-ghost namespace: default - annotations: - uptest.upbound.io/pre-delete-hook: testhooks/delete-release-app.sh spec: - providerConfigRef: - name: platform-ref-azure - passwordSecretRef: - namespace: default - name: platform-ref-azure-db-conn-mariadb + compositeDeletePolicy: Foreground + parameters: + providerConfigName: platform-ref-azure + passwordSecretRef: + namespace: default + name: platform-ref-azure-db-conn-mariadb writeConnectionSecretToRef: name: platform-ref-azure-app-conn diff --git a/examples/cluster-claim.yaml b/examples/cluster-claim.yaml index f608583..af4dd7d 100644 --- a/examples/cluster-claim.yaml +++ b/examples/cluster-claim.yaml @@ -3,17 +3,14 @@ kind: Cluster metadata: name: platform-ref-azure namespace: default - annotations: - uptest.upbound.io/pre-delete-hook: testhooks/delete-release.sh spec: - id: platform-ref-azure + compositeDeletePolicy: Foreground parameters: + id: platform-ref-azure + region: westus + version: "1.27.3" nodes: - count: 1 #1-100 - size: small #small/medium/large - services: - operators: - prometheus: - version: "15.0.1" + count: 3 + instanceType: Standard_B2s writeConnectionSecretToRef: - name: platform-ref-azure-kubeconfig #Must be unique for each instance + name: platform-ref-azure-kubeconfig diff --git a/examples/configuration.yaml b/examples/configuration.yaml index dc0622c..38e74d0 100644 --- a/examples/configuration.yaml +++ b/examples/configuration.yaml @@ -3,4 +3,4 @@ kind: Configuration metadata: name: upbound-platform-ref-azure spec: - package: xpkg.upbound.io/upbound/platform-ref-azure:v0.7.0 + package: xpkg.upbound.io/upbound/platform-ref-azure:v0.8.0 diff --git a/examples/mariadb-claim.yaml b/examples/mariadb-claim.yaml index 114e98e..c46a4b2 100644 --- a/examples/mariadb-claim.yaml +++ b/examples/mariadb-claim.yaml @@ -8,6 +8,7 @@ spec: matchLabels: dbengine: mariadb parameters: + region: westus storageGB: 5 #Minimum value is 5 passwordSecretRef: namespace: default diff --git a/examples/network-xr.yaml b/examples/network-xr.yaml index 61ca40e..bf54785 100644 --- a/examples/network-xr.yaml +++ b/examples/network-xr.yaml @@ -3,4 +3,6 @@ kind: XNetwork metadata: name: ref-azure-network spec: - id: ref-azure-network-from-xr + parameters: + id: ref-azure-network-from-xr + region: westus diff --git a/examples/postgres-claim.yaml b/examples/postgres-claim.yaml index c69f473..626beae 100644 --- a/examples/postgres-claim.yaml +++ b/examples/postgres-claim.yaml @@ -8,6 +8,7 @@ spec: matchLabels: dbengine: postgresql parameters: + region: westus storageGB: 5 #Minimum value is 5 passwordSecretRef: namespace: default diff --git a/examples/testhooks/delete-release-app.sh b/examples/testhooks/delete-release-app.sh deleted file mode 100755 index f85445f..0000000 --- a/examples/testhooks/delete-release-app.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -set -aeuo pipefail - -# Delete the release before deleting the cluster not to orphan the release object -# Note(turkenh): This is a workaround for the infamous dependency problem during deletion. -# Note(ytsarev): In addition to helm Release deletion we also need to pause -# XService reconciler to prevent it from recreating the Release. -${KUBECTL} annotate --overwrite xapps.azure.platformref.upbound.io --all crossplane.io/paused="true" -${KUBECTL} delete release -l crossplane.io/claim-name=platform-ref-azure-ghost diff --git a/examples/testhooks/delete-release.sh b/examples/testhooks/delete-release.sh deleted file mode 100755 index 5273360..0000000 --- a/examples/testhooks/delete-release.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -set -aeuo pipefail - -# Delete the release before deleting the cluster not to orphan the release object -# Note(turkenh): This is a workaround for the infamous dependency problem during deletion. -# Note(ytsarev): In addition to helm Release deletion we also need to pause -# XService reconciler to prevent it from recreating the Release. -${KUBECTL} annotate --overwrite xservices.azure.platformref.upbound.io --all crossplane.io/paused="true" -${KUBECTL} delete release -l crossplane.io/claim-name=platform-ref-azure diff --git a/test/setup.sh b/test/setup.sh index 000a0d1..b8a3f51 100755 --- a/test/setup.sh +++ b/test/setup.sh @@ -3,24 +3,24 @@ set -aeuo pipefail echo "Running setup.sh" echo "Waiting until configuration package is healthy/installed..." -${KUBECTL} wait configuration.pkg platform-ref-azure --for=condition=Healthy --timeout 5m -${KUBECTL} wait configuration.pkg platform-ref-azure --for=condition=Installed --timeout 5m +"${KUBECTL}" wait configuration.pkg platform-ref-azure --for=condition=Healthy --timeout 5m +"${KUBECTL}" wait configuration.pkg platform-ref-azure --for=condition=Installed --timeout 5m echo "Creating cloud credential secret..." -${KUBECTL} -n upbound-system create secret generic azure-creds --from-literal=credentials="${UPTEST_CLOUD_CREDENTIALS}" \ - --dry-run=client -o yaml | ${KUBECTL} apply -f - +"${KUBECTL}" -n upbound-system create secret generic azure-creds --from-literal=credentials="${UPTEST_CLOUD_CREDENTIALS}" \ + --dry-run=client -o yaml | "${KUBECTL}" apply -f - echo "Waiting until all installed provider packages are healthy..." -${KUBECTL} wait provider.pkg --all --for condition=Healthy --timeout 5m +"${KUBECTL}" wait provider.pkg --all --for condition=Healthy --timeout 5m echo "Waiting for all pods to come online..." "${KUBECTL}" -n upbound-system wait --for=condition=Available deployment --all --timeout=5m echo "Waiting for all XRDs to be established..." -kubectl wait xrd --all --for condition=Established +"${KUBECTL}" wait xrd --all --for condition=Established echo "Creating a default provider config..." -cat <