Skip to content

Commit

Permalink
quick start revamp
Browse files Browse the repository at this point in the history
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
  • Loading branch information
hasheddan committed Sep 18, 2019
1 parent f4b191a commit 1bd53a0
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 260 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: database.crossplane.io/v1alpha1
kind: MySQLInstance
kind: MySQLInstanceClass
metadata:
name: mysql-standard
namespace: app-project1-dev
Expand All @@ -24,6 +24,7 @@ specTemplate:
region: us-west2
storageType: PD_SSD
storageGB: 10
ipv4Enabled: true
providerRef:
name: example
namespace: gcp-infra-dev
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: database.crossplane.io/v1alpha1
kind: MySQLInstance
kind: MySQLInstanceClass
metadata:
name: mysql-standard
namespace: app-project1-dev
Expand All @@ -22,6 +22,7 @@ specTemplate:
region: us-west2
storageType: PD_SSD
storageGB: 10
ipv4Enabled: true
providerRef:
name: example
namespace: gcp-infra-dev
Expand Down
5 changes: 0 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ If you have any questions, please drop us a note on [Crossplane Slack][join-cros

* [Quick Start Guide](quick-start.md)
* [Getting Started](getting-started.md)
* [Installing Crossplane](install-crossplane.md)
* [Adding Your Cloud Providers](cloud-providers.md)
* [Deploying Workloads](deploy.md)
* [Running Resources](running-resources.md)
* [Troubleshooting](troubleshoot.md)
* [Concepts](concepts.md)
* [API Reference](api.md)
* [FAQs](faqs.md)
Expand Down
1 change: 1 addition & 0 deletions docs/cloud-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ In order for Crossplane to be able to manage resources across all your clouds, y
Use the links below for specific instructions to add each of the following cloud providers:

* [Google Cloud Platform (GCP)](cloud-providers/gcp/gcp-provider.md)
* Required for Quick Start
* [Microsoft Azure](cloud-providers/azure/azure-provider.md)
* [Amazon Web Services (AWS)](cloud-providers/aws/aws-provider.md)

Expand Down
142 changes: 0 additions & 142 deletions docs/deploy.md

This file was deleted.

154 changes: 154 additions & 0 deletions docs/quick-start-gcp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
---
title: Provisioning a MySQL Database on GCP
toc: true
weight: 240
indent: true
---
# Provisioning a MySQL Database on GCP

Now that Crossplane and the GCP stack are installed in your Kubernetes cluster, and your GCP account credentials have been configured in `crossplane-gcp-provider-key.json`, a MySQL database can easily be provisioned on GCP.

## Namespaces

Namespaces allow for logical grouping of resources in Kubernetes. For this example, create one for GCP-specific infrastructure resources, and one for portable application resources:

```bash
kubectl create namespace gcp-infra-dev
kubectl create namespace app-project1-dev
```

## Provider

The `Provider` and `Secret` resources work together to store your GCP account credentials in Kubernetes. Because these resources are GCP-specific, create them in the `gcp-infra-dev` namespace:

```bash
cat > provider.yaml <<EOF
apiVersion: v1
kind: Secret
metadata:
name: example-provider-gcp
namespace: gcp-infra-dev
type: Opaque
data:
credentials.json: $BASE64ENCODED_GCP_PROVIDER_CREDS
---
apiVersion: gcp.crossplane.io/v1alpha2
kind: Provider
metadata:
name: example
namespace: gcp-infra-dev
spec:
credentialsSecretRef:
name: example-provider-gcp
key: credentials.json
projectID: $PROJECT_ID
EOF

kubectl apply -f provider.yaml
```

## Cloud-Specific Resource Class

Cloud-specific resource classes define configuration for a specific type of service that is offered by a cloud provider. GCP provides a managed MySQL database offering through its CloudSQL service. The GCP stack in Crossplane has a `CloudsqlInstanceClass` resource that allows us to store configuration details for a CloudSQL instance. Because this resource is specific to GCP, create it in the `gcp-infra-dev` namespace:

```bash
cat > cloudsql.yaml <<EOF
apiVersion: database.gcp.crossplane.io/v1alpha2
kind: CloudsqlInstanceClass
metadata:
name: standard-cloudsql
namespace: gcp-infra-dev
specTemplate:
databaseVersion: MYSQL_5_7
tier: db-n1-standard-1
region: us-central1
storageType: PD_SSD
storageGB: 10
ipv4Address: true
providerRef:
name: example
namespace: gcp-infra-dev
reclaimPolicy: Delete
EOF

kubectl apply -f cloudsql.yaml
```

## Portable Resource Class

Portable resource classes define a class of service for an abstract resource type (e.g. a MySQL database) that could be fulfilled by any number of managed service providers. They serve to direct any portable claim types (see below) to a cloud-specific resource class that can satisfy their abstract request. Create a `MySQLInstanceClass` in the `app-project1-dev` namespace:

```bash
cat > mysql-class.yaml <<EOF
apiVersion: database.crossplane.io/v1alpha1
kind: MySQLInstanceClass
metadata:
name: mysql-standard
namespace: app-project1-dev
classRef:
kind: CloudsqlInstanceClass
apiVersion: database.gcp.crossplane.io/v1alpha2
name: standard-cloudsql
namespace: gcp-infra-dev
EOF

kubectl apply -f mysql-class.yaml
```

## Portable Resource Claim

Portable resource claims serve as abstract requests to provision a service that can fulfill their specifications. In this example, we have specified that a request for a `standard-mysql` database will be fulfilled by GCP's CloudSQL service. Creating a `MySQLInstance` claim for a `standard-mysql` database in the same namespace as our `MySQLInstanceClass` will provision a `CloudsqlInstance` on GCP:

```bash
cat > mysql-claim.yaml <<EOF
apiVersion: database.crossplane.io/v1alpha1
kind: MySQLInstance
metadata:
name: app-mysql
namespace: app-project1-dev
spec:
classRef:
name: mysql-standard
writeConnectionSecretToRef:
name: mysqlconn
engineVersion: "5.6"
EOF

kubectl apply -f mysql-claim.yaml
```

## Observe

When the claim is created, Crossplane creates a `CloudSQLInstance` resource in the `gcp-infra-dev` namespace, which mirrors the CloudSQL MySQL database created in GCP. You can use the following commands to view your `CloudSQLInstance`:

```bash
$ kubectl -n gcp-infra-dev get cloudsqlinstances
NAME STATUS STATE CLASS VERSION AGE
mysqlinstance-516345d1-d9af-11e9-a1f2-4eae47c3c2d6 PENDING_CREATE standard-cloudsql MYSQL_5_6 3m
```

After some time, GCP will finish creating the CloudSQL database and Crossplane will inform you that the `STATUS` is `Bound` and the `STATE` is `RUNNABLE`:

```bash
$ kubectl -n gcp-infra-dev get cloudsqlinstances
NAME STATUS STATE CLASS VERSION AGE
mysqlinstance-516345d1-d9af-11e9-a1f2-4eae47c3c2d6 Bound RUNNABLE standard-cloudsql MYSQL_5_6 5m
```

You can also login to the GCP [console] to view your resource!

## Clean Up

The CloudSQL database on GCP and all Crossplane resources in your Kubernetes cluster can be deleted with the following commands:

```bash
kubectl delete -f mysql-claim.yaml
kubectl delete -f mysql-class.yaml
kubectl delete -f cloudsql.yaml
kubectl delete -f provider.yaml
```

<!-- Named Links -->


[console]: https://console.cloud.google.com
23 changes: 13 additions & 10 deletions docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ weight: 210
---
# Quick Start Guide

This quick start will demonstrate using Crossplane to deploy a portable stateful workload in the cloud provider of your choice.
It will first dynamically provision a Kubernetes cluster within the cloud provider environment, followed by a stateful application and its database to the same environment.
The database will also be dynamically provisioned using a managed service hosted by the cloud provider.
The Workload will be deployed into the target Kubernetes cluster, and be configured to consume the database resource in a completely portable way.
This quick start will demonstrate using Crossplane to deploy a portable MySQL
database on a single cloud provider, Google Cloud Platform. It serves as an initial introduction to
Crossplane, but only displays a small portion of its functionality.

The general steps for this example are as follows:

1. [Install Crossplane](install-crossplane.md) into your Kubernetes cluster.
1. [Add a cloud provider](cloud-providers.md) for managed service provisioning.
1. [Deploy a workload](deploy.md) (Wordpress) including the managed services it depends on (MySQL).
1. [Install Crossplane and the GCP stack](install-crossplane.md) into your Kubernetes cluster.
1. [Configure GCP credentials](cloud-providers/gcp/gcp-provider.md) in Crossplane.
1. [Provision a MySQL database](quick-start-gcp.md) on GCP.

Additional info:
* [Running Resources](running-resources.md)
* [Troubleshooting](troubleshoot.md)
## Next Steps

* Add additional [cloud provider stacks](cloud-providers.md) to Crossplane.
* Explore the [Services Guide](services-guide.md) and the [Stacks Guide](stacks-guide.md).
* Learn more about [Crossplane concepts](concepts.md).
* See what services are [currently supported](api.md) for each provider.
* Build [your own stacks](developer-guide.md)!
Loading

0 comments on commit 1bd53a0

Please sign in to comment.