We’ll start off locally with minikube
then 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:
1 2 3 4 5 6 7 8 9 10 |
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
Note: if we’d forgotten to configure the secrets then we’d have seen:
1 2 3 |
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
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:
k get pods
1 2 3 |
NAME READY STATUS RESTARTS AGE wp-1-mariadb-0 0/1 CreateContainerConfigError 0 30m wp-1-wordpress-7bff96d46-4bss6 0/1 CrashLoopBackOff 8 30m |
1 2 |
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:
1 2 3 4 5 |
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 |