diff --git a/cluster/examples/workloads/kubernetes/wordpress/aws/app.yaml b/cluster/examples/workloads/kubernetes/wordpress/app.yaml similarity index 100% rename from cluster/examples/workloads/kubernetes/wordpress/aws/app.yaml rename to cluster/examples/workloads/kubernetes/wordpress/app.yaml diff --git a/cluster/examples/workloads/kubernetes/wordpress/aws/cluster.yaml b/cluster/examples/workloads/kubernetes/wordpress/cluster.yaml similarity index 100% rename from cluster/examples/workloads/kubernetes/wordpress/aws/cluster.yaml rename to cluster/examples/workloads/kubernetes/wordpress/cluster.yaml diff --git a/cluster/examples/workloads/kubernetes/wordpress/aws/database.yaml b/cluster/examples/workloads/kubernetes/wordpress/database.yaml similarity index 100% rename from cluster/examples/workloads/kubernetes/wordpress/aws/database.yaml rename to cluster/examples/workloads/kubernetes/wordpress/database.yaml diff --git a/cluster/examples/workloads/kubernetes/wordpress/gcp/environment.yaml b/cluster/examples/workloads/kubernetes/wordpress/gcp/environment.yaml deleted file mode 100644 index c2b12793f15..00000000000 --- a/cluster/examples/workloads/kubernetes/wordpress/gcp/environment.yaml +++ /dev/null @@ -1,43 +0,0 @@ ---- -apiVersion: database.gcp.crossplane.io/v1beta1 -kind: CloudsqlInstanceClass -metadata: - name: standard-cloudsql - labels: - example: "true" -specTemplate: - writeConnectionSecretsToNamespace: crossplane-system - forProvider: - databaseVersion: MYSQL_5_7 - region: us-central1 - settings: - tier: db-n1-standard-1 - dataDiskType: PD_SSD - dataDiskSizeGb: 10 - # Note from GCP Docs: Your Cloud SQL instances are not created in your VPC network. - # They are created in the service producer network (a VPC network internal to Google) that is then connected (peered) to your VPC network. - ipConfiguration: - privateNetwork: projects/crossplane-playground/global/networks/example-network - providerRef: - name: example - reclaimPolicy: Delete ---- -apiVersion: compute.gcp.crossplane.io/v1alpha2 -kind: GKEClusterClass -metadata: - name: standard-gke - labels: - example: "true" -specTemplate: - writeConnectionSecretsToNamespace: crossplane-system - machineType: n1-standard-1 - numNodes: 1 - zone: us-central1-b - network: projects/crossplane-playground/global/networks/example-network - subnetwork: projects/crossplane-playground/regions/us-central1/subnetworks/example-subnetwork - enableIPAlias: true - clusterSecondaryRangeName: pods - servicesSecondaryRangeName: services - providerRef: - name: example - reclaimPolicy: Delete diff --git a/cluster/examples/workloads/kubernetes/wordpress/gcp/network.yaml b/cluster/examples/workloads/kubernetes/wordpress/gcp/network.yaml deleted file mode 100644 index 9c0beec3442..00000000000 --- a/cluster/examples/workloads/kubernetes/wordpress/gcp/network.yaml +++ /dev/null @@ -1,65 +0,0 @@ ---- -# example-network will be the VPC that all cloud instances we'll create will use. -apiVersion: compute.gcp.crossplane.io/v1alpha2 -kind: Network -metadata: - name: example-network -spec: - name: example-network - autoCreateSubnetworks: false - providerRef: - name: example - reclaimPolicy: Delete - routingConfig: - routingMode: REGIONAL ---- -# example-subnetwork defines IP ranges to be used by GKE cluster. -apiVersion: compute.gcp.crossplane.io/v1alpha2 -kind: Subnetwork -metadata: - name: example-subnetwork -spec: - providerRef: - name: example - reclaimPolicy: Delete - name: example-subnetwork - region: us-central1 - ipCidrRange: "192.168.0.0/24" - privateIpGoogleAccess: true - secondaryIpRanges: - - rangeName: pods - ipCidrRange: 10.0.0.0/8 - - rangeName: services - ipCidrRange: 172.16.0.0/16 - network: projects/crossplane-playground/global/networks/example-network ---- -# example-globaladdress defines the IP range that will be allocated for cloud services connecting -# to the instances in the given Network. -apiVersion: compute.gcp.crossplane.io/v1alpha2 -kind: GlobalAddress -metadata: - name: example-globaladdress -spec: - providerRef: - name: example - reclaimPolicy: Delete - name: example-globaladdress - purpose: VPC_PEERING - addressType: INTERNAL - prefixLength: 16 - network: projects/crossplane-playground/global/networks/example-network ---- -# example-connection is what allows cloud services to use the allocated GlobalAddress for communication. Behind -# the scenes, it creates a VPC peering to the network that those service instances actually live. -apiVersion: servicenetworking.gcp.crossplane.io/v1alpha2 -kind: Connection -metadata: - name: example-connection -spec: - providerRef: - name: example - reclaimPolicy: Delete - parent: services/servicenetworking.googleapis.com - network: projects/crossplane-playground/global/networks/example-network - reservedPeeringRanges: - - example-globaladdress \ No newline at end of file diff --git a/cluster/examples/workloads/kubernetes/wordpress/gcp/resource-classes/cloudsql-class.yaml b/cluster/examples/workloads/kubernetes/wordpress/gcp/resource-classes/cloudsql-class.yaml index b93c660dcd6..b8822dfe019 100644 --- a/cluster/examples/workloads/kubernetes/wordpress/gcp/resource-classes/cloudsql-class.yaml +++ b/cluster/examples/workloads/kubernetes/wordpress/gcp/resource-classes/cloudsql-class.yaml @@ -2,10 +2,11 @@ apiVersion: database.gcp.crossplane.io/v1beta1 kind: CloudsqlInstanceClass metadata: - name: standard-cloudsql + name: standard-mysql annotations: resourceclass.crossplane.io/is-default-class: "true" specTemplate: + writeConnectionSecretsToNamespace: crossplane-system forProvider: databaseVersion: MYSQL_5_7 region: us-central1 @@ -16,6 +17,6 @@ specTemplate: ipConfiguration: privateNetworkRef: name: sample-network - reclaimPolicy: Delete + reclaimPolicy: Delete providerRef: name: gcp-provider diff --git a/cluster/examples/workloads/kubernetes/wordpress/gcp/resource-classes/gke-class.yaml b/cluster/examples/workloads/kubernetes/wordpress/gcp/resource-classes/gke-class.yaml index aba8d310886..d20d60f5682 100644 --- a/cluster/examples/workloads/kubernetes/wordpress/gcp/resource-classes/gke-class.yaml +++ b/cluster/examples/workloads/kubernetes/wordpress/gcp/resource-classes/gke-class.yaml @@ -2,10 +2,11 @@ apiVersion: compute.gcp.crossplane.io/v1alpha2 kind: GKEClusterClass metadata: - name: standard-gke + name: standard-cluster annotations: resourceclass.crossplane.io/is-default-class: "true" specTemplate: + writeConnectionSecretsToNamespace: crossplane-system machineType: n1-standard-1 numNodes: 1 zone: us-central1-b diff --git a/cluster/examples/workloads/kubernetes/wordpress/gcp/workload.yaml b/cluster/examples/workloads/kubernetes/wordpress/gcp/workload.yaml deleted file mode 100644 index e6f57de8151..00000000000 --- a/cluster/examples/workloads/kubernetes/wordpress/gcp/workload.yaml +++ /dev/null @@ -1,131 +0,0 @@ ---- -apiVersion: compute.crossplane.io/v1alpha1 -kind: KubernetesCluster -metadata: - name: wordpress-demo-cluster - labels: - app: wordpress-demo -spec: - classSelector: - matchLabels: - example: "true" - writeConnectionSecretToRef: - name: wordpress-demo-cluster ---- -apiVersion: database.crossplane.io/v1alpha1 -kind: MySQLInstance -metadata: - name: sql -spec: - engineVersion: "5.7" - classSelector: - matchLabels: - example: "true" - # A secret is exported by providing the secret name - # to export it under. This is the name of the secret - # in the crossplane cluster, and it's scoped to this claim's namespace. - writeConnectionSecretToRef: - name: sql ---- -apiVersion: workload.crossplane.io/v1alpha1 -kind: KubernetesApplication -metadata: - name: wordpress-demo - labels: - app: wordpress-demo -spec: - resourceSelector: - matchLabels: - app: wordpress-demo - clusterSelector: - matchLabels: - app: wordpress-demo - resourceTemplates: - - metadata: - name: wordpress-demo-namespace - labels: - app: wordpress-demo - spec: - template: - apiVersion: v1 - kind: Namespace - metadata: - name: wordpress - labels: - app: wordpress - - metadata: - name: wordpress-demo-deployment - labels: - app: wordpress-demo - spec: - secrets: - # This must match the writeConnectionSecretToRef field - # on the database claim; it is the name of the secret to - # pull from the crossplane cluster, from this Application's namespace. - - name: sql - template: - apiVersion: apps/v1 - kind: Deployment - metadata: - namespace: wordpress - name: wordpress - labels: - app: wordpress - spec: - selector: - matchLabels: - app: wordpress - template: - metadata: - labels: - app: wordpress - spec: - containers: - - name: wordpress - image: wordpress:4.6.1-apache - env: - - name: WORDPRESS_DB_HOST - valueFrom: - secretKeyRef: - # This is the name of the secret to use to consume the secret - # within the managed cluster. The reason it's different from the - # name of the secret above is because within the managed cluster, - # a crossplane-managed secret is written as '{metadata.name}-{secretname}'. - # The metadata name is specified above for this resource, and so is - # the secret name. - name: wordpress-demo-deployment-sql - # The secret has privateIP and publicIP options for connecting to CloudSQL instance. - # privateIP will be assigned to endpoint key if available, otherwise publicIP. - key: endpoint - - name: WORDPRESS_DB_USER - valueFrom: - secretKeyRef: - name: wordpress-demo-deployment-sql - key: username - - name: WORDPRESS_DB_PASSWORD - valueFrom: - secretKeyRef: - name: wordpress-demo-deployment-sql - key: password - ports: - - containerPort: 80 - name: wordpress - - metadata: - name: wordpress-demo-service - labels: - app: wordpress-demo - spec: - template: - apiVersion: v1 - kind: Service - metadata: - namespace: wordpress - name: wordpress - labels: - app: wordpress - spec: - ports: - - port: 80 - selector: - app: wordpress - type: LoadBalancer \ No newline at end of file diff --git a/docs/stacks-guide-gcp.md b/docs/stacks-guide-gcp.md index c894e9225e6..7f220efbcec 100644 --- a/docs/stacks-guide-gcp.md +++ b/docs/stacks-guide-gcp.md @@ -147,7 +147,7 @@ First, let's encode the credential file contents and put it in a variable: ```bash # base64 encode the GCP credentials -BASE64ENCODED_GCP_PROVIDER_CREDS=$(base64 crossplane-gcp-provider-key.json | tr -d "\n") +BASE64ENCODED_GCP_ACCOUNT_CREDS=$(base64 crossplane-gcp-provider-key.json | tr -d "\n") ``` Now we’ll create the `Secret` resource that contains the credential, and @@ -163,13 +163,14 @@ metadata: namespace: crossplane-system type: Opaque data: - credentials.json: ${BASE64ENCODED_GCP_ACCOUNT_CREDS} + credentials: ${BASE64ENCODED_GCP_ACCOUNT_CREDS} --- apiVersion: gcp.crossplane.io/v1alpha2 kind: Provider metadata: name: gcp-provider spec: + # replace this with your own gcp project id projectID: my-cool-gcp-project credentialsSecretRef: namespace: crossplane-system @@ -391,56 +392,57 @@ Below we inspect each of these resource classes in more details: - **`CloudsqlInstanceClass`** Represents a resource that serves as a template to create a [Cloud SQL Database Instance][gcp-cloudsql]. -```yaml ---- -apiVersion: database.gcp.crossplane.io/v1beta1 -kind: CloudsqlInstanceClass -metadata: - name: standard-mysql - annotations: - resourceclass.crossplane.io/is-default-class: "true" -specTemplate: - forProvider: - databaseVersion: MYSQL_5_7 - region: us-central1 - settings: - tier: db-n1-standard-1 - dataDiskType: PD_SSD - dataDiskSizeGb: 10 - ipConfiguration: - privateNetworkRef: - name: sample-network - reclaimPolicy: Delete - providerRef: - name: gcp-provider -``` + ```yaml + --- + apiVersion: database.gcp.crossplane.io/v1beta1 + kind: CloudsqlInstanceClass + metadata: + name: standard-mysql + annotations: + resourceclass.crossplane.io/is-default-class: "true" + specTemplate: + writeConnectionSecretsToNamespace: crossplane-system + forProvider: + databaseVersion: MYSQL_5_7 + region: us-central1 + settings: + tier: db-n1-standard-1 + dataDiskType: PD_SSD + dataDiskSizeGb: 10 + ipConfiguration: + privateNetworkRef: + name: sample-network + reclaimPolicy: Delete + providerRef: + name: gcp-provider + ``` - **`GKEClusterClass`** Represents a resource that serves as a template to create a [Kubernetes Engine][gcp-gke] (GKE). -```yaml ---- -apiVersion: compute.gcp.crossplane.io/v1alpha2 -kind: GKEClusterClass -metadata: - name: standard-cluster - annotations: - resourceclass.crossplane.io/is-default-class: "true" -specTemplate: - machineType: n1-standard-1 - numNodes: 1 - zone: us-central1-b - networkRef: - name: sample-network - subnetworkRef: - name: sample-subnetwork - enableIPAlias: true - clusterSecondaryRangeName: pods - servicesSecondaryRangeName: services - reclaimPolicy: Delete - providerRef: - name: gcp-provider -``` + ```yaml + --- + apiVersion: compute.gcp.crossplane.io/v1alpha2 + kind: GKEClusterClass + metadata: + name: standard-cluster + annotations: + resourceclass.crossplane.io/is-default-class: "true" + specTemplate: + machineType: n1-standard-1 + numNodes: 1 + zone: us-central1-b + networkRef: + name: sample-network + subnetworkRef: + name: sample-subnetwork + enableIPAlias: true + clusterSecondaryRangeName: pods + servicesSecondaryRangeName: services + reclaimPolicy: Delete + providerRef: + name: gcp-provider + ``` These resources will be the default resource classes for the corresponding claims (`resourceclass.crossplane.io/is-default-class: "true"` annotation). For