Skip to content

Commit d4ab9a2

Browse files
author
Craig D Wilhite
committed
Add example compositions and XRDs
1 parent e3d9ade commit d4ab9a2

8 files changed

Lines changed: 373 additions & 0 deletions

File tree

‎.up/examples/postgresql.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: database.starter.org/v1alpha1
2+
kind: PostgreSQLInstance
3+
metadata:
4+
name: my-db
5+
spec:
6+
parameters:
7+
region: east
8+
size: small
9+
storage: 20

‎apis/network/composition.yaml‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
apiVersion: apiextensions.crossplane.io/v1
2+
kind: Composition
3+
metadata:
4+
name: xnetworks.infrastructure.example.org
5+
labels:
6+
provider: gcp
7+
spec:
8+
writeConnectionSecretsToNamespace: upbound-system
9+
compositeTypeRef:
10+
apiVersion: infrastructure.example.org/v1alpha1
11+
kind: XNetwork
12+
patchSets:
13+
- name: network-id
14+
patches:
15+
- type: FromCompositeFieldPath
16+
fromFieldPath: spec.id
17+
toFieldPath: metadata.labels[networks.infrastructure.example.org/network-id]
18+
resources:
19+
- base:
20+
apiVersion: compute.gcp.upbound.io/v1beta1
21+
kind: Network
22+
spec:
23+
forProvider:
24+
autoCreateSubnetworks: false
25+
routingMode: REGIONAL
26+
patches:
27+
- fromFieldPath: spec.id
28+
toFieldPath: metadata.name
29+
- fromFieldPath: spec.id
30+
toFieldPath: metadata.labels[networks.infrastructure.example.org/network-id]
31+
- base:
32+
apiVersion: compute.gcp.upbound.io/v1beta1
33+
kind: Subnetwork
34+
spec:
35+
forProvider:
36+
region: us-west2 #patched
37+
networkSelector:
38+
# This selector ensures this Subnetwork will select and use the
39+
# above Network. They will both be part of the XR, and thus their
40+
# controller references will match.
41+
matchControllerRef: true
42+
privateIpGoogleAccess: true
43+
ipCidrRange: 172.16.0.0/16
44+
secondaryIpRange:
45+
- rangeName: pods
46+
ipCidrRange: 10.200.0.0/14
47+
- rangeName: services
48+
ipCidrRange: 10.204.0.0/16
49+
patches:
50+
- fromFieldPath: spec.id
51+
toFieldPath: metadata.labels[networks.infrastructure.example.org/network-id]
52+
- fromFieldPath: spec.location
53+
toFieldPath: spec.forProvider.region
54+
transforms:
55+
- type: map
56+
map:
57+
'East US': 'us-east1'
58+
'West US': 'us-west2'

‎apis/network/definition.yaml‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
apiVersion: apiextensions.crossplane.io/v1
2+
kind: CompositeResourceDefinition
3+
metadata:
4+
name: xnetworks.infrastructure.example.org
5+
spec:
6+
group: infrastructure.example.org
7+
names:
8+
kind: XNetwork
9+
plural: xnetworks
10+
versions:
11+
- name: v1alpha1
12+
served: true
13+
referenceable: true
14+
schema:
15+
openAPIV3Schema:
16+
type: object
17+
properties:
18+
spec:
19+
type: object
20+
properties:
21+
id:
22+
type: string
23+
description: "ID of this Network that other objects will use to refer to it."
24+
location:
25+
type: string
26+
enum:
27+
- 'East US'
28+
- 'West US'
29+
description: "Zone or region for the Network"
30+
required:
31+
- id
32+
- location
33+
status:
34+
type: object
35+
properties:
36+
subnetIds:
37+
type: array
38+
items:
39+
type: string

