Deploy a WordPress app using Kubernetes on AWS

We’ll start off locally with minikubethen deploy to AWS.

Our guide will be https://github.com/kubernetes/examples/tree/master/mysql-wordpress-pd

Locally

git clone git@github.com:kubernetes/examples.git

Install kubectl:

brew install kubernetes-cli

https://kubernetes.io/docs/tasks/tools/install-kubectl/

 

Install minikube:

brew cask install minikube

https://github.com/kubernetes/minikube/releases

 

Install virtualbox

brew cask install virtualbox

 

minikube start

Any problems, use minikube delete.

https://github.com/kubernetes/minikube/issues/459

 

And here’s an Asciinema Asciicast of deploying WordPress on Kubernetes via minikube

The crucial commands:

kubectl create secret generic mysql-pass --from-literal=password=test
kubectl get secrets
kubectl create -f https://k8s.io/examples/application/wordpress/mysql-deployment.yaml
kubectl get pvc
kubectl get pods
kubectl create -f https://k8s.io/examples/application/wordpress/wordpress-deployment.yaml
kubectl get pvc

minikube service wordpress --url
curl -L <url>

Note if you’re using a namespace then you’ll need to do:

minikube service -n <your namespace> wordpress --url

https://stackoverflow.com/questions/53283657/kubernetes-could-not-find-finalized-endpoint-being-pointed-to-error-validating/53283783#53283783

 

Note: if we’d forgotten to configure the secrets then we’d have seen:

kubectl get pods
NAME                              READY   STATUS                       RESTARTS   AGE
wordpress-mysql-bcc89f687-hs677   0/1     CreateContainerConfigError   0          4m

which we’d need to debug further with:

kubectl describe pods wordpress-mysql

and at the end you’d see (under Events:

Warning Failed 8s (x10 over 104s) kubelet, minikube Error: secrets "mysql-pass" not found

 

How to decode secrets

 

To list deployments use:

kubectl get deployment

or, for a specific deployment:

kubectl get deployment <your dep>

https://kubernetes.io/docs/reference/kubectl/cheatsheet/

 

See also: https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/#deploy-wordpress

Production-ready (also local)

Use Helm.

brew install kubernetes-helm

helm init

(otherwise you’ll get `Error: could not find tiller`)

helm install stable/wordpress

 

Check on progress with:

kubectl get pods

 

Issues:

https://stackoverflow.com/questions/53286172/error-from-server-badrequest-container-mariadb-in-pod-is-waiting-to-start

k get pods

NAME                             READY   STATUS                       RESTARTS   AGE
wp-1-mariadb-0                   0/1     CreateContainerConfigError   0          30m
wp-1-wordpress-7bff96d46-4bss6   0/1     CrashLoopBackOff             8          30m
k logs wp-1-mariadb-0
Error from server (BadRequest): container "mariadb" in pod "wp-1-mariadb-0" is waiting to start: CreateContainerConfigError

Debugging:

k describe pods wp-1-mariadb-0

revealed:

Events:
  Type     Reason  Age                    From               Message
  ----     ------  ----                   ----               -------
  Warning  Failed  15m (x320 over 3h48m)  kubelet, minikube  Error: failed to prepare subPath for volumeMount "config" of container "mariadb"
  Normal   Pulled  64s (x389 over 3h48m)  kubelet, minikube  Container image "docker.io/bitnami/mariadb:10.1.36-debian-9" already present on machine

 

Leave a Reply

Your email address will not be published. Required fields are marked *