Skip to content

Commit

Permalink
Merge pull request #2 from ytsarev/app-config
Browse files Browse the repository at this point in the history
Add App Configuration
  • Loading branch information
ytsarev authored Oct 31, 2023
2 parents 5602b85 + e2851ab commit 4608852
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 34 deletions.
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ XPKGS = $(PROJECT_NAME)
-include build/makelib/xpkg.mk

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

Expand Down Expand Up @@ -58,12 +58,9 @@ build.init: $(UP)
# ====================================================================================
# End to End Testing

# This target requires the following environment variables to be set:
# - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat ~/.aws/credentials)
# - 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/eks-xr.yaml,examples/network-xr.yaml --data-source="${UPTEST_DATASOURCE_PATH}" --setup-script=test/setup.sh --default-timeout=2400 || $(FAIL)
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e examples/app-claim.yaml --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
72 changes: 72 additions & 0 deletions apis/composition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: xapps.platform.upbound.io
labels:
provider: helm
spec:
writeConnectionSecretsToNamespace: upbound-system
compositeTypeRef:
apiVersion: platform.upbound.io/v1alpha1
kind: XApp
resources:
- name: helmRelease
base:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
spec:
rollbackLimit: 3
forProvider:
namespace: ghost
chart:
name: ghost
repository: https://charts.bitnami.com/bitnami
version: "19.3.10"
values:
persistence:
enabled: false
mysql:
enabled: false
externalDatabase:
database: upbound
port: 3306
ghostHost: upboundrocks.cloud
ghostBlogTitle: Upbound Rocks!
set:
- name: externalDatabase.host
valueFrom:
secretKeyRef:
key: host
- name: externalDatabase.user
valueFrom:
secretKeyRef:
key: username
- name: externalDatabase.password
valueFrom:
secretKeyRef:
key: password
patches:
# 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.parameters.providerConfigName
toFieldPath: spec.providerConfigRef.name
- fromFieldPath: spec.parameters.deletionPolicy
toFieldPath: spec.deletionPolicy
- fromFieldPath: spec.parameters.helm.chart.version
toFieldPath: spec.forProvider.chart.version
- fromFieldPath: spec.parameters.passwordSecretRef.namespace
toFieldPath: spec.forProvider.set[0].valueFrom.secretKeyRef.namespace
- fromFieldPath: spec.parameters.passwordSecretRef.name
toFieldPath: spec.forProvider.set[0].valueFrom.secretKeyRef.name
- fromFieldPath: spec.parameters.passwordSecretRef.namespace
toFieldPath: spec.forProvider.set[1].valueFrom.secretKeyRef.namespace
- fromFieldPath: spec.parameters.passwordSecretRef.name
toFieldPath: spec.forProvider.set[1].valueFrom.secretKeyRef.name
- fromFieldPath: spec.parameters.passwordSecretRef.namespace
toFieldPath: spec.forProvider.set[2].valueFrom.secretKeyRef.namespace
- fromFieldPath: spec.parameters.passwordSecretRef.name
toFieldPath: spec.forProvider.set[2].valueFrom.secretKeyRef.name
68 changes: 68 additions & 0 deletions apis/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.platform.upbound.io
spec:
defaultCompositeDeletePolicy: Foreground
group: platform.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
14 changes: 14 additions & 0 deletions examples/app-claim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: platform.upbound.io/v1alpha1
kind: App
metadata:
name: configuration-app
namespace: default
spec:
compositeDeletePolicy: Foreground
parameters:
providerConfigName: uptest
passwordSecretRef:
namespace: default
name: configuration-app-mariadb
writeConnectionSecretToRef:
name: configuration-app
6 changes: 6 additions & 0 deletions examples/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: pkg.crossplane.io/v1
kind: Configuration
metadata:
name: configuration-app
spec:
package: xpkg.upbound.io/upbound/configuration-app:v0.1.0
49 changes: 20 additions & 29 deletions test/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,11 @@
set -aeuo pipefail

echo "Running setup.sh"
echo "Installing transient Configuration dependencies"
cat <<EOF | "${KUBECTL}" apply -f -
---
apiVersion: pkg.crossplane.io/v1
kind: Configuration
metadata:
name: cofiguration-aws-database
spec:
package: xpkg.upbound.io/upbound/configuration-aws-database:v0.1.0
---
apiVersion: pkg.crossplane.io/v1
kind: Configuration
metadata:
name: cofiguration-aws-eks
spec:
package: xpkg.upbound.io/upbound/configuration-aws-eks:v0.1.0
EOF

echo "Waiting until all configurations are healthy/installed..."
"${KUBECTL}" wait configuration.pkg --all --for=condition=Healthy --timeout 5m
"${KUBECTL}" wait configuration.pkg --all --for=condition=Installed --timeout 5m

echo "Creating cloud credential secret..."
"${KUBECTL}" -n upbound-system create secret generic aws-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

Expand All @@ -37,17 +16,29 @@ echo "Waiting for all pods to come online..."
echo "Waiting for all XRDs to be established..."
"${KUBECTL}" wait xrd --all --for condition=Established

echo "Creating a default provider config..."
echo "Setting up helm provider config pointing to the local cluster..."
SA=$("${KUBECTL}" -n upbound-system get sa -o name | grep provider-helm | sed -e 's|serviceaccount\/|upbound-system:|g')
"${KUBECTL}" create clusterrolebinding provider-helm-admin-binding --clusterrole cluster-admin --serviceaccount="${SA}"
cat <<EOF | "${KUBECTL}" apply -f -
apiVersion: aws.upbound.io/v1beta1
apiVersion: helm.crossplane.io/v1beta1
kind: ProviderConfig
metadata:
name: default
name: uptest
spec:
credentials:
secretRef:
key: credentials
name: aws-creds
namespace: upbound-system
source: Secret
source: InjectedIdentity
EOF

echo "Setting up fake mariadb connection secret..."
cat <<EOF | "${KUBECTL}" apply -f -
apiVersion: v1
data:
endpoint: Y29uZmlndXJhdGlvbi1hcHAtZGF0YWJhc2UtbWFyaWFkYi1xdGNnbS1xNXMyNC5jeGFsMWxvbXpuYmEudXMtd2VzdC0yLnJkcy5hbWF6b25hd3MuY29tOjMzMDY=
host: Y29uZmlndXJhdGlvbi1hcHAtZGF0YWJhc2UtbWFyaWFkYi1xdGNnbS1xNXMyNC5jeGFsMWxvbXpuYmEudXMtd2VzdC0yLnJkcy5hbWF6b25hd3MuY29t
password: b3hIbzZZOTZQMDJHWERwMm9kejZDYTcyREY2
username: bWFzdGVydXNlcg==
kind: Secret
metadata:
name: configuration-app-mariadb
namespace: default
EOF

0 comments on commit 4608852

Please sign in to comment.