Skip to content

Commit

Permalink
Add README to kubernetes-ts-guestbook (pulumi#36)
Browse files Browse the repository at this point in the history
Also remove kubernetes-ts-webserver (concepts covered by kubernetes-py-nginx and kubernetes-ts-guestbook) and aws-ts-fortune (concepts covered by aws-ts-serverless-raw).

Cleanup .gitignores a bit.
  • Loading branch information
lukehoban committed Apr 14, 2018
1 parent c8c95a7 commit a74c983
Show file tree
Hide file tree
Showing 28 changed files with 124 additions and 268 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.pulumi/
node_modules/
Pulumi.*.yaml
bin/
yarn.lock
package-lock.json
*.pyc
Pulumi.*.yaml
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This example is available in multiple flavors:
* [AWS EC2 instance in JavaScript](aws-js-webserver)
* [AWS EC2 instance in Python](aws-py-webserver)
* [Azure Virtual Machine in JavaScript](azure-js-webserver)
* [Kubernetes Nginx in TypeScript](kubernetes-ts-webserver)
* [Kubernetes Nginx in Python](kubernetes-py-nginx)

An [extension of this example](aws-js-webserver-component/) demonstrates creating a minimal component that encapsulates
creating EC2 instances, highlighting one of the benefits of using general purpose languages for managing infrastructure.
Expand Down Expand Up @@ -50,3 +50,9 @@ to accomplish all of the same things this higher-level package offers.

The deployed Lambda function is a simple C# application, highlighting the ability to manage existing application code
in a Pulumi application, even if your Pulumi code is written in a different language like JavaScript or Python.

### [Kubernetes Guestbook](kubernetes-ts-guestbook/)

This examples shows a version of the [Kubernetes
Guestbook](https://kubernetes.io/docs/tutorials/stateless-application/guestbook/) app using Pulumi and
`@pulumi/kubernetes`.
5 changes: 0 additions & 5 deletions aws-js-webserver-component/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions aws-js-webserver/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions aws-py-webserver/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions aws-ts-fortune/Pulumi.yaml

This file was deleted.

44 changes: 0 additions & 44 deletions aws-ts-fortune/index.ts

This file was deleted.

20 changes: 0 additions & 20 deletions aws-ts-fortune/package.json

This file was deleted.

11 changes: 0 additions & 11 deletions aws-ts-fortune/tsconfig.json

This file was deleted.

7 changes: 0 additions & 7 deletions aws-ts-serverless-raw/.gitignore

This file was deleted.

2 changes: 2 additions & 0 deletions aws-ts-serverless-raw/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/**/obj
/**/bin
6 changes: 0 additions & 6 deletions aws-ts-webserver-zones/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions azure-js-webserver/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions cloud-js-thumbnailer/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions cloud-ts-url-shortener-cache/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions cloud-ts-url-shortener/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions cloud-ts-voting-app/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions kubernetes-ts-guestbook/.gitignore

This file was deleted.

105 changes: 105 additions & 0 deletions kubernetes-ts-guestbook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Kubernetes Guestbook

A version of the [Kubernetes Guestbook](https://kubernetes.io/docs/tutorials/stateless-application/guestbook/) app using
Pulumi and `@pulumi/kubernetes`.

## Running the App

Follow the steps in [Pulumi Installation and Setup](https://docs.pulumi.com/install/) and [Configuring Pulumi
Kubernetes](https://docs.pulumi.com/reference/kubernetes.html#configuration) to get setup with Pulumi and Kubernetes.

> NOTE: For this walkthrough, we'll assume you are deploying to a cluster that supports the
[`LoadBalancer`](https://kubernetes.io/docs/concepts/services-networking/service/#type-loadbalancer) service type. This
includes most cloud providers as well as [Docker for Mac Edge w/
Kubernetes](https://docs.docker.com/docker-for-mac/kubernetes/). If not (for example if you are targeting `minikube`),
you may need to replace `type: "LoadBalancer"` with another option for exposing the service in `index.ts`. See the
Kubernetes [Services
docs](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types) for more
details.

Create a new stack:

```
$ pulumi stack init
Enter a stack name: testing
```

Preview the deployment of the application:

```
$ pulumi preview
Previewing stack 'testing' in the Pulumi Cloud ☁️
Previewing changes:
pulumi:Stack("guestbook-testing"): Completed
kubernetes:Service("frontend"): + Would create
kubernetes:Service("redis-slave"): + Would create
kubernetes:Service("redis-master"): + Would create
kubernetes:Deployment("redis-master"): + Would create
kubernetes:Deployment("frontend"): + Would create
kubernetes:Deployment("redis-slave"): + Would create
info: 7 changes previewed:
+ 7 resources to create
```

Perform the deployment:

```
$ pulumi update
Updating stack 'testing' in the Pulumi Cloud ☁️
Performing changes:
pulumi:Stack("guestbook-testing"): Completed
kubernetes:Service("frontend"): + Created
kubernetes:Service("redis-slave"): + Created
kubernetes:Service("redis-master"): + Created
kubernetes:Deployment("redis-master"): + Created
kubernetes:Deployment("frontend"): + Created
kubernetes:Deployment("redis-slave"): + Created
info: 7 changes performed:
+ 7 resources created
Update duration: 3.535908863s
Permalink: https://pulumi.com/pulumi/examples/guestbook/testing/updates/1
```

The application is now deployed. Use `kubectl` to see the deployed services.

```
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
frontend LoadBalancer 10.98.65.192 localhost 80:30235/TCP 51m
redis-master ClusterIP 10.99.238.82 <none> 6379/TCP 51m
redis-slave ClusterIP 10.111.117.113 <none> 6379/TCP 51m
```

And finally - `curl` the exposed `frontend` service (or open in a broswer) to see the running application.

```
$ curl localhost:80
<html ng-app="redis">
<head>
<title>Guestbook</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.min.js"></script>
<script src="controllers.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.13.0/ui-bootstrap-tpls.js"></script>
</head>
<body ng-controller="RedisCtrl">
<div style="width: 50%; margin-left: 20px">
<h2>Guestbook</h2>
<form>
<fieldset>
<input ng-model="msg" placeholder="Messages" class="form-control" type="text" name="input"><br>
<button type="button" class="btn btn-primary" ng-click="controller.onRedis()">Submit</button>
</fieldset>
</form>
<div>
<div ng-repeat="msg in messages track by $index">
{{msg}}
</div>
</div>
</div>
</body>
</html>
```
6 changes: 3 additions & 3 deletions kubernetes-ts-guestbook/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ let frontendService = new kubernetes.Service("frontend", {
labels: [frontendLabels],
},
spec: {
// If your cluster supports it, uncomment the following to automatically create
// an external load-balanced IP for the frontend service.
// type: LoadBalancer
// If your cluster does not support `LoadBalancer` (such as on minikube), comment out the it, uncomment the
// following to automatically create an external load-balanced IP for the frontend service.
type: "LoadBalancer",
ports: [{ port: 80 }],
selector: [frontendLabels],
},
Expand Down
6 changes: 3 additions & 3 deletions kubernetes-ts-guestbook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"@types/node": "^9.3.0",
"typescript": "^2.5.3"
},
"peerDependencies": {
"@pulumi/kubernetes": "latest",
"@pulumi/pulumi": "^0.11.0-dev-65-g7aedf80f"
"dependencies": {
"@pulumi/kubernetes": "^0.11.3-rc1",
"@pulumi/pulumi": "^0.11.3-rc2"
},
"license": "MIT"
}
11 changes: 0 additions & 11 deletions kubernetes-ts-guestbook/yarn.lock

This file was deleted.

2 changes: 0 additions & 2 deletions kubernetes-ts-webserver/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions kubernetes-ts-webserver/Pulumi.yaml

This file was deleted.

63 changes: 0 additions & 63 deletions kubernetes-ts-webserver/index.ts

This file was deleted.

Loading

0 comments on commit a74c983

Please sign in to comment.