‎apis/postgres/composition.yaml‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
apiVersion: apiextensions.crossplane.io/v1
2+
kind: Composition
3+
metadata:
4+
name: xpostgresqlinstances.gcp.database.starter.org
5+
labels:
6+
provider: gcp
7+
spec:
8+
writeConnectionSecretsToNamespace: upbound-system
9+
compositeTypeRef:
10+
apiVersion: database.starter.org/v1alpha1
11+
kind: XPostgreSQLInstance
12+
resources:
13+
- name: DBInstance
14+
base:
15+
apiVersion: sql.gcp.upbound.io/v1beta1
16+
kind: DatabaseInstance
17+
spec:
18+
forProvider:
19+
databaseVersion: POSTGRES_13
20+
deletionProtection: false
21+
region: us-west1
22+
settings:
23+
- diskSize: 20
24+
tier: db-f1-micro
25+
writeConnectionSecretToRef:
26+
namespace: upbound-system
27+
patches:
28+
- fromFieldPath: "metadata.uid"
29+
toFieldPath: "spec.writeConnectionSecretToRef.name"
30+
transforms:
31+
- type: string
32+
string:
33+
fmt: "%s-postgresql"
34+
- fromFieldPath: "spec.parameters.region"
35+
toFieldPath: "spec.forProvider.region"
36+
transforms:
37+
- type: map
38+
map:
39+
east: us-east1
40+
west: us-west1
41+
- fromFieldPath: "spec.parameters.size"
42+
toFieldPath: "spec.forProvider.settings[0].tier"
43+
transforms:
44+
- type: map
45+
map:
46+
small: db-f1-micro
47+
medium: db-g1-small
48+
large: db-custom-16-61440
49+
- fromFieldPath: "spec.parameters.storage"
50+
toFieldPath: "spec.forProvider.settings[0].diskSize"
51+
connectionDetails:
52+
- fromFieldPath: "status.atProvider.publicIpAddress"
53+
name: endpoint

‎apis/postgres/definition.yaml‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
apiVersion: apiextensions.crossplane.io/v1
2+
kind: CompositeResourceDefinition
3+
metadata:
4+
name: xpostgresqlinstances.database.starter.org
5+
spec:
6+
group: database.starter.org
7+
names:
8+
kind: XPostgreSQLInstance
9+
plural: xpostgresqlinstances
10+
claimNames:
11+
kind: PostgreSQLInstance
12+
plural: postgresqlinstances
13+
connectionSecretKeys:
14+
- endpoint
15+
versions:
16+
- name: v1alpha1
17+
served: true
18+
referenceable: true
19+
schema:
20+
openAPIV3Schema:
21+
type: object
22+
properties:
23+
spec:
24+
type: object
25+
description: |
26+
The specification for how this PostgreSQLInstance should be
27+
deployed.
28+
properties:
29+
parameters:
30+
type: object
31+
description: |
32+
The parameters indicating how this PostgreSQLInstance should
33+
be configured.
34+
properties:
35+
region:
36+
type: string
37+
enum:
38+
- east
39+
- west
40+
description: |
41+
The geographic region in which this PostgreSQLInstance
42+
should be deployed.
43+
size:
44+
type: string
45+
enum:
46+
- small
47+
- medium
48+
- large
49+
description: |
50+
The machine size for this PostgreSQLInstance.
51+
storage:
52+
type: integer
53+
minimum: 10
54+
description: |
55+
The storage size for this PostgreSQLInstance in GB.
56+
required:
57+
- region
58+
- size
59+
- storage
60+
required:
61+
- parameters

‎apis/vm/composition.yaml‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
apiVersion: apiextensions.crossplane.io/v1
2+
kind: Composition
3+
metadata:
4+
name: xvirtualmachines.infrastructure.example.org
5+
labels:
6+
provider: gcp
7+
spec:
8+
compositeTypeRef:
9+
apiVersion: infrastructure.example.org/v1alpha1
10+
kind: XVirtualMachine
11+
resources:
12+
- base:
13+
apiVersion: infrastructure.example.org/v1alpha1
14+
kind: XNetwork
15+
patches:
16+
- fromFieldPath: spec.id
17+
toFieldPath: spec.id
18+
- fromFieldPath: spec.parameters.location
19+
toFieldPath: spec.location
20+
name: compositeNetGoogleVM
21+
- base:
22+
apiVersion: compute.gcp.upbound.io/v1beta1
23+
kind: Instance
24+
spec:
25+
forProvider:
26+
networkInterface:
27+
- networkSelector:
28+
matchLabels:
29+
networks.infrastructure.example.org/network-id: to-be-patched
30+
subnetworkSelector:
31+
matchLabels:
32+
networks.infrastructure.example.org/network-id: to-be-patched
33+
bootDisk:
34+
- initializeParams:
35+
- image: debian-cloud/debian-11 # patched
36+
machineType: e2-medium # patched
37+
zone: us-east1-b # patched
38+
patches:
39+
- fromFieldPath: spec.parameters.location
40+
toFieldPath: spec.forProvider.zone
41+
transforms:
42+
- type: map
43+
map:
44+
'East US': 'us-east1-b'
45+
'West US': 'us-west1-a'
46+
- fromFieldPath: spec.parameters.operatingSystem
47+
toFieldPath: spec.forProvider.bootDisk[0].initializeParams[0].image
48+
transforms:
49+
- type: map
50+
map:
51+
'Windows': windows-cloud/windows-2022
52+
'Linux (Ubuntu)': debian-cloud/debian-11
53+
- fromFieldPath: spec.parameters.vmSize
54+
toFieldPath: spec.forProvider.machineType
55+
transforms:
56+
- type: map
57+
map:
58+
'1 vCPU, 1 GB': e2-standard-2
59+
'2 vCPU, 8 GB': n2-standard-2
60+
'4 vCPU, 16 GB': n2-standard-4
61+
# Create this machine in the Network and Subnetwork referenced by network ID
62+
- fromFieldPath: spec.id
63+
toFieldPath: spec.forProvider.networkInterface[0].networkSelector.matchLabels[networks.infrastructure.example.org/network-id]
64+
- fromFieldPath: spec.id
65+
toFieldPath: spec.forProvider.networkInterface[0].subnetworkSelector.matchLabels[networks.infrastructure.example.org/network-id]
66+
name: compositeMachineGoogle

