4
4
5
5
This example is a full end to end example of delivering a containerized Ruby on Rails application. It
6
6
7
- * Provisions a [ Google Kubernetes Engine (GKE)] ( https://cloud.google.com/kubernetes-engine/ ) cluster
8
- * Provisions a fully managed Google Cloud SQL PostgreSQL database
9
- * Builds a containerized Ruby on Rails container image, and publishes it to Docker Hub
10
- * Deploys that container image as a Kubernetes Service inside of the provisioned GKE cluster
7
+ - Provisions a [ Google Kubernetes Engine (GKE)] ( https://cloud.google.com/kubernetes-engine/ ) cluster
8
+ - Provisions a fully managed Google Cloud SQL PostgreSQL database
9
+ - Builds a containerized Ruby on Rails container image, and publishes it to Docker Hub
10
+ - Deploys that container image as a Kubernetes Service inside of the provisioned GKE cluster
11
11
12
12
All of these happen behind a single ` pulumi up ` command, and are expressed in just a handful of TypeScript.
13
13
14
14
## Prerequisites
15
15
16
16
Ensure you have [ downloaded and installed the Pulumi CLI] ( https://www.pulumi.com/docs/get-started/install/ ) .
17
-
17
+ Esnure you have [ downloaded and installed Docker ] ( https://docs.docker.com/install/ )
18
18
We will be deploying to Google Cloud Platform (GCP), so you will need an account. If you don't have an account,
19
19
[ sign up for free here] ( https://cloud.google.com/free/ ) . In either case,
20
20
[ follow the instructions here] ( https://www.pulumi.com/docs/intro/cloud-providers/gcp/setup/ ) to connect Pulumi to your GCP account.
@@ -38,22 +38,25 @@ cluster and containerized Ruby on Rails application deployed into it, using a ho
38
38
` ` ` bash
39
39
$ pulumi config set gcp:project [your-gcp-project-here]
40
40
$ pulumi config set gcp:zone us-west1-a # any valid GCP zone works
41
- $ pulumi config set clusterPassword --secret [your-new-cluster-password-here]
41
+ $ pulumi config set clusterPassword --secret [your-new-cluster-password-here] # must be at least 16 characters
42
+ $ pulumi config set dbUsername [your-new-db-username-here]
42
43
$ pulumi config set dbPassword --secret [your-new-db-password-here]
43
44
$ pulumi config set dockerUsername [your-dockerhub-username-here]
44
45
$ pulumi config set dockerPassword --secret [your-dockerhub-password-here]
45
- $ pulumi config set masterVersion # any valid master version
46
+ $ pulumi config set masterVersion # any valid master version, or latest
46
47
` ` `
47
48
48
- By default, your cluster will have 3 nodes of type ` n1-standard-1` . This is configurable, however; for instance
49
- if we' d like to choose 5 nodes of type `n1-standard-2` instead, we can run these commands:
49
+ Config variables that use the ` --secret` flag are [encrypted and not stored as plaintext](https://www.pulumi.com/docs/intro/concepts/config/# secrets).
50
+
51
+ By default, your cluster will have 3 nodes of type ` n1-standard-1` . This is configurable, however; for instance
52
+ if we' d like to choose 5 nodes of type `n1-standard-2` instead, we can run these commands:
50
53
51
- ```bash
52
- $ pulumi config set clusterNodeCount 5
53
- $ pulumi config set clusterNodeMachineType n1-standard-2
54
- ```
54
+ ```bash
55
+ $ pulumi config set clusterNodeCount 5
56
+ $ pulumi config set clusterNodeMachineType n1-standard-2
57
+ ```
55
58
56
- This shows how stacks can be configurable in useful ways. You can even change these after provisioning.
59
+ This shows how stacks can be configurable in useful ways. You can even change these after provisioning.
57
60
58
61
3. Deploy everything with the `pulumi up` command. This provisions all the GCP resources necessary, including
59
62
your GKE cluster and database, as well as building and publishing your container image, all in a single gesture:
@@ -62,7 +65,7 @@ cluster and containerized Ruby on Rails application deployed into it, using a ho
62
65
$ pulumi up
63
66
```
64
67
65
- This will show you a preview, ask for confirmation, and then chug away at provisioning your cluster:
68
+ This will show you a preview, ask for confirmation, and then chug away at provisioning your cluster:
66
69
67
70
```
68
71
Updating stack ' gcp-rails'
@@ -101,9 +104,9 @@ cluster and containerized Ruby on Rails application deployed into it, using a ho
101
104
Update duration: 7m20.867501974as
102
105
```
103
106
104
- After this completes, numerous outputs will show up. `appAddress` is the URL that your Rails app will be available
105
- at, `appName` is the resulting Kubernetes Deployment, `dbAddress` is your PostgreSQL hostname in case you want to
106
- connect to it with `psql`, and `kueConfig` is the full Kubernetes configuration that you can use with `kubectl`.
107
+ After this completes, numerous outputs will show up. `appAddress` is the URL that your Rails app will be available
108
+ at, `appName` is the resulting Kubernetes Deployment, `dbAddress` is your PostgreSQL hostname in case you want to
109
+ connect to it with `psql`, and `kueConfig` is the full Kubernetes configuration that you can use with `kubectl`.
107
110
108
111
4. Open a browser to visit the site, `open $(pulumi stack output appAddress)/todo_lists`. Make some todo lists!
109
112
0 commit comments