Setup MySQL with Wordpress in k8s - Easy migrate or not !!
HELLO, LONG TIME NO SEE I JUST BRING BACK AFTER THE BREAK STRUGGLE ISSUE ON IMPLEMENTATION AND PROVISIONING AND ALSO I JUST FINISHING THE FLAT OF CAPSTONE PROJECT FOR SCALING PROJECT. SO I JUST WRITE A BLOG FOR GIVE EXPERIENCE, TAKE A BREAK AFTER ISSUE I MET ON ALONG LAST WEEK. TERRIBLE AND STRESSFUL
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
So i just want a talk it hard or not maybe base on your mindset. LOL and look below for meet some mistake when i met on provision progress
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
. Stay avoid it and don't make struggle mistake like me
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
The mindset on project:
- Migrate the on-prem wordpress to k8s wordpress, this is not to hard but also it will make you have some confuse and not understand when setup the another tools in K8s
- With wordpress, it always have legacy db - MySQL intergration with itself. So not only wordpress, we need to move mysql and datainside go to the k8s.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Step by step of progress when migrate and why i have struggle with that.
Setup the wordpress and mysql with k8s.
- So by the way working with k8s, you can deployed with raw YAML file or working it with terraform - both of them will work and use for specify situation
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- On my situation it just use compress between raw YAML and Terraform. So you can understand is Terraform will have to access k8s with credentials and run YAML file inside. That all
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
and go to detail that.
- First of all you need to configure driver for your k8s - Because on my situation, i work on k8s managed Azure is AKS. So i need to install driver for using the external object of Azure in AKS, especially about Storage things.
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
This is preparing for create PVC for mounting data of MySQL On-Prem into MySQL K8s. And struggle is currently starting
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
. So before that you just use az-cli or az powershell (Tools of Azure) for enable driver for you cluster. Step for do it
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
if it not enable, you can use this to update
NOTICE: This Process will take a couple minutes, so don't worry just wait to see the result blob drive is enabled !
- So for optimize the time for create blob with
script
, you can go directly to Azure portal
and create that on Storage Account
which you want
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
On situation it will ask you optional about Anonymous access level
of blob but for securing i choose private
NOTICE: Do not put anything this kind into the blob right know. Because it will cause failure when MySQL runs. Remmember about that (This is my mistake)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- So go for Terraform and YAML file to create wordpress and MySQL, this is the nightmare is started LOL. But don't worry i will note about that. Go detail for the script. I just put the main.tf but as you Terraform. Go check my Terraform blog
With the script i put it inhere, the step about that will go from
- Go to create the password with random func of Terraform
- K8s will work with data-mounting by many storage, which type can help you mounting way for helping you configure Pods or workload of K8s-things via Secret and ConfigMap (As you know you know
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
). So with dangerous information about the password and credential you need priority to choice secret. So second block terraform, Is create secret with random password
- So go to stupid things when use configure Azure, it will not clearly to you for choice with exactly optional for create Storage Class and PVC on it
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
(So in my opinion, Actually Microsoft create this thing to confuse)
On this step you need to add more thing create what storage class what you want and it will is it but Remember: Driver need to enable.
This is hard to mount_options and understand what situation for doing that. I just said some thing about information, it just shortly in side this blog and blob CSI repo for example. So you need to find exactly repo to understand theory and why they use that kind paramter and what tech is used inside. The technologies behind is blobfuse
and blobfuse 2
(some optional but this is popular)
Go for that you will need create PVC for them and PVC for them is need you to set again mount optional (Too bad for duplicate them but fact, it will not work if you don't because when you go to inside pod it will run with MySQL user but with BlobFuse it need root. Hard thing to understand if you do wrong and so focus to doing that to bypass this before the pod MySQL can go)

The curious thing will not stop in here, when you running MySQL pod in non't optional on MySQL when use BlobFuse PVC - IDK why the heck is Storage Mounting will create before the MySQL Running (Error cause in here and crashloopback container) - On Docker it not happening (Too Bad
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
). So that why you need to more config this kind "--defaults-file=/mysql/conf/my.cnf" "--ignore-db-dir=lost+found"
on config PARAM MYSQL for bypass this error when running that one with blob storage in K8s. The new my.cnf is
So go to running that with terraform
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
and see the result. Hope you can work perfectly like i said
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Notice: Easily with Docker LOL, do remember set optional for both of SC and PVC for bypass the non root work with blobfuse inside and one more thing blobfuse will be change the file to state ??? when you run ls -la for file in folder. But it oke, On container you can't erase but storage blob you can use
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Need to rechange config for running this pods and everything will be okay, 99% i ensure about that
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- So pass the noisy thing, the prrety other is quite easily LOL. So on this step you need to do next is dump MySQL DB –> To SQL file
Remember change something about URL if you need to configure HTTP - HTTPS (just optinal if you have LOL)
- If you need to concern more about configuration, one more thing you need to focus is
APACHE2 .htaccess
for about webserver configure and wp-admin
for about Wordpress configure, the default configure is okay but some kind situation you need to understand about that too.
Preparing the thing what you want, Moving onprem –> K8s. Go live it
- Azure offer for users can mount data into blob by using az-cli or azcopy but for easily interactive with AzureBlob –> azcopy-tools for copy data from your machine into AzureBlob
- After install azcopy, login azcopy with your azure account
- Login succeed, so you need generate SAS Token for each BlobStorage which want to mount data inside by UI

NOTICE: Need to set purpose role and what public ip address of your local pc where storage the data want to be mounted
- After generate SAS token, Now you are having SAS token, so you just need read command in azcopy copy for writing script to mounting data from local into blob storage. Example
You can change the route of path where you want data to mounted in before Blob SAS Token
- First of all, MySQL is package in file dump from On-Opem. So mount that to blob with
After your mount process complete:
- Check the blobstorage have your file
- Access mysql to import sql file into mysql on AKS by command
mysql -u <user-access-mysql> -p < <database.sql>
- Access mysql to check mysql have wordpress database (password mysql will store inside tfstate file or aks secret credentials-bravowebsite)
- Secondly with WP, Just need mount only pluggin and upload folder in wp-contents folder into wp Azureblob
- After complete, the wordpress website will have full data and pluggin of wordpress older –> For some reason in AKS, wordpress will be load slowly because loading to much pluggin. Just need to waiting for cache on browser on first request and wordpress will work greate but it will slower than physical system

Conclusion
- So that all thing i want to share about i know about to create or migrate WP from on-prem to k8s (AKS)
- This not to hard but it need to more clearly on driver and anything relate with storage of Azure
- So this is job i do about 4-5 months ago, so I don't remember too much if missing somthing but it all clearly i want to share.
- Maybe on next time, can we go to deploy Wordpress and learn Apache2 config and WP-Admin. So see you about that on that session
Reference