‎apis/vm/definition.yaml‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
apiVersion: apiextensions.crossplane.io/v1
2+
kind: CompositeResourceDefinition
3+
metadata:
4+
name: xvirtualmachines.infrastructure.example.org
5+
spec:
6+
group: infrastructure.example.org
7+
names:
8+
kind: XVirtualMachine
9+
plural: xvirtualmachines
10+
claimNames:
11+
kind: VirtualMachine
12+
plural: virtualmachines
13+
versions:
14+
- name: v1alpha1
15+
served: true
16+
referenceable: true
17+
schema:
18+
openAPIV3Schema:
19+
type: object
20+
properties:
21+
spec:
22+
type: object
23+
properties:
24+
id:
25+
type: string
26+
description: "ID of this Virtual Machine that other objects will use to refer to it."
27+
minLength: 1
28+
# Maximum key length in GCP is 40 characters. We are setting a 34 character
29+
# limit to accomodate the generated hash suffix ('-' + 5 chars).
30+
maxLength: 34
31+
parameters:
32+
type: object
33+
description: "Virtual Machine parameters."
34+
properties:
35+
location:
36+
type: string
37+
description: "Zone or region for the Virtual Machine (default: `us-east1-b`)"
38+
enum:
39+
- 'East US'
40+
- 'West US'
41+
operatingSystem:
42+
type: string
43+
description: "The Operating System to be used for the Virtual Machine image"
44+
enum:
45+
- 'Windows'
46+
- 'Linux (Ubuntu)'
47+
vmSize:
48+
type: string
49+
description: "Size of the Virtual Machine (default: `e2-standard-4`)"
50+
enum:
51+
- '1 vCPU, 1 GB'
52+
- '2 vCPU, 8 GB'
53+
- '4 vCPU, 16 GB'
54+
required:
55+
- location
56+
required:
57+
- id
58+
- parameters
59+
status:
60+
type: object
61+
properties:
62+
subnetIds:
63+
type: array
64+
items:
65+
type: string

‎crossplane.yaml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: meta.pkg.crossplane.io/v1alpha1
2+
kind: Configuration
3+
metadata:
4+
name: configuration-cloudsql
5+
annotations:
6+
meta.crossplane.io/maintainer: The Getting Started Organization <support@starter.org>
7+
meta.crossplane.io/source: github.com/upbound/configuration-cloudsql
8+
meta.crossplane.io/license: Apache-2.0
9+
meta.crossplane.io/description: |
10+
This GCP starter configuration offers PostgreSQL as a service backed by
11+
CloudSQL.
12+
meta.crossplane.io/readme: |
13+
This Configuration includes an API that will allow control planes to
14+
provision fully configured Google Cloud Platform (GCP) CloudSQL instances,
15+
composed using cloud service primitives from the [Upbound Official GCP
16+
Provider](https://marketplace.upbound.io/providers/upbound/provider-gcp).
17+
spec:
18+
crossplane:
19+
version: ">=v1.7.0-0"
20+
dependsOn:
21+
- provider: xpkg.upbound.io/upbound/provider-gcp
22+
version: ">=v0.27.0"

0 commit comments

Comments
 (0)