diff --git a/Makefile b/Makefile index bdbe85e..9c1a7e3 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,8 @@ XPKG_REG_ORGS_NO_PROMOTE ?= xpkg.upbound.io/upbound XPKGS = $(PROJECT_NAME) -include build/makelib/xpkg.mk -CROSSPLANE_NAMESPACE = upbound-system -CROSSPLANE_ARGS = "--enable-usages" +CROSSPLANE_NAMESPACE = crossplane-system +CROSSPLANE_ARGS = "" -include build/makelib/local.xpkg.mk -include build/makelib/controlplane.mk @@ -65,7 +65,7 @@ build.init: $(UP) # - 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) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) $(UPTEST) e2e examples/XAccountScaffold/xr.yaml,examples/XCluster/xr.yaml,examples/XCompositeCluster/xr.yaml,examples/XDatabase/xr.yaml,examples/XNetwork/xr.yaml,examples/XNodePool/xr.yaml,examples/XServiceAccount/xr.yaml,examples/XSubnetwork/xr.yaml --data-source="${UPTEST_DATASOURCE_PATH}" --setup-script=test/setup.sh --default-timeout=2400 || $(FAIL) + @KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) $(UPTEST) e2e examples/accountscaffold/xr.yaml,examples/cluster/xr.yaml,examples/compositecluster/xr.yaml,examples/database/xr.yaml,examples/network/xr.yaml,examples/nodepool/xr.yaml,examples/serviceaccount/xr.yaml,examples/subnetwork/xr.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: @@ -84,7 +84,7 @@ render: if [[ "$$COMPOSITION" == "null" || "$$FUNCTION" == "null" ]]; then \ continue; \ fi; \ - crossplane beta render $$file $$COMPOSITION $$FUNCTION -x -r; \ + crossplane render $$file $$COMPOSITION $$FUNCTION -x -r; \ done yamllint: diff --git a/README.md b/README.md index 47f5f30..3a242d7 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,24 @@ # configuration-getting-started -An introductory example to Crossplane and Compositions using provider-nop. This will enable provisioning of several different fake resource types. -This repository contains a reference configuration for [Crossplane](https://crossplane.io). This configuration is built with [provider-nop](https://marketplace.upbound.io/providers/crossplane-contrib/provider-nop), a Crossplane provider that simulates the creation of external resources. +An introductory example to Crossplane and Compositions using provider-nop. This will enable provisioning of several different fake resource types. +This repository contains a reference configuration for [Crossplane](https://crossplane.io) **v2**. This configuration is built with [provider-nop](https://marketplace.upbound.io/providers/crossplane-contrib/provider-nop), a Crossplane provider that simulates the creation of external resources. All composite resources are **namespaced** — claims are not used (they don't exist in Crossplane v2). ## Overview This platform offers APIs for setting up a variety of basic resources that mirror what you'd find in a Cloud Service Provider such as AWS, Azure, or GCP. The resource types include: -* [Cluster](apis/primitives/XCluster/), a resource that loosely represents a Kubernetes cluster. -* [NodePool](apis/primitives/XNodePool/), a resource that loosely represents a Nodepool in a Kubernetes cluster. -* [Database](apis/primitives/XDatabase/), a resource that loosely represents a cloud database. -* [Network](apis/primitives/XNetwork/), a resource that loosely represents a cloud network resource. -* [Subnetwork](apis/primitives/XSubnetwork/), a resource that loosely represents a subnetwork resource within a cloud network. -* [Service Account](apis/primitives/XServiceAccount/), a resource that loosely represents a service account in the cloud. +* [Cluster](apis/primitives/cluster/), a resource that loosely represents a Kubernetes cluster. +* [NodePool](apis/primitives/nodepool/), a resource that loosely represents a Nodepool in a Kubernetes cluster. +* [Database](apis/primitives/database/), a resource that loosely represents a cloud database. +* [Network](apis/primitives/network/), a resource that loosely represents a cloud network resource. +* [Subnetwork](apis/primitives/subnetwork/), a resource that loosely represents a subnetwork resource within a cloud network. +* [ServiceAccount](apis/primitives/serviceaccount/), a resource that loosely represents a service account in the cloud. This configuration also demonstrates the power of Crossplane to build abstractions called "compositions", which assemble multiple basic resources into a more complex resource. These are demonstrated with: -* [CompositeCluster](apis/composition-basics/XCompositeCluster/), a resource abstraction that composes a cluster, nodepool, network, subnetwork, and service account. -* [AccountScaffold](apis/composition-basics/XAccountScaffold/), a resource abstraction that composes a service account, network, and subnetwork. +* [CompositeCluster](apis/composition-basics/compositecluster/), a resource abstraction that composes a cluster, nodepool, network, subnetwork, and service account. +* [AccountScaffold](apis/composition-basics/accountscaffold/), a resource abstraction that composes a service account, network, and subnetwork. Learn more about Composite Resources in the [Crossplane Docs](https://docs.crossplane.io/latest/concepts/compositions/). @@ -27,79 +27,101 @@ Docs](https://docs.crossplane.io/latest/concepts/compositions/). ### Prerequisites -Before we can install the reference platform we should install the `up` CLI. -This is a utility that makes following this quickstart guide easier. Everything -described here can also be done in a declarative approach - which we highly -recommend for any production type use-case. - +You need a running Crossplane v2 control plane. You can create a managed control plane on [Upbound](https://console.upbound.io), or run upstream Crossplane locally with [kind](https://kind.sigs.k8s.io/). -To install `up` run this install script: +Install the `up` CLI: ```console curl -sL https://cli.upbound.io | sh ``` See [up docs](https://docs.upbound.io/cli/) for more install options. -We need a running Crossplane control plane to install our instance. Use [Upbound](https://console.upbound.io) to create a managed control plane. You can [create an account](https://accounts.upbound.io/register) and start a free 30 day trial if you haven't signed up for Upbound before. +Alternatively, install the Crossplane CLI: +```console +curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh +``` ### Install the Getting Started configuration -Now you can install this reference platform. It's packaged as a [Crossplane -configuration package](https://docs.crossplane.io/latest/concepts/packages/) -so there is a single command to install it: +Install the configuration package: ```console -up ctp configuration install xpkg.upbound.io/upbound/configuration-getting-started:v0.1.0 +kubectl apply -f - < **Note**: The `render` target uses the `crossplane` CLI under the hood (`crossplane render`), which has no `up` equivalent for classic configuration packages. + ## Next Steps -We recommend you check out of one of Upbound's platform reference architectures to learn how to use Crossplane to provision real external resources, such as in a Cloud Serice Provider's environment. Have a look: +We recommend you check out one of Upbound's platform reference architectures to learn how to use Crossplane to provision real external resources: * [AWS reference platform](https://github.com/upbound/platform-ref-aws/) * [Azure reference platform](https://github.com/upbound/platform-ref-azure/) @@ -109,4 +131,4 @@ We recommend you check out of one of Upbound's platform reference architectures For any questions, thoughts and comments don't hesitate to [reach out](https://www.upbound.io/contact) or drop by -[slack.crossplane.io](https://slack.crossplane.io), and say hi! \ No newline at end of file +[slack.crossplane.io](https://slack.crossplane.io), and say hi! diff --git a/apis/composition-basics/XAccountScaffold/composition.yaml b/apis/composition-basics/accountscaffold/composition.yaml similarity index 83% rename from apis/composition-basics/XAccountScaffold/composition.yaml rename to apis/composition-basics/accountscaffold/composition.yaml index 4d665f4..5c2cebe 100644 --- a/apis/composition-basics/XAccountScaffold/composition.yaml +++ b/apis/composition-basics/accountscaffold/composition.yaml @@ -1,11 +1,11 @@ apiVersion: apiextensions.crossplane.io/v1 kind: Composition metadata: - name: xaccountscaffolds.platform.acme.co + name: accountscaffolds.platform.acme.co spec: compositeTypeRef: apiVersion: platform.acme.co/v1alpha1 - kind: XAccountScaffold + kind: AccountScaffold mode: Pipeline pipeline: - step: compose @@ -24,23 +24,26 @@ spec: oxr = option("params").oxr items = [{ apiVersion: "platform.acme.co/v1alpha1" - kind: "XServiceAccount" + kind: "ServiceAccount" metadata.name = "{}-sa".format(oxr.metadata.name) + metadata.namespace = oxr.metadata.namespace spec.parameters = { displayName: oxr.spec.parameters.name } }, { apiVersion: "platform.acme.co/v1alpha1" - kind: "XNetwork" + kind: "Network" metadata.name = "{}-net".format(oxr.metadata.name) + metadata.namespace = oxr.metadata.namespace spec.parameters = { autoCreateSubnetworks: True routingMode: "GLOBAL" } }, { apiVersion: "platform.acme.co/v1alpha1" - kind: "XSubnetwork" + kind: "Subnetwork" metadata.name = "{}-subnet".format(oxr.metadata.name) + metadata.namespace = oxr.metadata.namespace spec.parameters = { ipCidrRange: "10.2.0.0/16" networkRef.name: "{}-net".format(oxr.metadata.name) diff --git a/apis/composition-basics/XAccountScaffold/definition.yaml b/apis/composition-basics/accountscaffold/definition.yaml similarity index 86% rename from apis/composition-basics/XAccountScaffold/definition.yaml rename to apis/composition-basics/accountscaffold/definition.yaml index 7c796e9..7a2f520 100644 --- a/apis/composition-basics/XAccountScaffold/definition.yaml +++ b/apis/composition-basics/accountscaffold/definition.yaml @@ -1,13 +1,11 @@ -apiVersion: apiextensions.crossplane.io/v1 +apiVersion: apiextensions.crossplane.io/v2 kind: CompositeResourceDefinition metadata: - name: xaccountscaffolds.platform.acme.co + name: accountscaffolds.platform.acme.co spec: + scope: Namespaced group: platform.acme.co names: - kind: XAccountScaffold - plural: xaccountscaffolds - claimNames: kind: AccountScaffold plural: accountscaffolds versions: diff --git a/apis/composition-basics/XCompositeCluster/composition.yaml b/apis/composition-basics/compositecluster/composition.yaml similarity index 84% rename from apis/composition-basics/XCompositeCluster/composition.yaml rename to apis/composition-basics/compositecluster/composition.yaml index d69acb6..90252a8 100644 --- a/apis/composition-basics/XCompositeCluster/composition.yaml +++ b/apis/composition-basics/compositecluster/composition.yaml @@ -1,11 +1,11 @@ apiVersion: apiextensions.crossplane.io/v1 kind: Composition metadata: - name: xcompositeclusters.platform.acme.co + name: compositeclusters.platform.acme.co spec: compositeTypeRef: apiVersion: platform.acme.co/v1alpha1 - kind: XCompositeCluster + kind: CompositeCluster mode: Pipeline pipeline: - step: compose @@ -24,8 +24,9 @@ spec: oxr = option("params").oxr items = [{ apiVersion: "platform.acme.co/v1alpha1" - kind: "XCluster" + kind: "Cluster" metadata.name = "{}-cluster".format(oxr.metadata.name) + metadata.namespace = oxr.metadata.namespace spec.parameters = { initialNodeCount: oxr.spec.parameters.nodeCount networkRef.name: "{}-net".format(oxr.metadata.name) @@ -35,15 +36,17 @@ spec: } }, { apiVersion: "platform.acme.co/v1alpha1" - kind: "XServiceAccount" + kind: "ServiceAccount" metadata.name = "{}-sa".format(oxr.metadata.name) + metadata.namespace = oxr.metadata.namespace spec.parameters = { displayName: "{} service account".format(oxr.metadata.name) } }, { apiVersion: "platform.acme.co/v1alpha1" - kind: "XNodePool" + kind: "NodePool" metadata.name = "{}-nodepool".format(oxr.metadata.name) + metadata.namespace = oxr.metadata.namespace spec.parameters = { nodeConfig = [{ machineType: oxr.spec.parameters.size @@ -55,16 +58,18 @@ spec: } }, { apiVersion: "platform.acme.co/v1alpha1" - kind: "XNetwork" + kind: "Network" metadata.name = "{}-net".format(oxr.metadata.name) + metadata.namespace = oxr.metadata.namespace spec.parameters = { autoCreateSubnetworks: True routingMode: "GLOBAL" } }, { apiVersion: "platform.acme.co/v1alpha1" - kind: "XSubnetwork" + kind: "Subnetwork" metadata.name = "{}-subnet".format(oxr.metadata.name) + metadata.namespace = oxr.metadata.namespace spec.parameters = { ipCidrRange: "10.2.0.0/16" networkRef.name: "{}-net".format(oxr.metadata.name) diff --git a/apis/composition-basics/XCompositeCluster/definition.yaml b/apis/composition-basics/compositecluster/definition.yaml similarity index 90% rename from apis/composition-basics/XCompositeCluster/definition.yaml rename to apis/composition-basics/compositecluster/definition.yaml index 848262a..cb505b9 100644 --- a/apis/composition-basics/XCompositeCluster/definition.yaml +++ b/apis/composition-basics/compositecluster/definition.yaml @@ -1,13 +1,11 @@ -apiVersion: apiextensions.crossplane.io/v1 +apiVersion: apiextensions.crossplane.io/v2 kind: CompositeResourceDefinition metadata: - name: xcompositeclusters.platform.acme.co + name: compositeclusters.platform.acme.co spec: + scope: Namespaced group: platform.acme.co names: - kind: XCompositeCluster - plural: xcompositeclusters - claimNames: kind: CompositeCluster plural: compositeclusters versions: diff --git a/apis/primitives/XCluster/composition.yaml b/apis/primitives/cluster/composition.yaml similarity index 94% rename from apis/primitives/XCluster/composition.yaml rename to apis/primitives/cluster/composition.yaml index 1b2323f..2ff4f58 100644 --- a/apis/primitives/XCluster/composition.yaml +++ b/apis/primitives/cluster/composition.yaml @@ -1,11 +1,11 @@ apiVersion: apiextensions.crossplane.io/v1 kind: Composition metadata: - name: xclusters.platform.acme.co + name: clusters.platform.acme.co spec: compositeTypeRef: apiVersion: platform.acme.co/v1alpha1 - kind: XCluster + kind: Cluster mode: Pipeline pipeline: - step: compose @@ -41,6 +41,7 @@ spec: apiVersion: "nop.crossplane.io/v1alpha1" kind: "NopResource" metadata.name = oxr.metadata.name + metadata.namespace = oxr.metadata.namespace spec.forProvider = { conditionAfter = [readyCondition] if readyCondition else [statusCondition] fields = { diff --git a/apis/primitives/XCluster/definition.yaml b/apis/primitives/cluster/definition.yaml similarity index 94% rename from apis/primitives/XCluster/definition.yaml rename to apis/primitives/cluster/definition.yaml index 2dab440..1431f2e 100644 --- a/apis/primitives/XCluster/definition.yaml +++ b/apis/primitives/cluster/definition.yaml @@ -1,13 +1,11 @@ -apiVersion: apiextensions.crossplane.io/v1 +apiVersion: apiextensions.crossplane.io/v2 kind: CompositeResourceDefinition metadata: - name: xclusters.platform.acme.co + name: clusters.platform.acme.co spec: + scope: Namespaced group: platform.acme.co names: - kind: XCluster - plural: xclusters - claimNames: kind: Cluster plural: clusters versions: diff --git a/apis/primitives/XDatabase/composition.yaml b/apis/primitives/database/composition.yaml similarity index 91% rename from apis/primitives/XDatabase/composition.yaml rename to apis/primitives/database/composition.yaml index ed79aac..904133d 100644 --- a/apis/primitives/XDatabase/composition.yaml +++ b/apis/primitives/database/composition.yaml @@ -1,11 +1,11 @@ apiVersion: apiextensions.crossplane.io/v1 kind: Composition metadata: - name: xdatabases.platform.acme.co + name: databases.platform.acme.co spec: compositeTypeRef: apiVersion: platform.acme.co/v1alpha1 - kind: XDatabase + kind: Database mode: Pipeline pipeline: - step: compose @@ -26,6 +26,7 @@ spec: apiVersion: "nop.crossplane.io/v1alpha1" kind: "NopResource" metadata.name = oxr.metadata.name + metadata.namespace = oxr.metadata.namespace spec.forProvider = { conditionAfter = [{ conditionStatus: "True" diff --git a/apis/primitives/XDatabase/definition.yaml b/apis/primitives/database/definition.yaml similarity index 92% rename from apis/primitives/XDatabase/definition.yaml rename to apis/primitives/database/definition.yaml index 1c8fd96..3722d9c 100644 --- a/apis/primitives/XDatabase/definition.yaml +++ b/apis/primitives/database/definition.yaml @@ -1,13 +1,11 @@ -apiVersion: apiextensions.crossplane.io/v1 +apiVersion: apiextensions.crossplane.io/v2 kind: CompositeResourceDefinition metadata: - name: xdatabases.platform.acme.co + name: databases.platform.acme.co spec: + scope: Namespaced group: platform.acme.co names: - kind: XDatabase - plural: xdatabases - claimNames: kind: Database plural: databases versions: diff --git a/apis/primitives/XNetwork/composition.yaml b/apis/primitives/network/composition.yaml similarity index 91% rename from apis/primitives/XNetwork/composition.yaml rename to apis/primitives/network/composition.yaml index 2ed7949..2168c48 100644 --- a/apis/primitives/XNetwork/composition.yaml +++ b/apis/primitives/network/composition.yaml @@ -1,11 +1,11 @@ apiVersion: apiextensions.crossplane.io/v1 kind: Composition metadata: - name: xnetworks.platform.acme.co + name: networks.platform.acme.co spec: compositeTypeRef: apiVersion: platform.acme.co/v1alpha1 - kind: XNetwork + kind: Network mode: Pipeline pipeline: - step: compose @@ -26,6 +26,7 @@ spec: apiVersion: "nop.crossplane.io/v1alpha1" kind: "NopResource" metadata.name = oxr.metadata.name + metadata.namespace = oxr.metadata.namespace spec.forProvider = { conditionAfter = [{ conditionStatus: "True" diff --git a/apis/primitives/XNetwork/definition.yaml b/apis/primitives/network/definition.yaml similarity index 90% rename from apis/primitives/XNetwork/definition.yaml rename to apis/primitives/network/definition.yaml index 1257426..6e10a29 100644 --- a/apis/primitives/XNetwork/definition.yaml +++ b/apis/primitives/network/definition.yaml @@ -1,13 +1,11 @@ -apiVersion: apiextensions.crossplane.io/v1 +apiVersion: apiextensions.crossplane.io/v2 kind: CompositeResourceDefinition metadata: - name: xnetworks.platform.acme.co + name: networks.platform.acme.co spec: + scope: Namespaced group: platform.acme.co names: - kind: XNetwork - plural: xnetworks - claimNames: kind: Network plural: networks versions: diff --git a/apis/primitives/XNodepool/composition.yaml b/apis/primitives/nodepool/composition.yaml similarity index 91% rename from apis/primitives/XNodepool/composition.yaml rename to apis/primitives/nodepool/composition.yaml index 1009ea2..c284fab 100644 --- a/apis/primitives/XNodepool/composition.yaml +++ b/apis/primitives/nodepool/composition.yaml @@ -1,11 +1,11 @@ apiVersion: apiextensions.crossplane.io/v1 kind: Composition metadata: - name: xnodepools.platform.acme.co + name: nodepools.platform.acme.co spec: compositeTypeRef: apiVersion: platform.acme.co/v1alpha1 - kind: XNodePool + kind: NodePool mode: Pipeline pipeline: - step: compose @@ -26,6 +26,7 @@ spec: apiVersion: "nop.crossplane.io/v1alpha1" kind: "NopResource" metadata.name = oxr.metadata.name + metadata.namespace = oxr.metadata.namespace spec.forProvider = { conditionAfter = [{ conditionStatus: "True" diff --git a/apis/primitives/XNodepool/definition.yaml b/apis/primitives/nodepool/definition.yaml similarity index 95% rename from apis/primitives/XNodepool/definition.yaml rename to apis/primitives/nodepool/definition.yaml index 9d6a3b6..1d817b6 100644 --- a/apis/primitives/XNodepool/definition.yaml +++ b/apis/primitives/nodepool/definition.yaml @@ -1,13 +1,11 @@ -apiVersion: apiextensions.crossplane.io/v1 +apiVersion: apiextensions.crossplane.io/v2 kind: CompositeResourceDefinition metadata: - name: xnodepools.platform.acme.co + name: nodepools.platform.acme.co spec: + scope: Namespaced group: platform.acme.co names: - kind: XNodePool - plural: xnodepools - claimNames: kind: NodePool plural: nodepools versions: diff --git a/apis/primitives/XServiceAccount/composition.yaml b/apis/primitives/serviceaccount/composition.yaml similarity index 90% rename from apis/primitives/XServiceAccount/composition.yaml rename to apis/primitives/serviceaccount/composition.yaml index 5c63d42..ef47e96 100644 --- a/apis/primitives/XServiceAccount/composition.yaml +++ b/apis/primitives/serviceaccount/composition.yaml @@ -1,11 +1,11 @@ apiVersion: apiextensions.crossplane.io/v1 kind: Composition metadata: - name: xserviceaccounts.platform.acme.co + name: serviceaccounts.platform.acme.co spec: compositeTypeRef: apiVersion: platform.acme.co/v1alpha1 - kind: XServiceAccount + kind: ServiceAccount mode: Pipeline pipeline: - step: compose @@ -26,6 +26,7 @@ spec: apiVersion: "nop.crossplane.io/v1alpha1" kind: "NopResource" metadata.name = oxr.metadata.name + metadata.namespace = oxr.metadata.namespace spec.forProvider = { conditionAfter = [{ conditionStatus: "True" diff --git a/apis/primitives/XServiceAccount/definition.yaml b/apis/primitives/serviceaccount/definition.yaml similarity index 86% rename from apis/primitives/XServiceAccount/definition.yaml rename to apis/primitives/serviceaccount/definition.yaml index 4be4da6..54bf9be 100644 --- a/apis/primitives/XServiceAccount/definition.yaml +++ b/apis/primitives/serviceaccount/definition.yaml @@ -1,13 +1,11 @@ -apiVersion: apiextensions.crossplane.io/v1 +apiVersion: apiextensions.crossplane.io/v2 kind: CompositeResourceDefinition metadata: - name: xserviceaccounts.platform.acme.co + name: serviceaccounts.platform.acme.co spec: + scope: Namespaced group: platform.acme.co names: - kind: XServiceAccount - plural: xserviceaccounts - claimNames: kind: ServiceAccount plural: serviceaccounts versions: diff --git a/apis/primitives/XSubnetwork/composition.yaml b/apis/primitives/subnetwork/composition.yaml similarity index 92% rename from apis/primitives/XSubnetwork/composition.yaml rename to apis/primitives/subnetwork/composition.yaml index 3d5e68d..817fa14 100644 --- a/apis/primitives/XSubnetwork/composition.yaml +++ b/apis/primitives/subnetwork/composition.yaml @@ -1,11 +1,11 @@ apiVersion: apiextensions.crossplane.io/v1 kind: Composition metadata: - name: xsubnetworks.platform.acme.co + name: subnetworks.platform.acme.co spec: compositeTypeRef: apiVersion: platform.acme.co/v1alpha1 - kind: XSubnetwork + kind: Subnetwork mode: Pipeline pipeline: - step: compose @@ -26,6 +26,7 @@ spec: apiVersion: "nop.crossplane.io/v1alpha1" kind: "NopResource" metadata.name = oxr.metadata.name + metadata.namespace = oxr.metadata.namespace spec.forProvider = { conditionAfter = [{ conditionStatus: "True" diff --git a/apis/primitives/XSubnetwork/definition.yaml b/apis/primitives/subnetwork/definition.yaml similarity index 94% rename from apis/primitives/XSubnetwork/definition.yaml rename to apis/primitives/subnetwork/definition.yaml index 3d32bad..c1e03dd 100644 --- a/apis/primitives/XSubnetwork/definition.yaml +++ b/apis/primitives/subnetwork/definition.yaml @@ -1,13 +1,11 @@ -apiVersion: apiextensions.crossplane.io/v1 +apiVersion: apiextensions.crossplane.io/v2 kind: CompositeResourceDefinition metadata: - name: xsubnetworks.platform.acme.co + name: subnetworks.platform.acme.co spec: + scope: Namespaced group: platform.acme.co names: - kind: XSubnetwork - plural: xsubnetworks - claimNames: kind: Subnetwork plural: subnetworks versions: diff --git a/crossplane.yaml b/crossplane.yaml index 0444a15..1aaac47 100644 --- a/crossplane.yaml +++ b/crossplane.yaml @@ -8,14 +8,14 @@ metadata: meta.crossplane.io/license: Apache-2.0 spec: crossplane: - version: ">=v1.15.2" + version: ">=v2.0.0-0" dependsOn: - provider: xpkg.upbound.io/crossplane-contrib/provider-nop # renovate: datasource=github-releases depName=crossplane-contrib/provider-nop - version: "v0.2.1" + version: "v0.5.0" - function: xpkg.upbound.io/crossplane-contrib/function-kcl # renovate: datasource=github-releases depName=crossplane-contrib/function-kcl - version: "v0.8.0" + version: "v0.12.1" - function: xpkg.upbound.io/crossplane-contrib/function-auto-ready # renovate: datasource=github-releases depName=crossplane-contrib/function-auto-ready - version: "v0.2.1" + version: "v0.6.3" diff --git a/examples/XAccountScaffold/claim.k b/examples/XAccountScaffold/claim.k deleted file mode 100644 index 6d8bf34..0000000 --- a/examples/XAccountScaffold/claim.k +++ /dev/null @@ -1,17 +0,0 @@ -""" -This file was generated by the KCL auto-gen tool. DO NOT EDIT. -Editing this file might prove futile when you re-run the KCL auto-gen generate command. -""" - -{ - apiVersion = "platform.acme.co/v1alpha1" - kind = "AccountScaffold" - metadata = { - name = option("resourcename") - } - spec = { - parameters = { - name = "test account" - } - } -} diff --git a/examples/XAccountScaffold/claim.yaml b/examples/XAccountScaffold/claim.yaml deleted file mode 100644 index 1403b1b..0000000 --- a/examples/XAccountScaffold/claim.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: platform.acme.co/v1alpha1 -kind: AccountScaffold -metadata: - name: custom-account1 -spec: - parameters: - name: "test account" diff --git a/examples/XCluster/claim.k b/examples/XCluster/claim.k deleted file mode 100644 index 2aa5a5e..0000000 --- a/examples/XCluster/claim.k +++ /dev/null @@ -1,23 +0,0 @@ -""" -This file was generated by the KCL auto-gen tool. DO NOT EDIT. -Editing this file might prove futile when you re-run the KCL auto-gen generate command. -""" - -{ - apiVersion = "platform.acme.co/v1alpha1" - kind = "Cluster" - metadata = { - name = option("resourcename") - } - spec = { - parameters = { - initialNodeCount = 1 - networkRef = { - } - subnetworkRef = { - } - project = "acme-project" - location = "us-central1" - } - } -} diff --git a/examples/XCluster/claim.yaml b/examples/XCluster/claim.yaml deleted file mode 100644 index 31463fc..0000000 --- a/examples/XCluster/claim.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: platform.acme.co/v1alpha1 -kind: Cluster -metadata: - name: cluster1 -spec: - parameters: - initialNodeCount: 1 - networkRef: {} - subnetworkRef: {} - project: acme-project - location: us-central1 diff --git a/examples/XCompositeCluster/claim.k b/examples/XCompositeCluster/claim.k deleted file mode 100644 index 8bd4d91..0000000 --- a/examples/XCompositeCluster/claim.k +++ /dev/null @@ -1,19 +0,0 @@ -""" -This file was generated by the KCL auto-gen tool. DO NOT EDIT. -Editing this file might prove futile when you re-run the KCL auto-gen generate command. -""" - -{ - apiVersion = "platform.acme.co/v1alpha1" - kind = "CompositeCluster" - metadata = { - name = option("resourcename") - } - spec = { - parameters = { - nodeCount = 1 - size = "small" - location = "us-central1" - } - } -} diff --git a/examples/XCompositeCluster/claim.yaml b/examples/XCompositeCluster/claim.yaml deleted file mode 100644 index f0622bc..0000000 --- a/examples/XCompositeCluster/claim.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: platform.acme.co/v1alpha1 -kind: CompositeCluster -metadata: - name: custom-cluster1 -spec: - parameters: - nodeCount: 1 - size: small - location: us-central1 diff --git a/examples/XDatabase/claim.k b/examples/XDatabase/claim.k deleted file mode 100644 index 2875a12..0000000 --- a/examples/XDatabase/claim.k +++ /dev/null @@ -1,19 +0,0 @@ -""" -This file was generated by the KCL auto-gen tool. DO NOT EDIT. -Editing this file might prove futile when you re-run the KCL auto-gen generate command. -""" - -{ - apiVersion = "platform.acme.co/v1alpha1" - kind = "Database" - metadata = { - name = option("resourcename") - } - spec = { - parameters = { - region = "east" - size = "small" - storage = 10 - } - } -} diff --git a/examples/XDatabase/claim.yaml b/examples/XDatabase/claim.yaml deleted file mode 100644 index 7da74d4..0000000 --- a/examples/XDatabase/claim.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: platform.acme.co/v1alpha1 -kind: Database -metadata: - name: database1 -spec: - parameters: - region: "east" - size: "small" - storage: 10 diff --git a/examples/XNetwork/claim.k b/examples/XNetwork/claim.k deleted file mode 100644 index e5ff728..0000000 --- a/examples/XNetwork/claim.k +++ /dev/null @@ -1,18 +0,0 @@ -""" -This file was generated by the KCL auto-gen tool. DO NOT EDIT. -Editing this file might prove futile when you re-run the KCL auto-gen generate command. -""" - -{ - apiVersion = "platform.acme.co/v1alpha1" - kind = "Network" - metadata = { - name = option("resourcename") - } - spec = { - parameters = { - autoCreateSubnetworks = True - routingMode = "GLOBAL" - } - } -} diff --git a/examples/XNetwork/claim.yaml b/examples/XNetwork/claim.yaml deleted file mode 100644 index 92ff9fb..0000000 --- a/examples/XNetwork/claim.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: platform.acme.co/v1alpha1 -kind: Network -metadata: - name: network1 -spec: - parameters: - autoCreateSubnetworks: true - routingMode: "GLOBAL" diff --git a/examples/XNodePool/claim.k b/examples/XNodePool/claim.k deleted file mode 100644 index 40deca9..0000000 --- a/examples/XNodePool/claim.k +++ /dev/null @@ -1,27 +0,0 @@ -""" -This file was generated by the KCL auto-gen tool. DO NOT EDIT. -Editing this file might prove futile when you re-run the KCL auto-gen generate command. -""" - -{ - apiVersion = "platform.acme.co/v1alpha1" - kind = "NodePool" - metadata = { - name = option("resourcename") - } - spec = { - parameters = { - nodeConfig = [ - { - machineType = "e2-medium" - preemptible = True - nodeCount = 1 - serviceAccountRef = { - } - clusterRef = { - } - } - ] - } - } -} diff --git a/examples/XNodePool/claim.yaml b/examples/XNodePool/claim.yaml deleted file mode 100644 index f302fbb..0000000 --- a/examples/XNodePool/claim.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: platform.acme.co/v1alpha1 -kind: NodePool -metadata: - name: nodepool1 -spec: - parameters: - nodeConfig: - - machineType: "e2-medium" - preemptible: true - nodeCount: 1 - serviceAccountRef: {} - clusterRef: {} diff --git a/examples/XServiceAccount/claim.k b/examples/XServiceAccount/claim.k deleted file mode 100644 index e19f092..0000000 --- a/examples/XServiceAccount/claim.k +++ /dev/null @@ -1,17 +0,0 @@ -""" -This file was generated by the KCL auto-gen tool. DO NOT EDIT. -Editing this file might prove futile when you re-run the KCL auto-gen generate command. -""" - -{ - apiVersion = "platform.acme.co/v1alpha1" - kind = "ServiceAccount" - metadata = { - name = option("resourcename") - } - spec = { - parameters = { - displayName = "service account 1" - } - } -} diff --git a/examples/XServiceAccount/claim.yaml b/examples/XServiceAccount/claim.yaml deleted file mode 100644 index 1873ea1..0000000 --- a/examples/XServiceAccount/claim.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: platform.acme.co/v1alpha1 -kind: ServiceAccount -metadata: - name: serviceaccount1 -spec: - parameters: - displayName: "service account 1" diff --git a/examples/XSubnetwork/claim.k b/examples/XSubnetwork/claim.k deleted file mode 100644 index 1ea6636..0000000 --- a/examples/XSubnetwork/claim.k +++ /dev/null @@ -1,26 +0,0 @@ -""" -This file was generated by the KCL auto-gen tool. DO NOT EDIT. -Editing this file might prove futile when you re-run the KCL auto-gen generate command. -""" - -{ - apiVersion = "platform.acme.co/v1alpha1" - kind = "Subnetwork" - metadata = { - name = option("resourcename") - } - spec = { - parameters = { - ipCidrRange = "10.2.0.0/16" - networkRef = { - } - region = "us-central1" - secondaryIpRange = [ - { - ipCidrRange = "192.168.10.0/24" - rangeName = "test-secondary-range-update1" - } - ] - } - } -} diff --git a/examples/XSubnetwork/claim.yaml b/examples/XSubnetwork/claim.yaml deleted file mode 100644 index 4c673a9..0000000 --- a/examples/XSubnetwork/claim.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: platform.acme.co/v1alpha1 -kind: Subnetwork -metadata: - name: subnetwork1 -spec: - parameters: - ipCidrRange: "10.2.0.0/16" - networkRef: {} - region: us-central1 - secondaryIpRange: - - ipCidrRange: 192.168.10.0/24 - rangeName: test-secondary-range-update1 diff --git a/examples/XAccountScaffold/xr.yaml b/examples/accountscaffold/xr.yaml similarity index 76% rename from examples/XAccountScaffold/xr.yaml rename to examples/accountscaffold/xr.yaml index 6a62891..4e86489 100644 --- a/examples/XAccountScaffold/xr.yaml +++ b/examples/accountscaffold/xr.yaml @@ -1,9 +1,10 @@ apiVersion: platform.acme.co/v1alpha1 -kind: XAccountScaffold +kind: AccountScaffold metadata: name: custom-account1 + namespace: default annotations: - render.crossplane.io/composition-path: apis/composition-basics/XAccountScaffold/composition.yaml + render.crossplane.io/composition-path: apis/composition-basics/accountscaffold/composition.yaml render.crossplane.io/function-path: examples/functions.yaml spec: parameters: diff --git a/examples/XCluster/xr.yaml b/examples/cluster/xr.yaml similarity index 71% rename from examples/XCluster/xr.yaml rename to examples/cluster/xr.yaml index 33d5eb0..ce0f0c6 100644 --- a/examples/XCluster/xr.yaml +++ b/examples/cluster/xr.yaml @@ -1,9 +1,10 @@ apiVersion: platform.acme.co/v1alpha1 -kind: XCluster +kind: Cluster metadata: name: cluster1 + namespace: default annotations: - render.crossplane.io/composition-path: apis/primitives/XCluster/composition.yaml + render.crossplane.io/composition-path: apis/primitives/cluster/composition.yaml render.crossplane.io/function-path: examples/functions.yaml spec: parameters: diff --git a/examples/XCompositeCluster/xr.yaml b/examples/compositecluster/xr.yaml similarity index 78% rename from examples/XCompositeCluster/xr.yaml rename to examples/compositecluster/xr.yaml index 299e526..fb7dbbd 100644 --- a/examples/XCompositeCluster/xr.yaml +++ b/examples/compositecluster/xr.yaml @@ -1,9 +1,10 @@ apiVersion: platform.acme.co/v1alpha1 -kind: XCompositeCluster +kind: CompositeCluster metadata: name: custom-cluster1 + namespace: default annotations: - render.crossplane.io/composition-path: apis/composition-basics/XCompositeCluster/composition.yaml + render.crossplane.io/composition-path: apis/composition-basics/compositecluster/composition.yaml render.crossplane.io/function-path: examples/functions.yaml spec: parameters: diff --git a/examples/XDatabase/xr.yaml b/examples/database/xr.yaml similarity index 64% rename from examples/XDatabase/xr.yaml rename to examples/database/xr.yaml index ba37053..e5c7805 100644 --- a/examples/XDatabase/xr.yaml +++ b/examples/database/xr.yaml @@ -1,9 +1,10 @@ apiVersion: platform.acme.co/v1alpha1 -kind: XDatabase +kind: Database metadata: name: database1 + namespace: default annotations: - render.crossplane.io/composition-path: apis/primitives/XDatabase/composition.yaml + render.crossplane.io/composition-path: apis/primitives/database/composition.yaml render.crossplane.io/function-path: examples/functions.yaml spec: parameters: diff --git a/examples/XNetwork/xr.yaml b/examples/network/xr.yaml similarity index 65% rename from examples/XNetwork/xr.yaml rename to examples/network/xr.yaml index 275914e..a2b1de2 100644 --- a/examples/XNetwork/xr.yaml +++ b/examples/network/xr.yaml @@ -1,9 +1,10 @@ apiVersion: platform.acme.co/v1alpha1 -kind: XNetwork +kind: Network metadata: name: network1 + namespace: default annotations: - render.crossplane.io/composition-path: apis/primitives/XNetwork/composition.yaml + render.crossplane.io/composition-path: apis/primitives/network/composition.yaml render.crossplane.io/function-path: examples/functions.yaml spec: parameters: diff --git a/examples/XNodePool/xr.yaml b/examples/nodepool/xr.yaml similarity index 71% rename from examples/XNodePool/xr.yaml rename to examples/nodepool/xr.yaml index 2977dfa..4a168f9 100644 --- a/examples/XNodePool/xr.yaml +++ b/examples/nodepool/xr.yaml @@ -1,9 +1,10 @@ apiVersion: platform.acme.co/v1alpha1 -kind: XNodePool +kind: NodePool metadata: name: nodepool1 + namespace: default annotations: - render.crossplane.io/composition-path: apis/primitives/XNodepool/composition.yaml + render.crossplane.io/composition-path: apis/primitives/nodepool/composition.yaml render.crossplane.io/function-path: examples/functions.yaml spec: parameters: diff --git a/examples/XServiceAccount/xr.yaml b/examples/serviceaccount/xr.yaml similarity index 60% rename from examples/XServiceAccount/xr.yaml rename to examples/serviceaccount/xr.yaml index be4b77a..15ba7e6 100644 --- a/examples/XServiceAccount/xr.yaml +++ b/examples/serviceaccount/xr.yaml @@ -1,9 +1,10 @@ apiVersion: platform.acme.co/v1alpha1 -kind: XServiceAccount +kind: ServiceAccount metadata: name: serviceaccount1 + namespace: default annotations: - render.crossplane.io/composition-path: apis/primitives/XServiceAccount/composition.yaml + render.crossplane.io/composition-path: apis/primitives/serviceaccount/composition.yaml render.crossplane.io/function-path: examples/functions.yaml spec: parameters: diff --git a/examples/XSubnetwork/xr.yaml b/examples/subnetwork/xr.yaml similarity index 73% rename from examples/XSubnetwork/xr.yaml rename to examples/subnetwork/xr.yaml index 248eb6e..b2b5aba 100644 --- a/examples/XSubnetwork/xr.yaml +++ b/examples/subnetwork/xr.yaml @@ -1,9 +1,10 @@ apiVersion: platform.acme.co/v1alpha1 -kind: XSubnetwork +kind: Subnetwork metadata: name: subnetwork1 + namespace: default annotations: - render.crossplane.io/composition-path: apis/primitives/XSubnetwork/composition.yaml + render.crossplane.io/composition-path: apis/primitives/subnetwork/composition.yaml render.crossplane.io/function-path: examples/functions.yaml spec: parameters: diff --git a/examples/test-harness.sh b/examples/test-harness.sh deleted file mode 100755 index 9ed048d..0000000 --- a/examples/test-harness.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/bash -cleanup_flag='' - -print_usage() { - printf "Usage: -c cleans up all resources on the target MCP, no flags generates random resources." -} - -# Check for cleanup -while getopts 'c' flag; do - case "${flag}" in - c) cleanup_flag='true' ;; - *) print_usage - exit 1 ;; - esac -done - -if [[ $cleanup_flag ]]; then - echo "Cleaning up all resources on control plane." - kubectl delete --all Clusters.platform,Databases.platform,Networks.platform,ServiceAccounts.platform,Subnetworks.platform,NodePools.platform,CompositeClusters.platform,AccountScaffolds.platform - exit 1 -fi - -# Check for prerequisites to be instsalled -if ! [ -x "$(command -v kcl)" ]; then - echo "The test harness requires kcl. kcl couldn't be found; please install it first: https://www.kcl-lang.io/docs/user_docs/getting-started/install" - >&2 - exit 1 -fi - -# Confirm user wants to create resources against current kubecontext before continuing -echo "This script uses your current kubecontext to create several claims against the APIs defined in this configuration." -read -p "Are you sure you want to continue (y/n)? " CONT -if [ "$CONT" = "y" ]; then - echo "This scipt will apply a random number of claims for each XR type defined in this configuration."; -else - exit 1; -fi - -# Generate a random number of clusters -random_number=$((1 + RANDOM % 10)) -counter=1 -while [ $counter -le $random_number ] -do - clustername=cluster"$counter" - kcl XCluster/claim.k -D resourcename=$clustername | kubectl apply -f - - ((counter++)) -done - -# Generate a random number of databases -random_number=$((1 + RANDOM % 10)) -counter=1 -while [ $counter -le $random_number ] -do - databasename=database"$counter" - kcl XDatabase/claim.k -D resourcename=$databasename | kubectl apply -f - - ((counter++)) -done - -# Generate a random number of networks -random_number=$((1 + RANDOM % 10)) -counter=1 -while [ $counter -le $random_number ] -do - networkname=network"$counter" - kcl XNetwork/claim.k -D resourcename=$networkname | kubectl apply -f - - ((counter++)) -done - -# Generate a random number of nodepools -random_number=$((1 + RANDOM % 10)) -counter=1 -while [ $counter -le $random_number ] -do - nodepoolname=nodepool"$counter" - kcl XNodePool/claim.k -D resourcename=$nodepoolname | kubectl apply -f - - ((counter++)) -done - -# Generate a random number of service accounts -random_number=$((1 + RANDOM % 10)) -counter=1 -while [ $counter -le $random_number ] -do - serviceaccountname=serviceaccount"$counter" - kcl XServiceAccount/claim.k -D resourcename=$serviceaccountname | kubectl apply -f - - ((counter++)) -done - -# Generate a random number of subnetworks -random_number=$((1 + RANDOM % 10)) -counter=1 -while [ $counter -le $random_number ] -do - subnetworkname=subnetwork"$counter" - kcl XSubnetwork/claim.k -D resourcename=$subnetworkname | kubectl apply -f - - ((counter++)) -done - -# Generate a random number of composite clusters -random_number=$((1 + RANDOM % 10)) -counter=1 -while [ $counter -le $random_number ] -do - compositeclustername=cluster"$counter" - kcl XCompositeCluster/claim.k -D resourcename=$compositeclustername | kubectl apply -f - - ((counter++)) -done - -# Generate a random number of account scaffolds -random_number=$((1 + RANDOM % 10)) -counter=1 -while [ $counter -le $random_number ] -do - accountscaffoldname=account"$counter" - kcl XAccountScaffold/claim.k -D resourcename=$accountscaffoldname | kubectl apply -f - - ((counter++)) -done \ No newline at end of file