From 1aba27a2f1f273b1e586fe2e07a2dfa49f59f88f Mon Sep 17 00:00:00 2001 From: Christopher Haar Date: Wed, 24 Jan 2024 21:31:54 +0100 Subject: [PATCH] feat(functions): use configurations, update to functions (#49) * feat(functions): use configurations, update to functions Signed-off-by: Christopher Haar * feat(readme): add family provider for readme Signed-off-by: Christopher Haar --------- Signed-off-by: Christopher Haar --- .github/renovate.json5 | 42 ++++ .github/workflows/yamllint.yaml | 15 ++ .yamllint | 5 + Makefile | 19 +- README.md | 60 ++--- apis/cluster/composition.yaml | 173 +++++++++++++++ apis/cluster/definition.yaml | 177 +++++++++++++++ build | 2 +- package/crossplane.yaml => crossplane.yaml | 39 ++-- examples/app-claim.yaml | 16 ++ examples/cluster-claim.yaml | 31 +-- examples/configuration.yaml | 6 +- examples/functions.yaml | 6 + examples/network-xr.yaml | 6 - examples/postgres-claim.yaml | 12 +- examples/testhooks/delete-release.sh | 10 - examples/testhooks/delete-sql-user.sh | 7 - .../crossplane-cluster-admin-rolebinding.yaml | 12 - package/cluster/composition.yaml | 48 ---- package/cluster/definition.yaml | 73 ------- package/cluster/gke/composition.yaml | 205 ------------------ package/cluster/gke/definition.yaml | 74 ------- package/cluster/network/composition.yaml | 45 ---- package/cluster/network/definition.yaml | 25 --- package/cluster/services/composition.yaml | 38 ---- package/cluster/services/definition.yaml | 45 ---- package/database/postgres/composition.yaml | 79 ------- package/database/postgres/definition.yaml | 61 ------ test/setup.sh | 15 +- 29 files changed, 533 insertions(+), 813 deletions(-) create mode 100644 .github/renovate.json5 create mode 100644 .github/workflows/yamllint.yaml create mode 100644 .yamllint create mode 100644 apis/cluster/composition.yaml create mode 100644 apis/cluster/definition.yaml rename package/crossplane.yaml => crossplane.yaml (58%) create mode 100644 examples/app-claim.yaml create mode 100644 examples/functions.yaml delete mode 100644 examples/network-xr.yaml delete mode 100755 examples/testhooks/delete-release.sh delete mode 100755 examples/testhooks/delete-sql-user.sh delete mode 100644 hack/crossplane-cluster-admin-rolebinding.yaml delete mode 100644 package/cluster/composition.yaml delete mode 100644 package/cluster/definition.yaml delete mode 100644 package/cluster/gke/composition.yaml delete mode 100644 package/cluster/gke/definition.yaml delete mode 100644 package/cluster/network/composition.yaml delete mode 100644 package/cluster/network/definition.yaml delete mode 100644 package/cluster/services/composition.yaml delete mode 100644 package/cluster/services/definition.yaml delete mode 100644 package/database/postgres/composition.yaml delete mode 100644 package/database/postgres/definition.yaml diff --git a/.github/renovate.json5 b/.github/renovate.json5 new file mode 100644 index 0000000..f43c59f --- /dev/null +++ b/.github/renovate.json5 @@ -0,0 +1,42 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended", + "helpers:pinGitHubActionDigests", + ":semanticCommits" + ], + "rebaseWhen": "conflicted", + "prConcurrentLimit": 5, + "baseBranches": ["main"], + "labels": ["automated"], + "customManagers": [ + { + "customType": "regex", + "description": "Bump up version in the Makefile", + "fileMatch": ["^Makefile$"], + "matchStrings": [ + "UP_VERSION = (?.*?)\\n" + ], + "datasourceTemplate": "github-releases", + "depNameTemplate": "upbound/up", + }, { + "customType": "regex", + "description": "Bump uptest version in the Makefile", + "fileMatch": ["^Makefile$"], + "matchStrings": [ + "UPTEST_VERSION = (?.*?)\\n" + ], + "datasourceTemplate": "github-releases", + "depNameTemplate": "upbound/uptest", + }, { + "customType": "regex", + "description": "Bump providers/functions/configurations in crossplane.yaml", + "fileMatch": ["crossplane.yaml"], + "matchStrings": [ + "#\\s*renovate:\\s*datasource=(?[^\\s]+)\\s+depName=(?[^\\s]+)\\s*\\n\\s*version:\\s*\"(?[^\"]+)\"" + ], + "datasourceTemplate": "{{{datasource}}}", + "depNameTemplate": "{{{depName}}}", + } + ], +} diff --git a/.github/workflows/yamllint.yaml b/.github/workflows/yamllint.yaml new file mode 100644 index 0000000..16a78d3 --- /dev/null +++ b/.github/workflows/yamllint.yaml @@ -0,0 +1,15 @@ +name: yamllint +on: [pull_request] +jobs: + yamllint: + name: runner / yamllint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: yamllint + uses: reviewdog/action-yamllint@v1.9.0 + with: + reporter: github-pr-review + filter_mode: nofilter + yamllint_flags: 'apis/' + fail_on_error: true diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..669c864 --- /dev/null +++ b/.yamllint @@ -0,0 +1,5 @@ +extends: default + +rules: + line-length: disable + document-start: disable diff --git a/Makefile b/Makefile index c256850..7475645 100644 --- a/Makefile +++ b/Makefile @@ -11,13 +11,15 @@ PLATFORMS ?= linux_amd64 # ==================================================================================== # Setup Kubernetes tools -UP_VERSION = v0.14.0 +UP_VERSION = v0.21.0 UP_CHANNEL = stable -UPTEST_VERSION = v0.2.1 +UPTEST_VERSION = v0.9.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. @@ -26,6 +28,7 @@ XPKGS = $(PROJECT_NAME) -include build/makelib/xpkg.mk CROSSPLANE_NAMESPACE = upbound-system +CROSSPLANE_ARGS = "--enable-usages" -include build/makelib/local.xpkg.mk -include build/makelib/controlplane.mk @@ -59,11 +62,19 @@ build.init: $(UP) # - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat gcp-sa.json) uptest: $(UPTEST) $(KUBECTL) $(KUTTL) @$(INFO) running automated tests - @KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e examples/cluster-claim.yaml,examples/postgres-claim.yaml --setup-script=test/setup.sh --default-timeout=3600 || $(FAIL) + @KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) $(UPTEST) e2e examples/cluster-claim.yaml,examples/postgres-claim.yaml --setup-script=test/setup.sh --default-timeout=3600 || $(FAIL) @$(OK) running automated tests # 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 gcp-sa.json) e2e: build controlplane.up local.xpkg.deploy.configuration.$(PROJECT_NAME) uptest -.PHONY: uptest e2e \ No newline at end of file +render: + crossplane beta render examples/cluster-claim.yaml apis/cluster/composition.yaml examples/functions.yaml -r + +yamllint: + @$(INFO) running yamllint + @yamllint ./apis || $(FAIL) + @$(OK) running yamllint + +.PHONY: uptest e2e render yamllint diff --git a/README.md b/README.md index 5abb3c5..128a6aa 100644 --- a/README.md +++ b/README.md @@ -9,18 +9,21 @@ This platform provides APIs to provision fully configured GKE clusters, with secure networking, and stateful cloud services (Cloud SQL for PostgreSQL) designed to securely connect to the nodes in each GKE cluster — all composed using cloud service primitives from the [Official Upbound GCP -Provider](https://marketplace.upbound.io/providers/upbound/provider-gcp). App +Provider](https://marketplace.upbound.io/providers/upbound/provider-family-gcp/). App deployments can securely connect to the infrastructure they need using secrets distributed directly to the app namespace. ## Overview -This reference platform defines a custom API for creating an GKE cluster -([XCluster](package/cluster/definition.yaml)) which includes the actual GKE -cluster, a network fabric and Prometheus and other cluster services -([XServices](package/cluster/composition.yaml)). Additionally it defines a -custom API for provisioning Postgres Databases -([XPostgreSQLInstance](package/database/postgres/definition.yaml)). +This reference platform outlines a specialized API for generating an GKE cluster +([XCluster](apis/cluster/definition.yaml)) that incorporates XRs from the specified configurations: + +* [upbound-configuration-app](https://github.com/upbound/configuration-app) +* [upbound-configuration-gcp-database](https://github.com/upbound/configuration-gcp-database) +* [upbound-configuration-gcp-gke](https://github.com/upbound/configuration-gcp-gke) +* [upbound-configuration-gcp-network](https://github.com/upbound/configuration-gcp-network) +* [upbound-configuration-gitops-flux](https://github.com/upbound/configuration-gitops-flux) +* [upbound-configuration-observability-oss](https://github.com/upbound/configuration-observability-oss) ```mermaid @@ -55,7 +58,7 @@ style Postgres.MRs color:#000,fill:#81CABB,stroke:#000,stroke-width:2px ``` Learn more about Composite Resources in the [Crossplane -Docs](https://crossplane.io/docs/v1.9/concepts/composition.html). +Docs](https://docs.crossplane.io/latest/concepts/compositions/). ## Quickstart @@ -98,11 +101,11 @@ kubectl get all -n upbound-system ### Install the GCP Reference Platform Now you can install this reference platform. It's packaged as a [Crossplane -configuration package](https://crossplane.io/docs/v1.9/concepts/packages.html) -so there is a single command to install this package: +configuration package](https://docs.crossplane.io/latest/concepts/packages/) +so there is a single command to install it: ```console -up ctp configuration install xpkg.upbound.io/upbound/platform-ref-gcp:v0.3.0 +up ctp configuration install xpkg.upbound.io/upbound/platform-ref-gcp:v0.5.0 ``` Validate the install by inspecting the provider and configuration packages: @@ -210,22 +213,28 @@ To delete the provisioned resources, you would simply delete the claims again: kubectl delete -f examples/cluster-claim.yaml,examples/postgres-claim.yaml ``` -**NOTE**: until [ordered -deletion](https://github.com/crossplane/crossplane/issues/3393) is implemented -in core Crossplane, we have to manually cleanup Helm Release and SQL User object -fist: - -```console -kubectl delete release.helm.crossplane.io ${release_name} -kubectl delete user.sql.gcp.upbound.io ${sql_user_name} -``` - To uninstall the provider & platform configuration: ```console kubectl delete configurations.pkg.crossplane.io upbound-platform-ref-gcp -kubectl delete providers.pkg.crossplane.io upbound-provider-gcp -kubectl delete providers.pkg.crossplane.io crossplane-contrib-provider-helm +kubectl delete configurations.pkg.crossplane.io upbound-configuration-app +kubectl delete configurations.pkg.crossplane.io upbound-configuration-gcp-database +kubectl delete configurations.pkg.crossplane.io upbound-configuration-gcp-gke +kubectl delete configurations.pkg.crossplane.io upbound-configuration-gcp-network +kubectl delete configurations.pkg.crossplane.io upbound-configuration-gitops-flux +kubectl delete configurations.pkg.crossplane.io upbound-configuration-observability-oss + +kubectl delete provider.pkg.crossplane.io crossplane-contrib-provider-helm +kubectl delete provider.pkg.crossplane.io crossplane-contrib-provider-kubernetes +kubectl delete provider.pkg.crossplane.io grafana-provider-grafana +kubectl delete provider.pkg.crossplane.io upbound-provider-family-gcp +kubectl delete provider.pkg.crossplane.io upbound-provider-gcp-cloudplatform +kubectl delete provider.pkg.crossplane.io upbound-provider-gcp-compute +kubectl delete provider.pkg.crossplane.io upbound-provider-gcp-container +kubectl delete provider.pkg.crossplane.io upbound-provider-gcp-servicenetworking +kubectl delete provider.pkg.crossplane.io upbound-provider-gcp-sql + +kubectl delete function.pkg.crossplane.io upbound-function-patch-and-transform ``` ## Customize for your Organization @@ -259,11 +268,6 @@ To make your changes clone this repository: git clone https://github.com/upbound/platform-ref-gcp.git $PLATFORM && cd $PLATFORM ``` -In the [GKE composition](package/cluster/gke/composition.yaml) find the -`location` definitions and change them from `us-west2` to `europe-central2`. Also find the -`autoscaling[0].maxNodeCount` and change it from `3` to `10`. - - ### Build and push your platform To share your new platform you need to build and distribute this package. diff --git a/apis/cluster/composition.yaml b/apis/cluster/composition.yaml new file mode 100644 index 0000000..1a88327 --- /dev/null +++ b/apis/cluster/composition.yaml @@ -0,0 +1,173 @@ +apiVersion: apiextensions.crossplane.io/v1 +kind: Composition +metadata: + name: xclusters.gcp.platformref.upbound.io +spec: + writeConnectionSecretsToNamespace: upbound-system + compositeTypeRef: + apiVersion: gcp.platformref.upbound.io/v1alpha1 + kind: XCluster + mode: Pipeline + pipeline: + - step: patch-and-transform + functionRef: + name: upbound-function-patch-and-transform + input: + apiVersion: pt.fn.crossplane.io/v1beta1 + kind: Resources + resources: + - name: XNetwork + base: + apiVersion: gcp.platform.upbound.io/v1alpha1 + kind: XNetwork + patches: + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.id + toFieldPath: spec.parameters.id + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.region + toFieldPath: spec.parameters.region + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.deletionPolicy + toFieldPath: spec.parameters.deletionPolicy + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.providerConfigName + toFieldPath: spec.parameters.providerConfigName + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.networkSelector + toFieldPath: spec.compositionSelector.matchLabels[type] + + - name: XGKE + base: + apiVersion: gcp.platform.upbound.io/v1alpha1 + kind: XGKE + connectionDetails: + - type: FromConnectionSecretKey + fromConnectionSecretKey: kubeconfig + name: kubeconfig + patches: + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.id + toFieldPath: metadata.labels[xgke.gcp.platform.upbound.io/cluster-id] + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.id + toFieldPath: spec.parameters.id + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.region + toFieldPath: spec.parameters.region + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.deletionPolicy + toFieldPath: spec.parameters.deletionPolicy + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.providerConfigName + toFieldPath: spec.parameters.providerConfigName + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.id + toFieldPath: metadata.annotations[crossplane.io/external-name] + - type: FromCompositeFieldPath + fromFieldPath: metadata.uid + toFieldPath: spec.writeConnectionSecretToRef.name + transforms: + - type: string + string: + fmt: '%s-gke' + type: Format + - type: FromCompositeFieldPath + fromFieldPath: spec.writeConnectionSecretToRef.namespace + toFieldPath: spec.writeConnectionSecretToRef.namespace + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.version + toFieldPath: spec.parameters.version + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.nodes.count + toFieldPath: spec.parameters.nodes.count + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.nodes.instanceType + toFieldPath: spec.parameters.nodes.instanceType + + - name: XOss + base: + apiVersion: observe.platform.upbound.io/v1alpha1 + kind: XOss + patches: + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.deletionPolicy + toFieldPath: spec.parameters.deletionPolicy + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.id + toFieldPath: spec.parameters.id + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.operators.prometheus.version + toFieldPath: spec.parameters.operators.prometheus.version + + - name: XFlux + base: + apiVersion: gitops.platform.upbound.io/v1alpha1 + kind: XFlux + patches: + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.deletionPolicy + toFieldPath: spec.parameters.deletionPolicy + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.id + toFieldPath: spec.parameters.providerConfigName + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.operators.flux.version + toFieldPath: spec.parameters.operators.flux.version + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.operators.flux-sync.version + toFieldPath: spec.parameters.operators.flux-sync.version + - type: FromCompositeFieldPath + fromFieldPath: spec.parameters.gitops + toFieldPath: spec.parameters.source + + - name: usageXGkeByXFlux + base: + apiVersion: apiextensions.crossplane.io/v1alpha1 + kind: Usage + spec: + by: + apiVersion: gitops.platform.upbound.io/v1alpha1 + kind: XFlux + resourceSelector: + matchControllerRef: true + of: + apiVersion: gcp.platform.upbound.io/v1alpha1 + kind: XGKE + resourceSelector: + matchControllerRef: true + + - name: usageXGkeByXOss + base: + apiVersion: apiextensions.crossplane.io/v1alpha1 + kind: Usage + spec: + by: + apiVersion: observe.platform.upbound.io/v1alpha1 + kind: XOss + resourceSelector: + matchControllerRef: true + of: + apiVersion: gcp.platform.upbound.io/v1alpha1 + kind: XGKE + resourceSelector: + matchControllerRef: true + + - name: usageXGkeByArbitraryLabeledRelease + base: + apiVersion: apiextensions.crossplane.io/v1alpha1 + kind: Usage + spec: + by: + apiVersion: helm.crossplane.io/v1beta1 + kind: Release + resourceSelector: + matchLabels: + platform.upbound.io/deletion-ordering: enabled + of: + apiVersion: gcp.platform.upbound.io/v1alpha1 + kind: XGKE + resourceSelector: + matchControllerRef: true + readinessChecks: + - type: None diff --git a/apis/cluster/definition.yaml b/apis/cluster/definition.yaml new file mode 100644 index 0000000..30e8e6e --- /dev/null +++ b/apis/cluster/definition.yaml @@ -0,0 +1,177 @@ +apiVersion: apiextensions.crossplane.io/v1 +kind: CompositeResourceDefinition +metadata: + name: xclusters.gcp.platformref.upbound.io +spec: + defaultCompositeDeletePolicy: Foreground + group: gcp.platformref.upbound.io + names: + kind: XCluster + plural: xclusters + claimNames: + kind: Cluster + plural: clusters + connectionSecretKeys: + - kubeconfig + versions: + - name: v1alpha1 + served: true + referenceable: true + schema: + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + 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 + 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 + default: latest + nodes: + type: object + description: Cluster node configuration parameters. + properties: + count: + type: integer + description: Desired node count, from 1 to 100. + instanceType: + type: string + description: instance types associated with the Node Group. + default: n1-standard-4 + required: + - count + - instanceType + operators: + description: Configuration for operators. + type: object + default: + flux: + version: "2.10.6" + flux-sync: + version: "1.7.2" + prometheus: + version: "52.1.0" + properties: + flux: + description: Configuration for the Flux GitOps operator. + type: object + properties: + version: + description: flux helm-chart version to run. + type: string + default: "2.10.6" + required: + - version + flux-sync: + description: Configuration for the Flux Sync Helm-Chart. + type: object + properties: + version: + description: flux sync helm-chart version to run. + type: string + default: "1.7.2" + required: + - version + prometheus: + description: Configuration for the Prometheus Helm-Chart. + type: object + properties: + version: + description: prometheus helm-chart version to run. + type: string + default: "52.1.0" + required: + - version + gitops: + description: GitOps configure gitops system + type: object + properties: + git: + type: object + properties: + interval: + default: "5m0s" + description: Interval at which the GitRepository URL is checked for + updates. This interval is approximate and may be subject to jitter + to ensure efficient use of resources. + pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ + type: string + timeout: + default: "60s" + description: Timeout for Git operations like cloning, defaults to + 60s. + pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$ + type: string + url: + description: URL specifies the Git repository URL, it can be an HTTP/S + or SSH address. + pattern: ^(http|https|ssh)://.*$ + type: string + path: + type: string + default: "/" + ref: + description: Reference specifies the Git reference to resolve and + monitor for changes. + type: object + properties: + name: + description: "Name of the reference to check out; takes precedence + over Branch, Tag and SemVer. \n It must be a valid Git reference: + https://git-scm.com/docs/git-check-ref-format#_description Examples: + \"refs/heads/main\", \"refs/tags/v0.1.0\", \"refs/pull/420/head\", + \"refs/merge-requests/1/head\"" + type: string + required: + - interval + - timeout + - url + - path + - ref + required: + - git + required: + - deletionPolicy + - gitops + - id + - nodes + - operators + - providerConfigName + - region + required: + - parameters + status: + type: object + properties: + subnetIds: + type: array + items: + type: string diff --git a/build b/build index cc6539e..75a9fe3 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit cc6539e738e14e5322911639e2173f54dd21c9d0 +Subproject commit 75a9fe3ae6b6de82c5f7ddc6a267617940f16b83 diff --git a/package/crossplane.yaml b/crossplane.yaml similarity index 58% rename from package/crossplane.yaml rename to crossplane.yaml index 9efd5e6..7c02b5a 100644 --- a/package/crossplane.yaml +++ b/crossplane.yaml @@ -15,7 +15,6 @@ metadata: This reference platform `Configuration` for Kubernetes and Data Services is a starting point to build, run, and operate your own internal cloud platform and offer a self-service console and API to your internal teams. - It provides platform APIs to provision fully configured GKE clusters, with secure networking, and stateful cloud services (Cloud SQL) designed to securely connect to the nodes in each GKE cluster -- all composed using @@ -24,28 +23,28 @@ metadata: deployments can securely connect to the infrastructure they need using secrets distributed directly to the app namespace. - [Quickstart - Guide](https://github.com/upbound/platform-ref-gcp/#quickstart) - - [Customize for your - Organization](https://github.com/upbound/platform-ref-gcp/#customize-for-your-organization) - To learn more checkout the [GitHub repo](https://github.com/upbound/platform-ref-gcp/) that you can copy and customize to meet the exact needs of your organization! spec: crossplane: - version: ">=v1.12.1-0" + version: ">=v1.14.1-0" dependsOn: - - provider: xpkg.upbound.io/crossplane-contrib/provider-helm - version: ">=v0.15.0" - - provider: xpkg.upbound.io/upbound/provider-gcp-cloudplatform - version: "v0.33.0" - - provider: xpkg.upbound.io/upbound/provider-gcp-compute - version: "v0.33.0" - - provider: xpkg.upbound.io/upbound/provider-gcp-container - version: "v0.33.0" - - provider: xpkg.upbound.io/upbound/provider-gcp-servicenetworking - version: "v0.33.0" - - provider: xpkg.upbound.io/upbound/provider-gcp-sql - version: "v0.33.0" + - configuration: xpkg.upbound.io/upbound/configuration-gcp-network + # renovate: datasource=github-releases depName=upbound/configuration-gcp-network + version: "v0.1.0" + - configuration: xpkg.upbound.io/upbound/configuration-gcp-gke + # renovate: datasource=github-releases depName=upbound/configuration-gcp-gke + version: "v0.1.0" + - configuration: xpkg.upbound.io/upbound/configuration-gcp-database + # renovate: datasource=github-releases depName=upbound/configuration-gcp-database + version: "v0.1.0" + - configuration: xpkg.upbound.io/upbound/configuration-app + # renovate: datasource=github-releases depName=upbound/configuration-app + version: "v0.2.0" + - configuration: xpkg.upbound.io/upbound/configuration-observability-oss + # renovate: datasource=github-releases depName=upbound/configuration-observability-oss + version: "v0.2.0" + - configuration: xpkg.upbound.io/upbound/configuration-gitops-flux + # renovate: datasource=github-releases depName=upbound/configuration-gitops-flux + version: "v0.2.0" diff --git a/examples/app-claim.yaml b/examples/app-claim.yaml new file mode 100644 index 0000000..64cf842 --- /dev/null +++ b/examples/app-claim.yaml @@ -0,0 +1,16 @@ +apiVersion: platform.upbound.io/v1alpha1 +kind: App +metadata: + name: platform-ref-gcp-ghost + namespace: default + labels: + platform.upbound.io/deletion-ordering: enabled +spec: + compositeDeletePolicy: Foreground + parameters: + providerConfigName: platform-ref-gcp + passwordSecretRef: + namespace: default + name: platform-ref-gcp-db-conn-mariadb + writeConnectionSecretToRef: + name: platform-ref-gcp-ghost-conn diff --git a/examples/cluster-claim.yaml b/examples/cluster-claim.yaml index 1f6ac13..12a37a0 100644 --- a/examples/cluster-claim.yaml +++ b/examples/cluster-claim.yaml @@ -1,22 +1,25 @@ apiVersion: gcp.platformref.upbound.io/v1alpha1 kind: Cluster metadata: - name: platform-ref-gcp-cluster + name: platform-ref-gcp namespace: default - annotations: - uptest.upbound.io/pre-delete-hook: testhooks/delete-release.sh spec: - compositionSelector: - matchLabels: - provider: GCP - id: platform-ref-gcp-cluster + compositeDeletePolicy: Foreground parameters: + id: platform-ref-gcp + region: us-west2 + version: latest nodes: - count: 1 - size: small - services: - operators: - prometheus: - version: "34.5.1" + count: 3 + instanceType: n1-standard-4 + gitops: + git: + url: https://github.com/upbound/platform-ref-gcp/ + ref: + # refs/heads/main + # refs/tags/v0.1.0 + # refs/pull/420/head + # refs/merge-requests/1/head + name: refs/heads/main writeConnectionSecretToRef: - name: cluster-conn + name: platform-ref-gcp-kubeconfig diff --git a/examples/configuration.yaml b/examples/configuration.yaml index 2d40805..8b02a53 100644 --- a/examples/configuration.yaml +++ b/examples/configuration.yaml @@ -1,8 +1,6 @@ apiVersion: pkg.crossplane.io/v1 kind: Configuration metadata: - name: upbound-platform-ref-gcp + name: platform-ref-gcp spec: - package: xpkg.upbound.io/upbound/platform-ref-gcp:v0.3.0 - packagePullSecrets: - - name: package-pull-secret + package: xpkg.upbound.io/upbound/platform-ref-gcp:v0.5.0 diff --git a/examples/functions.yaml b/examples/functions.yaml new file mode 100644 index 0000000..98c28bd --- /dev/null +++ b/examples/functions.yaml @@ -0,0 +1,6 @@ +apiVersion: pkg.crossplane.io/v1beta1 +kind: Function +metadata: + name: upbound-function-patch-and-transform +spec: + package: xpkg.upbound.io/upbound/function-patch-and-transform:v0.2.1 diff --git a/examples/network-xr.yaml b/examples/network-xr.yaml deleted file mode 100644 index f0e7c7a..0000000 --- a/examples/network-xr.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: gcp.platformref.upbound.io/v1alpha1 -kind: XNetwork -metadata: - name: platform-ref-gcp-cluster -spec: - id: platform-ref-gcp-cluster diff --git a/examples/postgres-claim.yaml b/examples/postgres-claim.yaml index 2a8902e..d4ff4ca 100644 --- a/examples/postgres-claim.yaml +++ b/examples/postgres-claim.yaml @@ -1,10 +1,8 @@ -apiVersion: gcp.platformref.upbound.io/v1alpha1 +apiVersion: gcp.platform.upbound.io/v1alpha1 kind: PostgreSQLInstance metadata: - name: platform-ref-gcp-db + name: platform-ref-gcp-db-postgres namespace: default - annotations: - uptest.upbound.io/pre-delete-hook: testhooks/delete-sql-user.sh spec: parameters: storageGB: 10 @@ -12,10 +10,10 @@ spec: namespace: default name: psqlsecret key: password - clusterRef: - id: platform-ref-gcp-cluster + networkRef: + id: platform-ref-gcp writeConnectionSecretToRef: - name: platform-ref-gcp-db-conn + name: platform-ref-gcp-db-conn-postgres --- apiVersion: v1 data: diff --git a/examples/testhooks/delete-release.sh b/examples/testhooks/delete-release.sh deleted file mode 100755 index 5cd2e8c..0000000 --- a/examples/testhooks/delete-release.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -set -aeuo pipefail - -# Delete the release before deleting the cluster not to orphan the release object -# Use explicit ordering of the sql resources to avoid database stuck -# 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 xservices.gcp.platformref.upbound.io --all crossplane.io/paused="true" -${KUBECTL} delete release.helm.crossplane.io --all diff --git a/examples/testhooks/delete-sql-user.sh b/examples/testhooks/delete-sql-user.sh deleted file mode 100755 index ef07234..0000000 --- a/examples/testhooks/delete-sql-user.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -aeuo pipefail - -# Delete the sql user before deleting the database not to orphan the user object -# Use explicit ordering of the sql resources to avoid database stuck -# Note(turkenh): This is a workaround for the infamous dependency problem during deletion. -${KUBECTL} delete user.sql.gcp.upbound.io --all diff --git a/hack/crossplane-cluster-admin-rolebinding.yaml b/hack/crossplane-cluster-admin-rolebinding.yaml deleted file mode 100644 index 50dbdbb..0000000 --- a/hack/crossplane-cluster-admin-rolebinding.yaml +++ /dev/null @@ -1,12 +0,0 @@ -kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1beta1 -metadata: - name: crossplane-clusterrolebinding -subjects: -- kind: ServiceAccount - name: crossplane - namespace: upbound-system -roleRef: - kind: ClusterRole - name: cluster-admin - apiGroup: "" diff --git a/package/cluster/composition.yaml b/package/cluster/composition.yaml deleted file mode 100644 index 2d8119c..0000000 --- a/package/cluster/composition.yaml +++ /dev/null @@ -1,48 +0,0 @@ -apiVersion: apiextensions.crossplane.io/v1 -kind: Composition -metadata: - name: xclusters.gcp.platformref.upbound.io - labels: - provider: GCP -spec: - writeConnectionSecretsToNamespace: upbound-system - compositeTypeRef: - apiVersion: gcp.platformref.upbound.io/v1alpha1 - kind: XCluster - resources: - - base: - apiVersion: gcp.platformref.upbound.io/v1alpha1 - kind: XNetwork - patches: - - fromFieldPath: spec.id - toFieldPath: spec.id - - base: - apiVersion: gcp.platformref.upbound.io/v1alpha1 - kind: XGKE - connectionDetails: - - fromConnectionSecretKey: kubeconfig - patches: - - fromFieldPath: spec.id - toFieldPath: spec.id - - fromFieldPath: metadata.uid - toFieldPath: spec.writeConnectionSecretToRef.name - transforms: - - type: string - string: - fmt: "%s-gke" - - fromFieldPath: spec.writeConnectionSecretToRef.namespace - 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: spec.id - toFieldPath: spec.parameters.XNetworkSelector.matchLabels[networks.gcp.platformref.upbound.io/network-id] - - base: - apiVersion: gcp.platformref.upbound.io/v1alpha1 - kind: XServices - patches: - - fromFieldPath: spec.id - toFieldPath: spec.providerConfigRef.name - - fromFieldPath: spec.parameters.services.operators.prometheus.version - toFieldPath: spec.operators.prometheus.version diff --git a/package/cluster/definition.yaml b/package/cluster/definition.yaml deleted file mode 100644 index ee22e8c..0000000 --- a/package/cluster/definition.yaml +++ /dev/null @@ -1,73 +0,0 @@ -apiVersion: apiextensions.crossplane.io/v1 -kind: CompositeResourceDefinition -metadata: - name: xclusters.gcp.platformref.upbound.io -spec: - claimNames: - kind: Cluster - plural: clusters - connectionSecretKeys: - - kubeconfig - group: gcp.platformref.upbound.io - names: - kind: XCluster - plural: xclusters - versions: - - name: v1alpha1 - served: true - referenceable: true - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - id: - type: string - description: ID of this Cluster that other objects will use to refer to it. - minLength: 1 - # Maximum key length in GCP is 40 characters. We are setting a 34 character - # limit to accomodate the generated hash suffix ('-' + 5 chars). - maxLength: 34 - parameters: - type: object - description: Cluster configuration parameters. - properties: - nodes: - type: object - description: Cluster node configuration parameters. - properties: - count: - type: integer - description: Desired node count, from 1 to 100. - size: - type: string - description: Size of node. - enum: - - small - - medium - - large - required: - - count - - size - services: - type: object - description: Services configuration parameters. - properties: - operators: - type: object - description: Configuration for operators. - properties: - prometheus: - type: object - description: Configuration for the Prometheus operator. - properties: - version: - type: string - description: Prometheus operator version to run. - required: - - nodes - required: - - id - - parameters diff --git a/package/cluster/gke/composition.yaml b/package/cluster/gke/composition.yaml deleted file mode 100644 index 7dfc96b..0000000 --- a/package/cluster/gke/composition.yaml +++ /dev/null @@ -1,205 +0,0 @@ -apiVersion: apiextensions.crossplane.io/v1 -kind: Composition -metadata: - name: xgke.gcp.platformref.upbound.io - labels: - provider: GCP -spec: - writeConnectionSecretsToNamespace: upbound-system - compositeTypeRef: - apiVersion: gcp.platformref.upbound.io/v1alpha1 - kind: XGKE - resources: - - name: service-account - base: - apiVersion: cloudplatform.gcp.upbound.io/v1beta1 - kind: ServiceAccount - patches: - - fromFieldPath: spec.id - toFieldPath: metadata.annotations[crossplane.io/external-name] - - fromFieldPath: spec.id - toFieldPath: spec.forProvider.displayName - - type: ToCompositeFieldPath - fromFieldPath: status.atProvider.email - toFieldPath: status.gke.serviceAccount - policy: - fromFieldPath: Required - - type: ToCompositeFieldPath - fromFieldPath: status.atProvider.id - toFieldPath: status.gke.project - transforms: - - type: string - string: - type: Regexp - regexp: - match: projects\/(.+)\/serviceAccounts\/.* - group: 1 - policy: - fromFieldPath: Required - - name: service-account-key - base: - apiVersion: cloudplatform.gcp.upbound.io/v1beta1 - kind: ServiceAccountKey - spec: - forProvider: - serviceAccountIdSelector: - matchControllerRef: true - patches: - - fromFieldPath: metadata.uid - toFieldPath: spec.writeConnectionSecretToRef.name - transforms: - - type: string - string: - fmt: "%s-sakey" - - fromFieldPath: spec.writeConnectionSecretToRef.namespace - toFieldPath: spec.writeConnectionSecretToRef.namespace - - name: project-iam-member - base: - apiVersion: cloudplatform.gcp.upbound.io/v1beta1 - kind: ProjectIAMMember - spec: - forProvider: - role: roles/container.admin - patches: - - fromFieldPath: spec.id - toFieldPath: metadata.annotations[crossplane.io/external-name] - - fromFieldPath: status.gke.serviceAccount - toFieldPath: spec.forProvider.member - transforms: - - type: string - string: - fmt: "serviceAccount:%s" - policy: - fromFieldPath: Required - - fromFieldPath: status.gke.project - toFieldPath: spec.forProvider.project - policy: - fromFieldPath: Required - - name: gke-cluster - base: - apiVersion: container.gcp.upbound.io/v1beta1 - kind: Cluster - spec: - forProvider: - location: us-west2 - ipAllocationPolicy: - - clusterSecondaryRangeName: pods - servicesSecondaryRangeName: services - enableIntranodeVisibility: true - loggingService: logging.googleapis.com/kubernetes - monitoringService: monitoring.googleapis.com/kubernetes - initialNodeCount: 1 - patches: - - fromFieldPath: metadata.uid - toFieldPath: spec.writeConnectionSecretToRef.name - transforms: - - type: string - string: - fmt: "%s-gkecluster" - - fromFieldPath: spec.writeConnectionSecretToRef.namespace - toFieldPath: spec.writeConnectionSecretToRef.namespace - # Create this cluster in the Network and Subnetwork referenced by network ID - - fromFieldPath: spec.parameters.XNetworkSelector.matchLabels - toFieldPath: spec.forProvider.networkSelector.matchLabels - - fromFieldPath: spec.parameters.XNetworkSelector.matchLabels - toFieldPath: spec.forProvider.subnetworkSelector.matchLabels - - fromFieldPath: status.gke.serviceAccount - toFieldPath: spec.forProvider.nodeConfig[0].serviceAccount - policy: - fromFieldPath: Required - # The control plane supplies the 'kubeconfig' connection secret key, which - # is required by the XR. - connectionDetails: - - fromConnectionSecretKey: kubeconfig - # Each cluster has one node pool. Its nodes are spread evenly across the zones - # in which the cluster exists. - - name: node-pool - base: - apiVersion: container.gcp.upbound.io/v1beta1 - kind: NodePool - spec: - forProvider: - location: us-west2 - initialNodeCount: 1 - clusterSelector: - # Attach this node pool to the GKECluster created above. - matchControllerRef: true - autoscaling: - - minNodeCount: 1 - maxNodeCount: 3 - nodeConfig: - - diskSizeGb: 10 - imageType: COS_CONTAINERD - machineType: e2-medium - preemptible: true - shieldedInstanceConfig: - - enableIntegrityMonitoring: true - enableSecureBoot: true - metadata: - disable-legacy-endpoints: "true" - oauthScopes: - - https://www.googleapis.com/auth/cloud-platform - management: - - autoRepair: true - autoUpgrade: true - maxPodsPerNode: 55 - patches: - # Derive the node count and type of this node pool from the XR. Note that - # the XR's node count is set to initial, min, and max. - - fromFieldPath: spec.parameters.nodes.size - toFieldPath: spec.forProvider.nodeConfig[0].machineType - transforms: - - type: map - map: - small: n1-standard-4 - medium: n1-standard-16 - large: n1-standard-32 - - fromFieldPath: spec.parameters.nodes.count - toFieldPath: spec.forProvider.initialNodeCount - - fromFieldPath: spec.parameters.nodes.count - toFieldPath: spec.forProvider.autoscaling[0].minNodeCount - - fromFieldPath: spec.parameters.nodes.count - toFieldPath: spec.forProvider.autoscaling[0].maxNodeCount - - fromFieldPath: status.gke.serviceAccount - toFieldPath: spec.forProvider.nodeConfig[0].serviceAccount - policy: - fromFieldPath: Required - - name: helm-provider-config - base: - apiVersion: helm.crossplane.io/v1beta1 - kind: ProviderConfig - spec: - credentials: - source: Secret - secretRef: - key: kubeconfig - identity: - type: GoogleApplicationCredentials - source: Secret - secretRef: - key: private_key - patches: - - fromFieldPath: spec.id - toFieldPath: metadata.name - - fromFieldPath: spec.writeConnectionSecretToRef.namespace - toFieldPath: spec.credentials.secretRef.namespace - # This ProviderConfig uses the above GKE Cluster kubeconfig as - # its credentials secret. - - fromFieldPath: metadata.uid - toFieldPath: spec.credentials.secretRef.name - transforms: - - type: string - string: - fmt: "%s-gkecluster" - - fromFieldPath: spec.writeConnectionSecretToRef.namespace - toFieldPath: spec.identity.secretRef.namespace - # This ProviderConfig uses the above ServiceAccount secret as - # its credentials secret. - - fromFieldPath: metadata.uid - toFieldPath: spec.identity.secretRef.name - transforms: - - type: string - string: - fmt: "%s-sakey" - readinessChecks: - - type: None diff --git a/package/cluster/gke/definition.yaml b/package/cluster/gke/definition.yaml deleted file mode 100644 index 322ea81..0000000 --- a/package/cluster/gke/definition.yaml +++ /dev/null @@ -1,74 +0,0 @@ -apiVersion: apiextensions.crossplane.io/v1 -kind: CompositeResourceDefinition -metadata: - name: xgke.gcp.platformref.upbound.io -spec: - connectionSecretKeys: - - kubeconfig - group: gcp.platformref.upbound.io - names: - kind: XGKE - plural: xgke - versions: - - name: v1alpha1 - served: true - referenceable: true - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - id: - type: string - description: ID of this Cluster that other objects will use to refer to it. - minLength: 1 - # Maximum key length in GCP is 40 characters. We are setting a 34 character - # limit to accomodate the generated hash suffix ('-' + 5 chars). - maxLength: 34 - parameters: - type: object - description: GKE configuration parameters. - properties: - nodes: - type: object - description: GKE node configuration parameters. - properties: - count: - type: integer - description: Desired node count, from 1 to 100. - size: - type: string - description: Size of node. - enum: - - small - - medium - - large - required: - - count - - size - XNetworkSelector: - type: object - properties: - matchLabels: - additionalProperties: - type: string - description: MatchLabels ensures a XNetwork with matching labels - is selected. - type: object - required: - - matchLabels - required: - - nodes - required: - - id - - parameters - status: - description: A Status represents the observed state - properties: - gke: - description: Freeform field containing status information for eks - type: object - x-kubernetes-preserve-unknown-fields: true - type: object diff --git a/package/cluster/network/composition.yaml b/package/cluster/network/composition.yaml deleted file mode 100644 index 5facb42..0000000 --- a/package/cluster/network/composition.yaml +++ /dev/null @@ -1,45 +0,0 @@ -apiVersion: apiextensions.crossplane.io/v1 -kind: Composition -metadata: - name: xnetworks.gcp.platformref.upbound.io - labels: - provider: GCP -spec: - writeConnectionSecretsToNamespace: upbound-system - compositeTypeRef: - apiVersion: gcp.platformref.upbound.io/v1alpha1 - kind: XNetwork - resources: - - base: - apiVersion: compute.gcp.upbound.io/v1beta1 - kind: Network - spec: - forProvider: - autoCreateSubnetworks: false - routingMode: REGIONAL - patches: - - fromFieldPath: spec.id - toFieldPath: metadata.name - - fromFieldPath: spec.id - toFieldPath: metadata.labels[networks.gcp.platformref.upbound.io/network-id] - - base: - apiVersion: compute.gcp.upbound.io/v1beta1 - kind: Subnetwork - spec: - forProvider: - region: us-west2 - networkSelector: - # This selector ensures this Subnetwork will select and use the - # above Network. They will both be part of the XR, and thus their - # controller references will match. - matchControllerRef: true - privateIpGoogleAccess: true - ipCidrRange: 172.16.0.0/16 - secondaryIpRange: - - rangeName: pods - ipCidrRange: 10.200.0.0/14 - - rangeName: services - ipCidrRange: 10.204.0.0/16 - patches: - - fromFieldPath: spec.id - toFieldPath: metadata.labels[networks.gcp.platformref.upbound.io/network-id] diff --git a/package/cluster/network/definition.yaml b/package/cluster/network/definition.yaml deleted file mode 100644 index aa4dc88..0000000 --- a/package/cluster/network/definition.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: apiextensions.crossplane.io/v1 -kind: CompositeResourceDefinition -metadata: - name: xnetworks.gcp.platformref.upbound.io -spec: - group: gcp.platformref.upbound.io - names: - kind: XNetwork - plural: xnetworks - versions: - - name: v1alpha1 - served: true - referenceable: true - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - id: - type: string - description: ID of this Network that other objects will use to refer to it. - required: - - id diff --git a/package/cluster/services/composition.yaml b/package/cluster/services/composition.yaml deleted file mode 100644 index 178cbfb..0000000 --- a/package/cluster/services/composition.yaml +++ /dev/null @@ -1,38 +0,0 @@ -apiVersion: apiextensions.crossplane.io/v1 -kind: Composition -metadata: - name: xservices.gcp.platformref.upbound.io - labels: - provider: helm -spec: - writeConnectionSecretsToNamespace: upbound-system - compositeTypeRef: - apiVersion: gcp.platformref.upbound.io/v1alpha1 - kind: XServices - resources: - - base: - apiVersion: helm.crossplane.io/v1beta1 - kind: Release - spec: - rollbackLimit: 3 - forProvider: - namespace: operators - chart: - # from https://github.com/prometheus-community/helm-charts - # Note that default values are overridden by the patches below. - name: kube-prometheus-stack - repository: https://prometheus-community.github.io/helm-charts - version: "41.4.1" - values: {} - 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.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 diff --git a/package/cluster/services/definition.yaml b/package/cluster/services/definition.yaml deleted file mode 100644 index 91e5e9c..0000000 --- a/package/cluster/services/definition.yaml +++ /dev/null @@ -1,45 +0,0 @@ -apiVersion: apiextensions.crossplane.io/v1 -kind: CompositeResourceDefinition -metadata: - name: xservices.gcp.platformref.upbound.io -spec: - group: gcp.platformref.upbound.io - names: - kind: XServices - plural: xservices - versions: - - name: v1alpha1 - served: true - referenceable: true - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - operators: - type: object - description: Configuration for operators. - properties: - prometheus: - type: object - description: Configuration for the Prometheus operator. - properties: - version: - type: string - description: Prometheus operator version to run. - 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." - required: - - name - required: - - providerConfigRef diff --git a/package/database/postgres/composition.yaml b/package/database/postgres/composition.yaml deleted file mode 100644 index eab7f47..0000000 --- a/package/database/postgres/composition.yaml +++ /dev/null @@ -1,79 +0,0 @@ -apiVersion: apiextensions.crossplane.io/v1 -kind: Composition -metadata: - name: xpostgresqlinstances.gcp.platformref.upbound.io - labels: - provider: gcp -spec: - writeConnectionSecretsToNamespace: upbound-system - compositeTypeRef: - apiVersion: gcp.platformref.upbound.io/v1alpha1 - kind: XPostgreSQLInstance - resources: - - name: PrivateIPAddress - base: - apiVersion: compute.gcp.upbound.io/v1beta1 - kind: GlobalAddress - spec: - forProvider: - addressType: INTERNAL - prefixLength: 16 - purpose: VPC_PEERING - patches: - - fromFieldPath: spec.parameters.clusterRef.id - toFieldPath: spec.forProvider.networkSelector.matchLabels[networks.gcp.platformref.upbound.io/network-id] - - name: PrivateConnection - base: - apiVersion: servicenetworking.gcp.upbound.io/v1beta1 - kind: Connection - spec: - forProvider: - reservedPeeringRangesSelector: - matchControllerRef: true - service: servicenetworking.googleapis.com - patches: - - fromFieldPath: spec.parameters.clusterRef.id - toFieldPath: spec.forProvider.networkSelector.matchLabels[networks.gcp.platformref.upbound.io/network-id] - - name: DatabaseUser - base: - apiVersion: sql.gcp.upbound.io/v1beta1 - kind: User - spec: - forProvider: - instanceSelector: - matchControllerRef: true - patches: - - fromFieldPath: spec.parameters.passwordSecretRef.namespace - toFieldPath: spec.forProvider.passwordSecretRef.namespace - - fromFieldPath: spec.parameters.passwordSecretRef.name - toFieldPath: spec.forProvider.passwordSecretRef.name - - fromFieldPath: spec.parameters.passwordSecretRef.key - toFieldPath: spec.forProvider.passwordSecretRef.key - - name: DBInstance - base: - apiVersion: sql.gcp.upbound.io/v1beta1 - kind: DatabaseInstance - spec: - forProvider: - databaseVersion: POSTGRES_13 - deletionProtection: false - region: us-west2 - settings: - - diskSize: 20 - tier: db-f1-micro - patches: - - fromFieldPath: metadata.uid - toFieldPath: spec.writeConnectionSecretToRef.name - transforms: - - type: string - string: - fmt: "%s-gcp-postgresql" - - fromFieldPath: spec.writeConnectionSecretToRef.namespace - toFieldPath: spec.writeConnectionSecretToRef.namespace - - fromFieldPath: spec.parameters.storageGB - toFieldPath: spec.forProvider.settings[0].diskSize - - fromFieldPath: spec.parameters.clusterRef.id - toFieldPath: spec.forProvider.settings[0].ipConfiguration[0].privateNetworkRef.name - connectionDetails: - - fromConnectionSecretKey: privateIP - - fromConnectionSecretKey: serverCACertificateCert diff --git a/package/database/postgres/definition.yaml b/package/database/postgres/definition.yaml deleted file mode 100644 index 7c51ec3..0000000 --- a/package/database/postgres/definition.yaml +++ /dev/null @@ -1,61 +0,0 @@ -apiVersion: apiextensions.crossplane.io/v1 -kind: CompositeResourceDefinition -metadata: - name: xpostgresqlinstances.gcp.platformref.upbound.io -spec: - group: gcp.platformref.upbound.io - names: - kind: XPostgreSQLInstance - plural: xpostgresqlinstances - claimNames: - kind: PostgreSQLInstance - plural: postgresqlinstances - connectionSecretKeys: - - privateIP - - serverCACertificateCert - versions: - - name: v1alpha1 - served: true - referenceable: true - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - parameters: - type: object - properties: - storageGB: - type: integer - passwordSecretRef: - type: object - description: "A reference to the Secret object containing database password" - properties: - namespace: - type: string - name: - type: string - key: - type: string - required: - - namespace - - name - - key - clusterRef: - type: object - description: "A reference to the Network object that this postgres should be - connected to." - properties: - id: - type: string - description: ID of the Network object this ref points to. - required: - - id - required: - - storageGB - - clusterRef - - passwordSecretRef - required: - - parameters diff --git a/test/setup.sh b/test/setup.sh index 52bf9fa..0237919 100755 --- a/test/setup.sh +++ b/test/setup.sh @@ -5,24 +5,25 @@ UPTEST_GCP_PROJECT=${UPTEST_GCP_PROJECT:-official-provider-testing} echo "Running setup.sh" echo "Waiting until configuration package is healthy/installed..." -${KUBECTL} wait configuration.pkg platform-ref-gcp --for=condition=Healthy --timeout 5m -${KUBECTL} wait configuration.pkg platform-ref-gcp --for=condition=Installed --timeout 5m +"${KUBECTL}" wait configuration.pkg platform-ref-gcp --for=condition=Healthy --timeout 5m +"${KUBECTL}" wait configuration.pkg platform-ref-gcp --for=condition=Installed --timeout 5m +"${KUBECTL}" wait configurationrevisions.pkg --all --for=condition=Healthy --timeout 5m echo "Creating cloud credential secret..." -${KUBECTL} -n upbound-system create secret generic gcp-creds --from-literal=credentials="${UPTEST_CLOUD_CREDENTIALS}" \ - --dry-run=client -o yaml | ${KUBECTL} apply -f - +"${KUBECTL}" -n upbound-system create secret generic gcp-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 <