WordPress on Kubernetes in Ubuntu

WordPress on Kubernetes in Ubuntu

based on:


1) Install snapd

sudo apt update 
sudo apt install snapd

2) Install helm

sudo snap install helm --classic

3) Install and enable Docker

sudo apt install docker.io
sudo systemctl enable docker

4) Add the Kubernetes signing key on both the nodes

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add

5) Add Xenial Kubernetes Repository

sudo apt-get install software-properties-common
sudo apt-get update
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"

6) Install Kubeadm

sudo apt install kubeadm

7) Disable swap memory – Kubernetes does not perform properly on a system that is using

swap memory
sudo swapoff -a

8) Set hostname

sudo hostnamectl set-hostname master-node

9) Initialize Kubernetes on the master node

sudo kubeadm init --pod-network-cidr=

10) To start using your cluster, you need to run the following as a regular user:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

11) Then you can join any number of worker nodes by running the following on each as root:

kubeadm join --token 3fblch.ja2qp2uymppvd92n --discovery-token-ca-cert-hash sha256:77bef2579a7c22a3b8a55f94f70595f35112b406ac12a04f67e7a73e1a50e62b

12) Deploy a Pod Network through the master node

sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

13) view the status of the network

kubectl get pods --all-namespaces

14) Install Bitnami WordPress (a help chart)

helm install my-blog bitnami/wordpress

15) Result

NAME: my-blog
LAST DEPLOYED: Mon Apr 27 18:35:23 2020
NAMESPACE: default
STATUS: deployed
** Please be patient while the chart is being deployed **

To access your WordPress site from outside the cluster follow the steps below:

  1. Get the WordPress URL by running these commands: NOTE: It may take a few minutes for the LoadBalancer IP to be available.
    Watch the status with: ‘kubectl get svc –namespace default -w my-blog-wordpress’ export SERVICE_IP=$(kubectl get svc –namespace default my-blog-wordpress –template “{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}”)
    echo “WordPress URL: http://$SERVICE_IP/”
    echo “WordPress Admin URL: http://$SERVICE_IP/admin”
  2. Open a browser and access WordPress using the obtained URL.
  3. Login with the following credentials below to see your blog: echo Username: user
    echo Password: $(kubectl get secret –namespace default my-blog-wordpress -o jsonpath=”{.data.wordpress-password}” | base64 –decode)

16) Uninstall

helm delete my-blog

Leave a Reply