Setup Database server#
1. Install mariadb or mysql#
1
| apt install mysql-server -y
|
1
| vim /etc/mysql/mysql.conf.d/mysqld.cnf => bind-address to 0.0.0.0
|
3. Create new user for wordpress#
1
2
3
| mysql -u root
CREATE USER 'wp-user'@'%' IDENTIFIED BY 'gladiators88'; GRANT ALL PRIVILEGES ON *.* TO 'wp-user'@'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'wp-user'@'%';
|
Setup bind9#
4. Install bind9#
5. Setup forward zone#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| nano /etc/bind/db.foo
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA ns.foo.id. root.foo.id. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns.foo.id.
@ IN A xx.xx.xx.xx
ns IN A xx.xx.xx.xx
dbwordpress IN A xx.xx.xx.xx
|
6. Setup reverse zone#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| nano /etc/bind/db.ip
;
; BIND reverse data file for local loopback interface
;
$TTL 604800
@ IN SOA foo.id. root.foo.id. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS foo.id.
xx IN PTR foo.id
xx IN PTR dbwordpress.foo.id.
|
7. Setup named.conf#
1
2
3
4
5
6
7
8
9
10
11
| nano /etc/bind/named.conf.local
zone "foo.id" IN {
type master;
file "/etc/bind/db.foo";
};
zone "xx.xx.xx.in-addr.arpa" IN {
type master;
file "/etc/bind/db.ip";
};
|
8. Restart mysql#
1
| systemctl restart mysql-server
|
Setup Wordpress on kubernetes#
9. Create manifest#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
| apiVersion: v1
kind: Service
metadata:
name: wordpress
labels:
app: wordpress
spec:
ports:
- port: 80
selector:
app: wordpress
tier: frontend
type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wp-pv-claim
labels:
app: wordpress
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: wordpress
labels:
app: wordpress
spec:
selector:
matchLabels:
app: wordpress
tier: frontend
strategy:
type: Recreate
template:
metadata:
labels:
app: wordpress
tier: frontend
spec:
containers:
- image: wordpress:4.8-apache
name: wordpress
env:
- name: WORDPRESS_DB_HOST
value: dbwordpress.foo.id
- name: WORDPRESS_DB_USER
value: wp-user
- name: WORDPRESS_DB_PASSWORD
value: gladiators88
ports:
- containerPort: 80
name: wordpress
ports:
- containerPort: 80
name: wordpress
volumeMounts:
- name: wordpress-persistent-storage
mountPath: /var/www/html
volumes:
- name: wordpress-persistent-storage
persistentVolumeClaim:
claimName: wp-pv-claim
|
1
| kubectl apply -f <file>
|
9. Create ingress#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: wp-ingress
labels:
app: wordpress
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: wp-foo.info
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: wordpress
port:
number: 80
|
Finnally just tunneling and access Wordpress by ingress host and enjoy :D