Skip to content

Commit 5b4979f

Browse files
authored
GCP-TS-K8s-Ruby - Fix Import/DockerFile and Readme Updates (pulumi#500)
GCP-TS-K8s-Ruby - Fix Import/DockerFile and Readme Updates
2 parents ba6a4d9 + 036c5e0 commit 5b4979f

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

gcp-ts-k8s-ruby-on-rails-postgresql/README.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
This example is a full end to end example of delivering a containerized Ruby on Rails application. It
66

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
1111

1212
All of these happen behind a single `pulumi up` command, and are expressed in just a handful of TypeScript.
1313

1414
## Prerequisites
1515

1616
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/)
1818
We will be deploying to Google Cloud Platform (GCP), so you will need an account. If you don't have an account,
1919
[sign up for free here](https://cloud.google.com/free/). In either case,
2020
[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
3838
```bash
3939
$ pulumi config set gcp:project [your-gcp-project-here]
4040
$ 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]
4243
$ pulumi config set dbPassword --secret [your-new-db-password-here]
4344
$ pulumi config set dockerUsername [your-dockerhub-username-here]
4445
$ 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
4647
```
4748

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:
5053
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+
```
5558
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.
5760
5861
3. Deploy everything with the `pulumi up` command. This provisions all the GCP resources necessary, including
5962
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
6265
$ pulumi up
6366
```
6467
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:
6669
6770
```
6871
Updating stack 'gcp-rails'
@@ -101,9 +104,9 @@ cluster and containerized Ruby on Rails application deployed into it, using a ho
101104
Update duration: 7m20.867501974as
102105
```
103106
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`.
107110
108111
4. Open a browser to visit the site, `open $(pulumi stack output appAddress)/todo_lists`. Make some todo lists!
109112

gcp-ts-k8s-ruby-on-rails-postgresql/app/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ruby:2.5
1+
FROM ruby:2.5.1
22
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
33
RUN mkdir /myapp
44
WORKDIR /myapp

gcp-ts-k8s-ruby-on-rails-postgresql/infra/cluster.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import * as gcp from "@pulumi/gcp";
44
import * as k8s from "@pulumi/kubernetes";
55
import * as pulumi from "@pulumi/pulumi";
6-
import { clusterNodeCount, clusterNodeMachineType, clusterPassword, clusterUsername } from "./config";
6+
import { clusterNodeCount, clusterNodeMachineType, clusterPassword, clusterUsername, masterVersion } from "./config";
77

88
// Create the GKE cluster and export it.
99
export const cluster = new gcp.container.Cluster("gke-cluster", {

0 commit comments

Comments
 (0)