forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move both guestbook variants under a common directory
- Loading branch information
Showing
14 changed files
with
88 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,17 @@ | ||
# Kubernetes Guestbook | ||
# Kubernetes Guestbook (Two Ways) | ||
|
||
A version of the [Kubernetes Guestbook](https://kubernetes.io/docs/tutorials/stateless-application/guestbook/) | ||
application using Pulumi. | ||
A port of the standard [Kubernetes Guestbook](https://kubernetes.io/docs/tutorials/stateless-application/guestbook/) | ||
to Pulumi. This example shows you how to build and deploy a simple, multi-tier web application using Kubernetes and | ||
Docker, and consists of three components: | ||
|
||
This is a straight port of the original YAML, and doesn't highlight advantages of using real languages. For an example | ||
using abstraction to cut down on boilerplate, please see the [easy Guestbook variant](../kubernetes-ts-guestbook-easy), | ||
also in this repo. It provisions the same set of resources. | ||
* A single-instance Redis master to store guestbook entries | ||
* Multiple replicated Redis instances to serve reads | ||
* Multiple web frontend instances | ||
|
||
## Running the App | ||
In this directory, you will find two variants of the Guestbook: | ||
|
||
Follow the steps in [Pulumi Installation and Setup](https://pulumi.io/install/) and [Configuring Pulumi | ||
Kubernetes](https://pulumi.io/reference/kubernetes.html#configuration) to get setup with Pulumi and Kubernetes. | ||
1. [simple/](./simple) is a straight port of the original YAML. | ||
2. [components](./components) demonstrates benefits of using a real language, namely eliminating boilerplate through | ||
the use of real component abstractions. | ||
|
||
Install dependencies: | ||
|
||
```sh | ||
npm install | ||
``` | ||
|
||
Create a new stack: | ||
|
||
```sh | ||
$ pulumi stack init | ||
Enter a stack name: testbook | ||
``` | ||
|
||
This example will attempt to expose the Guestbook application to the Internet with a `Service` of | ||
type `LoadBalancer`. Since minikube does not support `LoadBalancer`, the Guestbook application | ||
already knows to use type `ClusterIP` instead; all you need to do is to tell it whether you're | ||
deploying to minikube: | ||
|
||
```sh | ||
pulumi config set guestbook:isMinikube <value> | ||
``` | ||
|
||
Perform the deployment: | ||
|
||
```sh | ||
$ pulumi up | ||
Updating stack 'testbook' | ||
Performing changes: | ||
|
||
Type Name Status Info | ||
+ pulumi:pulumi:Stack guestbook-testbook created | ||
+ ├─ kubernetes:apps:Deployment redis-master created | ||
+ ├─ kubernetes:apps:Deployment frontend created | ||
+ ├─ kubernetes:apps:Deployment redis-slave created | ||
+ ├─ kubernetes:core:Service redis-master created 1 info message | ||
+ ├─ kubernetes:core:Service redis-slave created 1 info message | ||
+ └─ kubernetes:core:Service frontend created 2 info messages | ||
|
||
---outputs:--- | ||
frontendIp: "35.232.147.18" | ||
|
||
info: 7 changes performed: | ||
+ 7 resources created | ||
Update duration: 40.829381902s | ||
|
||
Permalink: https://app.pulumi.com/hausdorff/testbook/updates/1 | ||
``` | ||
|
||
And finally - open the application in your browser to see the running application. If you're running | ||
macOS you can simply run: | ||
|
||
```sh | ||
open $(pulumi stack output frontendIp) | ||
``` | ||
|
||
> *Note*: minikube does not support type `LoadBalancer`; if you are deploying to minikube, make sure | ||
> to run `kubectl port-forward svc/frontend 8080:80` to forward the cluster port to the local | ||
> machine and access the service via `localhost:8080`. | ||
![Guestbook in browser](./imgs/guestbook.png) | ||
Both examples provision the exact same Kubernetes Guestbook application, but showcase different aspects of Pulumi. |
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
kubernetes-ts-guestbook-easy/README.md → kubernetes-ts-guestbook/components/README.md
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
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,74 @@ | ||
# Kubernetes Guestbook (Simple Variant) | ||
|
||
A version of the [Kubernetes Guestbook](https://kubernetes.io/docs/tutorials/stateless-application/guestbook/) | ||
application using Pulumi. | ||
|
||
This is a straight port of the original YAML, and doesn't highlight advantages of using real languages. For an example | ||
using abstraction to cut down on boilerplate, please see the [variant using components](../components), | ||
also in this repo. It provisions the same set of resources. | ||
|
||
## Running the App | ||
|
||
Follow the steps in [Pulumi Installation and Setup](https://pulumi.io/install/) and [Configuring Pulumi | ||
Kubernetes](https://pulumi.io/reference/kubernetes.html#configuration) to get setup with Pulumi and Kubernetes. | ||
|
||
Install dependencies: | ||
|
||
```sh | ||
npm install | ||
``` | ||
|
||
Create a new stack: | ||
|
||
```sh | ||
$ pulumi stack init | ||
Enter a stack name: testbook | ||
``` | ||
|
||
This example will attempt to expose the Guestbook application to the Internet with a `Service` of | ||
type `LoadBalancer`. Since minikube does not support `LoadBalancer`, the Guestbook application | ||
already knows to use type `ClusterIP` instead; all you need to do is to tell it whether you're | ||
deploying to minikube: | ||
|
||
```sh | ||
pulumi config set guestbook:isMinikube <value> | ||
``` | ||
|
||
Perform the deployment: | ||
|
||
```sh | ||
$ pulumi up | ||
Updating stack 'testbook' | ||
Performing changes: | ||
|
||
Type Name Status Info | ||
+ pulumi:pulumi:Stack guestbook-testbook created | ||
+ ├─ kubernetes:apps:Deployment redis-master created | ||
+ ├─ kubernetes:apps:Deployment frontend created | ||
+ ├─ kubernetes:apps:Deployment redis-slave created | ||
+ ├─ kubernetes:core:Service redis-master created 1 info message | ||
+ ├─ kubernetes:core:Service redis-slave created 1 info message | ||
+ └─ kubernetes:core:Service frontend created 2 info messages | ||
|
||
---outputs:--- | ||
frontendIp: "35.232.147.18" | ||
|
||
info: 7 changes performed: | ||
+ 7 resources created | ||
Update duration: 40.829381902s | ||
|
||
Permalink: https://app.pulumi.com/hausdorff/testbook/updates/1 | ||
``` | ||
|
||
And finally - open the application in your browser to see the running application. If you're running | ||
macOS you can simply run: | ||
|
||
```sh | ||
open $(pulumi stack output frontendIp) | ||
``` | ||
|
||
> *Note*: minikube does not support type `LoadBalancer`; if you are deploying to minikube, make sure | ||
> to run `kubectl port-forward svc/frontend 8080:80` to forward the cluster port to the local | ||
> machine and access the service via `localhost:8080`. | ||
![Guestbook in browser](./imgs/guestbook.png) |
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.