Skip to content

Commit

Permalink
feat(caas): backport from caas (#116)
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Haar <christopher.haar@upbound.io>
  • Loading branch information
haarchri authored Oct 16, 2023
1 parent c972e0c commit 951c1a2
Show file tree
Hide file tree
Showing 35 changed files with 1,379 additions and 838 deletions.
1 change: 1 addition & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ jobs:
package-type: configuration
secrets:
UPTEST_CLOUD_CREDENTIALS: ${{ secrets.UPTEST_CLOUD_CREDENTIALS }}
UPTEST_DATASOURCE: ${{ secrets.UPTEST_DATASOURCE }}
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ PLATFORMS ?= linux_amd64
# ====================================================================================
# Setup Kubernetes tools

UP_VERSION = v0.18.0
UP_VERSION = v0.19.1
UP_CHANNEL = stable
UPTEST_VERSION = v0.2.1
UPTEST_VERSION = v0.5.0

-include build/makelib/k8s_tools.mk
# ====================================================================================
# Setup XPKG
XPKG_DIR = $(shell pwd)
XPKG_IGNORE = .github/workflows/*.yaml,.github/workflows/*.yml,examples/*.yaml,.work/uptest-datasource.yaml
XPKG_REG_ORGS ?= xpkg.upbound.io/upbound
# NOTE(hasheddan): skip promoting on xpkg.upbound.io as channel tags are
# inferred.
Expand All @@ -26,7 +28,7 @@ XPKGS = $(PROJECT_NAME)
-include build/makelib/xpkg.mk

CROSSPLANE_NAMESPACE = upbound-system
CROSSPLANE_ARGS = "--enable-environment-configs"
CROSSPLANE_ARGS = "--enable-usages"
-include build/makelib/local.xpkg.mk
-include build/makelib/controlplane.mk

Expand Down Expand Up @@ -60,9 +62,10 @@ build.init: $(UP)
# - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat ~/.aws/credentials)
# - To ensure the proper functioning of the end-to-end test resource pre-deletion hook, it is crucial to arrange your resources appropriately.
# You can check the basic implementation here: https://github.com/upbound/uptest/blob/main/internal/templates/01-delete.yaml.tmpl.
# - UPTEST_DATASOURCE_PATH (optional), see https://github.com/upbound/uptest#injecting-dynamic-values-and-datasource
uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
@$(INFO) running automated tests
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e examples/app-claim.yaml,examples/mariadb-claim.yaml,examples/cluster-claim.yaml --setup-script=test/setup.sh --default-timeout=2400 || $(FAIL)
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e examples/app-claim.yaml,examples/mariadb-claim.yaml,examples/cluster-claim.yaml --data-source="${UPTEST_DATASOURCE_PATH}" --setup-script=test/setup.sh --default-timeout=2400 || $(FAIL)
@$(OK) running automated tests

# This target requires the following environment variables to be set:
Expand Down
35 changes: 27 additions & 8 deletions package/app/composition.yaml → 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: aws.platformref.upbound.io/v1alpha1
kind: XEKS
by:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
resourceSelector:
matchControllerRef: true
patches:
- fromFieldPath: spec.parameters.providerConfigName
toFieldPath: spec.of.resourceSelector.matchLabels[xeks.aws.platformref.upbound.io/cluster-id]
68 changes: 68 additions & 0 deletions apis/app/definition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
name: xapps.aws.platformref.upbound.io
spec:
defaultCompositeDeletePolicy: Foreground
group: aws.platformref.upbound.io
names:
kind: XApp
plural: xapps
claimNames:
kind: App
plural: apps
versions:
- name: v1alpha1
served: true
referenceable: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
parameters:
type: object
description: App configuration parameters.
properties:
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
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:
- providerConfigName
110 changes: 110 additions & 0 deletions apis/cluster/composition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: xclusters.aws.platformref.upbound.io
spec:
writeConnectionSecretsToNamespace: upbound-system
compositeTypeRef:
apiVersion: aws.platformref.upbound.io/v1alpha1
kind: XCluster
resources:
- base:
apiVersion: aws.platformref.upbound.io/v1alpha1
kind: XNetwork
patches:
- 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]
- type: ToCompositeFieldPath
fromFieldPath: status.subnetIds
toFieldPath: status.subnetIds
policy:
fromFieldPath: Required
name: compositeNetworkEKS
- base:
apiVersion: aws.platformref.upbound.io/v1alpha1
kind: XEKS
connectionDetails:
- fromConnectionSecretKey: kubeconfig
name: compositeClusterEKS
patches:
- fromFieldPath: spec.parameters.id
toFieldPath: metadata.labels[xeks.aws.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: spec.parameters.id
toFieldPath: metadata.annotations[crossplane.io/external-name]
- fromFieldPath: metadata.uid
toFieldPath: spec.writeConnectionSecretToRef.name
transforms:
- type: string
string:
fmt: "%s-eks"
- 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.instanceType
toFieldPath: spec.parameters.nodes.instanceType
- fromFieldPath: spec.parameters.iam.roleArn
toFieldPath: spec.parameters.iam.roleArn
- fromFieldPath: spec.parameters.iam.userArn
toFieldPath: spec.parameters.iam.userArn
- fromFieldPath: status.subnetIds
toFieldPath: spec.parameters.subnetIds
policy:
fromFieldPath: Required
- base:
apiVersion: aws.platformref.upbound.io/v1alpha1
kind: XServices
name: compositeClusterServices
patches:
- 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: usageXEksByXService
base:
apiVersion: apiextensions.crossplane.io/v1alpha1
kind: Usage
spec:
of:
apiVersion: aws.platformref.upbound.io/v1alpha1
kind: XEKS
resourceSelector:
matchControllerRef: true
by:
apiVersion: aws.platformref.upbound.io/v1alpha1
kind: XServices
resourceSelector:
matchControllerRef: true
Loading

0 comments on commit 951c1a2

Please sign in to comment.