Skip to content

Commit c2571f4

Browse files
authored
Update ts-helm-wordpress example (pulumi#803)
1 parent 4650ca2 commit c2571f4

File tree

2 files changed

+92
-66
lines changed

2 files changed

+92
-66
lines changed

kubernetes-ts-helm-wordpress/README.md

+79-51
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,16 @@
22

33
# Wordpress Helm Chart
44

5-
Uses the Helm API of `@pulumi/kubernetes` to deploy `v2.1.3` of the Wordpress Helm Chart to a
6-
Kubernetes cluster. **The Tiller server is not required to be installed.** Pulumi will expand the
7-
Helm Chart and submit the expanded YAML to the cluster.
8-
9-
> **NOTE:** Because Tiller is not used, it is important to be aware that a small number of Charts
10-
> depend on values that can only be expanded on the server. These variables will get default values
11-
> instead.
12-
13-
> **NOTE:** This example has a dependency on the `helm` CLI. **Be sure to install that first!** See
14-
> instructions below.
5+
Uses the Helm API of `@pulumi/kubernetes` to deploy `v9.6.0` of the Wordpress Helm Chart to a
6+
Kubernetes cluster. Pulumi will expand the Helm Chart and submit the expanded YAML to the cluster.
157

168
![wordpress](images/deploy.gif "Wordpress Helm Chart deployment")
179

1810
## Running the App
1911

20-
Use the [Helm installation guide](https://helm.sh/docs/intro/install/) to install the
21-
`helm` CLI. On macOS this might look something like:
22-
23-
```sh
24-
brew install helm
25-
```
26-
2712
If you haven't already, follow the steps in [Pulumi Installation and
2813
Setup](https://www.pulumi.com/docs/get-started/install/) and [Configuring Pulumi
29-
Kubernetes](https://www.pulumi.com/docs/intro/cloud-providers/kubernetes/setup/) to get setup with
14+
Kubernetes](https://www.pulumi.com/docs/intro/cloud-providers/kubernetes/setup/) to get set up with
3015
Pulumi and Kubernetes.
3116

3217
Now, install dependencies:
@@ -42,41 +27,53 @@ $ pulumi stack init
4227
Enter a stack name: wordpress-dev
4328
```
4429

45-
Preview the deployment of the application.
46-
47-
> **TIP:** This example installs the Wordpress Chart. You can use `helm search` to find other Helm
48-
> charts, as well as available versions for them.
49-
50-
Perform the deployment:
30+
Preview the deployment of the application and the perform the deployment:
5131

5232
```sh
53-
$ pulumi up
54-
Updating stack 'wordpress-dev'
55-
Performing changes:
56-
57-
Type Name Status Info
58-
+ pulumi:pulumi:Stack wordpress-wordpress-dev created 1 warning
59-
+ └─ kubernetes:helm.sh:Chart wpdev created
60-
+ ├─ kubernetes:core:ConfigMap wpdev-mariadb created
61-
+ ├─ kubernetes:core:ConfigMap wpdev-mariadb-tests created
62-
+ ├─ kubernetes:core:Secret wpdev-mariadb created
63-
+ ├─ kubernetes:core:Secret wpdev-wordpress created
64-
+ ├─ kubernetes:core:Service wpdev-wordpress created 1 warning, 2 info messages
65-
+ ├─ kubernetes:core:Service wpdev-mariadb created 1 warning, 1 info message
66-
+ ├─ kubernetes:core:Pod wpdev-credentials-test created 17 warnings
67-
+ ├─ kubernetes:core:Pod wpdev-mariadb-test-mgjjy created 32 warnings
68-
+ ├─ kubernetes:core:PersistentVolumeClaim wpdev-wordpress created
69-
+ ├─ kubernetes:apps:StatefulSet wpdev-mariadb created
70-
+ └─ kubernetes:extensions:Deployment wpdev-wordpress created
71-
72-
---outputs:---
73-
frontendIp: "35.193.210.254"
74-
75-
info: 13 changes performed:
76-
+ 13 resources created
77-
Update duration: 1m28.601219022s
78-
79-
Permalink: https://app.pulumi.com/hausdorff/wordpress-dev/updates/1
33+
pulumi up
34+
Previewing update (ts-helm-wordpress)
35+
36+
View Live: https://app.pulumi.com/example/wordpress/ts-helm-wordpress/previews/cc683bd2-1e19-49c9-8a88-792c44e3b020
37+
38+
Type Name Plan
39+
+ pulumi:pulumi:Stack wordpress-ts-helm-wordpress create
40+
+ └─ kubernetes:helm.sh:Chart wpdev create
41+
+ ├─ kubernetes:core:Secret default/wpdev-mariadb create
42+
+ ├─ kubernetes:core:Secret wpdev-wordpress create
43+
+ ├─ kubernetes:core:Service default/wpdev-mariadb create
44+
+ ├─ kubernetes:core:Service wpdev-wordpress create
45+
+ ├─ kubernetes:core:ConfigMap default/wpdev-mariadb create
46+
+ ├─ kubernetes:core:PersistentVolumeClaim wpdev-wordpress create
47+
+ ├─ kubernetes:apps:StatefulSet default/wpdev-mariadb create
48+
+ └─ kubernetes:apps:Deployment wpdev-wordpress create
49+
50+
Resources:
51+
+ 10 to create
52+
53+
Do you want to perform this update? yes
54+
Updating (ts-helm-wordpress)
55+
56+
View Live: https://app.pulumi.com/example/wordpress/ts-helm-wordpress/updates/7
57+
58+
Type Name Status
59+
+ pulumi:pulumi:Stack wordpress-ts-helm-wordpress created
60+
+ └─ kubernetes:helm.sh:Chart wpdev created
61+
+ ├─ kubernetes:core:Secret default/wpdev-mariadb created
62+
+ ├─ kubernetes:core:Secret wpdev-wordpress created
63+
+ ├─ kubernetes:core:PersistentVolumeClaim wpdev-wordpress created
64+
+ ├─ kubernetes:core:Service wpdev-wordpress created
65+
+ ├─ kubernetes:core:ConfigMap default/wpdev-mariadb created
66+
+ ├─ kubernetes:core:Service default/wpdev-mariadb created
67+
+ ├─ kubernetes:apps:StatefulSet default/wpdev-mariadb created
68+
+ └─ kubernetes:apps:Deployment wpdev-wordpress created
69+
70+
Outputs:
71+
frontendIp: "35.193.210.254"
72+
73+
Resources:
74+
+ 10 created
75+
76+
Duration: 53s
8077
```
8178

8279
We can see here in the `---outputs:---` section that Wordpress was allocated a public IP, in this
@@ -87,3 +84,34 @@ and `grep` to retrieve the `<title>` of the site the proxy points at.
8784
$ curl -sL $(pulumi stack output frontendIp):80 | grep "<title>"
8885
<title>User&#039;s Blog! &#8211; Just another WordPress site</title>
8986
```
87+
88+
You can also navigate to the site in a web browser.
89+
90+
When you're done, you can remove these resources with `pulumi destroy`:
91+
92+
```sh
93+
pulumi destroy --skip-preview
94+
Destroying (ts-helm-wordpress)
95+
96+
View Live: https://app.pulumi.com/example/wordpress/ts-helm-wordpress/updates/8
97+
98+
Type Name Status
99+
- pulumi:pulumi:Stack wordpress-ts-helm-wordpress deleted
100+
- └─ kubernetes:helm.sh:Chart wpdev deleted
101+
- ├─ kubernetes:core:Secret wpdev-wordpress deleted
102+
- ├─ kubernetes:core:Secret default/wpdev-mariadb deleted
103+
- ├─ kubernetes:core:ConfigMap default/wpdev-mariadb deleted
104+
- ├─ kubernetes:core:Service default/wpdev-mariadb deleted
105+
- ├─ kubernetes:core:PersistentVolumeClaim wpdev-wordpress deleted
106+
- ├─ kubernetes:core:Service wpdev-wordpress deleted
107+
- ├─ kubernetes:apps:StatefulSet default/wpdev-mariadb deleted
108+
- └─ kubernetes:apps:Deployment wpdev-wordpress deleted
109+
110+
Outputs:
111+
- frontendIp: "35.193.210.254"
112+
113+
Resources:
114+
- 10 deleted
115+
116+
Duration: 7s
117+
```

kubernetes-ts-helm-wordpress/index.ts

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
1+
// Copyright 2016-2020, Pulumi Corporation. All rights reserved.
22

33
import * as k8s from "@pulumi/kubernetes";
4-
import * as pulumi from "@pulumi/pulumi";
54

6-
// Minikube does not implement services of type `LoadBalancer`; require the user to specify if we're
7-
// running on minikube, and if so, create only services of type ClusterIP.
8-
const config = new pulumi.Config();
9-
if (config.require("isMinikube") === "true") {
10-
throw new Error("This example does not yet support minikube");
11-
}
12-
13-
// Deploy the latest version of the stable/wordpress chart.
14-
const wordpress = new k8s.helm.v2.Chart("wpdev", {
15-
repo: "stable",
16-
version: "2.1.3",
5+
// Deploy the bitnami/wordpress chart.
6+
const wordpress = new k8s.helm.v3.Chart("wpdev", {
7+
version: "9.6.0",
178
chart: "wordpress",
9+
fetchOpts: {
10+
repo: "https://charts.bitnami.com/bitnami"
11+
}
1812
});
1913

20-
// Export the public IP for Wordpress.
14+
// Get the status field from the wordpress service, and then grab a reference to the ingress field.
2115
const frontend = wordpress.getResourceProperty("v1/Service", "wpdev-wordpress", "status");
22-
export const frontendIp = frontend.apply(status => status.loadBalancer.ingress[0].ip);
16+
const ingress = frontend.loadBalancer.ingress[0];
17+
18+
// Export the public IP for Wordpress.
19+
// Depending on the k8s cluster, this value may be an IP address or a hostname.
20+
export const frontendIp = ingress.apply(x => x.ip ?? x.hostname);

0 commit comments

Comments
 (0)