You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 1, 2024. It is now read-only.
Update Code Pattern to make it usable with new versions of Kubernetes (#58)
* Code pattern update
* Code pattern updated
* Code pattern updated
* Updated readme
build status added but need to be debugged
* Readme added and updated
Need to add build status
* Update README.md
* Update README.md
Co-authored-by: Fawaz Siddiqi <[email protected]>
*Read this in other languages: [한국어](README-ko.md) / [日本語](README-jp.md).*
4
-
5
1
# Scalable WordPress deployment on Kubernetes Cluster
6
2
7
3
This journey showcases the full power of Kubernetes clusters and shows how can we deploy the world's most popular website framework on top of world's most popular container orchestration platform. We provide a full roadmap for hosting WordPress on a Kubernetes Cluster. Each component runs in a separate container or group of containers.
@@ -17,8 +13,6 @@ In addition to deployment on Kubernetes, we will also show how you can scale the
@@ -33,25 +27,77 @@ This scenario provides instructions for the following tasks:
33
27
- Create and deploy the WordPress frontend with one or more pods.
34
28
- Create and deploy the MySQL database (either in a container or using IBM Cloud MySQL as backend).
35
29
36
-
## Deploy to IBM Cloud
37
-
If you want to deploy the WordPress directly to IBM Cloud, click on `Deploy to IBM Cloud` button below to create an IBM Cloud DevOps service toolchain and pipeline for deploying the WordPress sample, else jump to [Steps](##steps)
30
+
## Deply to IBM Cloud
31
+
32
+
If you want to deploy the WordPress directly to IBM Cloud, click on `Deploy to IBM Cloud` button below to create an IBM Cloud DevOps service toolchain and pipeline for deploying the WordPress sample, else jump to [steps](##Methods-to-Deploy)
33
+
34
+
[](https://cloud.ibm.com/devops/setup/deploy?repository=https://github.com/IBM/Scalable-WordPress-deployment-on-Kubernetes&branch=master)
35
+
36
+
# Methods to Deploy
37
+
38
+
-[Using The Kustomization File](#Using-The-Kustomization-File)
39
+
-[Manually deploying each file](#Manually-deploying-each-deployment)
40
+
-[Using Compose for MySQL as Backend](#Using-IBM-Cloud-Compose-for-MySQL-as-backend)
41
+
42
+
# Using The Kustomization File
43
+
44
+
`kustomize` lets you customize raw, template-free YAML
45
+
files for multiple purposes, leaving the original YAML
46
+
untouched and usable as is.
47
+
48
+
Create a new file called `password.txt` in the same directory and put your desired MySQL password inside `password.txt` (Could be any string with ASCII characters).
49
+
50
+
How does our `kustomization.yaml` file looks like:
51
+
52
+
```yaml
53
+
secretGenerator: #generates secrets within the cluster
54
+
- name: mysql-pass
55
+
files:
56
+
- password.txt
57
+
resources: #runs the .yaml files which are written below
[To read more about kustomization please click here](https://github.com/kubernetes-sigs/kustomize)
40
84
41
-
Please follow the [Toolchain instructions](https://github.com/IBM/container-journey-template/blob/master/Toolchain_Instructions_new.md) to complete your toolchain and pipeline.
85
+
Now please move on to [Accessing the External Link](#Accessing-the-external-wordpress-link).
42
86
43
-
## Steps
87
+
#### To remove the deployment
88
+
89
+
```bash
90
+
kubectl delete -k ./
91
+
```
92
+
93
+
# Manually deploying each deployment
44
94
1.[Setup MySQL Secrets](#1-setup-mysql-secrets)
45
95
2.[Create local persistent volumes](#2-create-local-persistent-volumes)
46
96
3.[Create Services and Deployments for WordPress and MySQL](#3-create-services-and-deployments-for-wordpress-and-mysql)
47
-
- 3.1 [Using MySQL in container](#31-using-mysql-in-container)
48
-
- 3.2 [Using IBM Cloud MySQL](#32-using-ibm-cloud-mysql-as-backend)
49
-
4.[Accessing the external WordPress link](#4-accessing-the-external-wordpress-link)
97
+
4.[Accessing the external WordPress link](#Accessing-the-external-wordpress-link)
50
98
5.[Using WordPress](#5-using-wordpress)
51
99
52
-
# 1. Setup MySQL Secrets
53
-
54
-
> *Quickstart option:* In this repository, run `bash scripts/quickstart.sh`.
100
+
### 1. Setup MySQL Secrets
55
101
56
102
Create a new file called `password.txt` in the same directory and put your desired MySQL password inside `password.txt` (Could be any string with ASCII characters).
57
103
@@ -62,7 +108,7 @@ We need to make sure `password.txt` does not have any trailing newline. Use the
To save your data beyond the lifecycle of a Kubernetes pod, you will want to create persistent volumes for your MySQL and Wordpress applications to attach to.
#### For paid IBM Cloud Kubernetes Service OR Minikube
74
120
Persistent volumes are created dynamically for you when the MySQL and Wordpress applications are deployed. No action is needed.
75
121
76
-
# 3. Create Services and deployments for WordPress and MySQL
77
-
78
-
### 3.1 Using MySQL in container
122
+
### 3. Create Services and deployments for WordPress and MySQL
79
123
80
-
> *Note:* If you want to use IBMCloud Compose-MySql as your backend, please go to [Using Bluemix MySQL as backend](#32-using-bluemix-mysql-as-backend).
124
+
> *Note:* If you want to use IBM Cloud Compose for MySql as your backend, please go to [Using IBM Cloud MySQL as backend](#Using-IBM-Cloud-MySQL-as-backend).
81
125
82
126
Install persistent volume on your cluster's local storage. Then, create the secret and services for MySQL and WordPress.
Now please move on to [Accessing the External Link](#4-accessing-the-external-wordpress-link).
149
+
Now please move on to [Accessing the External Link](#Accessing-the-external-wordpress-link).
106
150
107
-
### 3.2 Using IBM Cloud MySQL as backend
151
+
# Using IBM Cloud Compose for MySQL as backend
152
+
153
+
### Create Local Persistent Volumes
154
+
To save your data beyond the lifecycle of a Kubernetes pod, you will want to create persistent volumes for your Wordpress applications to attach to.
155
+
156
+
#### For "lite" IBM Cloud Kubernetes Service
157
+
Create the local persistent volumes manually by running
158
+
```bash
159
+
kubectl create -f local-volumes-compose.yaml
160
+
```
161
+
#### For paid IBM Cloud Kubernetes Service OR Minikube
162
+
Persistent volumes are created dynamically for you when the MySQL and Wordpress applications are deployed. No action is needed.
108
163
109
164
Provision Compose for MySQL in IBM Cloud via https://cloud.ibm.com/catalog/services/compose-for-mysql
110
165
111
-
Go to Service credentials and view your credentials. Your MySQL hostname, port, user, and password are under your credential uri and it should look like this
166
+
Go to Service credentials and view your credentials (or add one if you don't see one created already). Your MySQL hostname, port, user, and password are under your credential url and it should look like this
**Alternatively** you could also go to the manage tab and under "Connection Strings" you will be able to find the username, password, hostname as well as the port as shown below
112
174
113
-

175
+

114
176
115
-
Modify your `wordpress-deployment.yaml` file, change WORDPRESS_DB_HOST's value to your MySQL hostname and port (i.e. `value: <hostname>:<port>`), WORDPRESS_DB_USER's value to your MySQL user, and WORDPRESS_DB_PASSWORD's value to your MySQL password.
177
+
Go to your `wordpress-deployment-compose.yaml` file, change WORDPRESS_DB_HOST's value to your MySQL hostname and port (i.e. `value: <hostname>:<port>`), WORDPRESS_DB_USER's value to your MySQL user, and WORDPRESS_DB_PASSWORD's value to your MySQL password.
116
178
117
179
And the environment variables should look like this
118
180
119
181
```yaml
120
182
spec:
121
183
containers:
122
-
- image: wordpress:4.7.3-apache
123
-
name: wordpress
184
+
- image: wordpress:latest
185
+
name: wordpress-c
124
186
env:
125
187
- name: WORDPRESS_DB_HOST
126
-
value: sl-us-dal-9-portal.7.dblayer.com:22412
188
+
value: <<ENTER YOUR DB HOST>>:<<ENTER DB PORT>>
127
189
- name: WORDPRESS_DB_USER
128
-
value: admin
190
+
value: <<ENTER YOUR DB USERNAME>>
129
191
- name: WORDPRESS_DB_PASSWORD
130
-
value: XMRXTOXTDWOOPXEE
192
+
value: <<ENTER YOUR DB PASSWORD FROM COMPOSE>>
131
193
```
132
194
133
-
After you modified the `wordpress-deployment.yaml`, run the following commands to deploy WordPress.
195
+
196
+
After you modified the `wordpress-deployment-compose.yaml`, run the following commands to deploy WordPress.
0 commit comments