-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from ytsarev/database
Add Database abstraction and README update
- Loading branch information
Showing
19 changed files
with
417 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: gcp.platformref.upbound.io/v1alpha1 | ||
kind: PostgreSQLInstance | ||
metadata: | ||
name: platform-ref-gcp-db | ||
namespace: default | ||
annotations: | ||
uptest.upbound.io/pre-delete-hook: testhooks/delete-sql-user.sh | ||
spec: | ||
parameters: | ||
storageGB: 10 | ||
passwordSecretRef: | ||
namespace: default | ||
name: psqlsecret | ||
key: password | ||
clusterRef: | ||
id: platform-ref-gcp-cluster | ||
writeConnectionSecretToRef: | ||
name: platform-ref-gcp-db-conn | ||
--- | ||
apiVersion: v1 | ||
data: | ||
password: dXBiMHVuZHIwY2s1ITMxMzM3 | ||
kind: Secret | ||
metadata: | ||
name: psqlsecret | ||
namespace: default | ||
type: Opaque |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
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 |
Oops, something went wrong.