Cloud Computing, DevOps, Google Cloud (GCP)

5 Mins Read

Deploying WordPress on Google Kubernetes Engine (GKE)

Voiced by Amazon Polly


In today’s rapidly evolving landscape of containerized applications, deploying WordPress on Google Kubernetes Engine (GKE) offers unparalleled scalability and resilience. This guide serves as a comprehensive resource, detailing the steps involved in setting up a robust WordPress deployment paired with a MySQL database, utilizing Persistent Disk for storage, and leveraging Google Cloud SQL for efficient database management.

WordPress and Its Data Storage

WordPress relies heavily on relational databases for storing articles and metadata, as well as on local file systems for asset management. Given the transient nature of containers, storing persistent data within them is impractical. Persistent Disk provides a reliable solution, ensuring that data remains intact even in the event of container deletion.

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

Setting up your environment

To kickstart the setup process, configure Google Cloud Shell by setting the desired region and downloading the necessary application manifest files from the GitHub repository

Download the manifest files

Creating a GKE cluster

Leverage Google Cloud Shell to create a GKE cluster tailored to host your WordPress application containers. Once created, establish a connection to the newly provisioned cluster to facilitate further configuration.

Provicining PV and a PVC :

In order to achieve persistent data storage for the WordPress deployment, it’s imperative to create a Persistent Volume (PV) and a Persistent Volume Claim (PVC). Google Kubernetes Engine (GKE) simplifies this process by offering a default StorageClass resource, enabling dynamic provisioning of PVs backed by Persistent Disk.

PVC Creation Manifest:

We utilize the wordpress-volumeclaim.yaml file to describe our PVC. This manifest requests 200 GB of storage. Note that we haven’t explicitly defined a StorageClass resource in the file, implying the use of the default StorageClass for provisioning a PV backed by Persistent Disk.Command to deploy the manifest

Setting up Google Cloud SQL instance

Generate credentials for a database user named “wordpress” and assign a password for WordPress authentication to the instance:

Deploying WordPress

Configure Service Account and Create Kubernetes Secrets:
Before proceeding with the deployment of WordPress, it’s essential to set up a service account and create Kubernetes secrets to manage both the service account and database credentials. This ensures secure communication between our WordPress application and the MySQL instance through a Google Cloud SQL proxy.

Create Service Account:
We begin by creating a service account named <cloudsql-proxy> using the Google Cloud CLI:

This command establishes a dedicated service account for our deployment.

Extract Service Account Email:
We extract the service account’s email address and set it as an environment variable for later use:

Assign Required Role:
To enable the service account to interact with Google Cloud SQL, we add the cloudsql.client role:This step ensures the necessary permissions for the service account.

Generate Key for Service Account:
Generate a key file named “key.json” for the service account to facilitate authentication and authorization access.

Create Kubernetes Secrets:
We create two Kubernetes secrets to store MySQL and service account credentials securely:
For MySQL credentials:

For service account credentials:

These confidential pieces of information are vital for securely handling the sensitive data necessary to facilitate the communication between WordPress and the underlying MySQL database.

Deploy WordPress on GKE

It’s time to deploy our WordPress container in the Google Kubernetes Engine (GKE) cluster. This involves utilizing the wordpress_cloudsql.yaml manifest file, which defines a Deployment creating a Pod with the WordPress container.

Manifest File Description:
The wordpress_cloudsql.yaml manifest file encapsulates the deployment configuration. It specifies a single Pod running a container with the WordPress instance. Here are the key components:

  • The container reads the WORDPRESS_DB_PASSWORD environment variable, which contains the cloudsql-db-credentials secret created earlier.
  • Configuration for communication with MySQL is facilitated through the Google Cloud SQL proxy running in a sidecar container. The WORDPRESS_DB_HOST environment variable is crucial in this setup.

Prepare and Deploy:
Before deployment, it’s essential to prepare the manifest file by replacing the <INSTANCE_CONNECTION_NAME> environment variable. This is achieved using the following commands:

We’re prepared to initiate the deployment of the WordPress container utilizing the manifest file.

Monitor Deployment Status:
The deployment process takes a few minutes as the manifest file orchestrates the attachment of a Persistent Disk to the compute node. To monitor the deployment status and ensure everything is running smoothly, use the following command.

Expose WordPress Service for External Access

In the preceding step, we successfully deployed the WordPress container; however, it’s currently secluded within your cluster without an external IP address. To make your WordPress app accessible from the internet, we’ll create and configure a Kubernetes Service with an attached external load balancer.

Service Exposure Configuration:

Utilizing the wordpress-service.yaml file, this configuration ensures external accessibility for your WordPress app. The Service is explicitly defined with the type LoadBalancer, indicating the need for an external load balancer.

Command to Create Service:

Monitor Service Creation:

The process of creating the load balancer takes a few minutes. Keep an eye on the deployment progress and wait for the Service to be assigned an external IP address. Utilize the following command:

When the output displays an external IP address, as illustrated below, you’re ready to move forward. Note that your external IP will differ from the example:
Sample Output:

Setting up your WordPress blog

Now that your WordPress service is externally accessible, it’s time to configure and set up your WordPress blog.

Navigate to WordPress Installation Page

Using your preferred web browser, visit the following URL, replacing external-ip-address with the actual EXTERNAL_IP address assigned to your WordPress service,

Begin WordPress Installation:

Upon reaching the WordPress installation page, you’ll have the opportunity to choose your desired language. Simply select your preferred language and proceed by clicking on the “Continue” button.

Provide Essential Information:

Proceed to the “Information Needed” page. Here, we will be required to input crucial details for your WordPress blog, including the site title, username, password, and email address. Fill in the necessary information.


Finalize WordPress Installation:

Once you’ve filled in the necessary information, proceed by clicking the “Install WordPress” button to begin the installation process.

Log In to our WordPress Dashboard:

Access your WordPress dashboard by clicking on “Log In” after the installation is finished. Then, enter the username and password you set up earlier during the installation process.



Congratulations on successfully deploying WordPress on Google Kubernetes Engine (GKE) with Persistent Disk and Google Cloud SQL! This setup ensures data durability and availability, with Persistent Disk providing reliable storage outside the containers and Google Cloud SQL offering a managed MySQL database solution.

Drop a query if you have any questions regarding GKE and we will get back to you quickly.

Experience Effortless Cloud Migration with Our Expert Solutions

  • Stronger security  
  • Accessible backup      
  • Reduced expenses
Get Started

About CloudThat

CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.

CloudThat is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 650k+ professionals in 500+ cloud certifications and completed 300+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, AWS Training Partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery Partner, Microsoft Gold Partner, AWS Microsoft Workload Partners, Amazon EC2 Service Delivery Partner, and many more.

To get started, go through our Consultancy page and Managed Services PackageCloudThat’s offerings.


1. Why use Persistent Disk for WordPress on GKE?

ANS: – Persistent Disk ensures that your WordPress data persists even if containers are deleted or moved. It provides a reliable storage solution outside the containers, enhancing data durability.

2. What is the role of Google Cloud SQL in this deployment?

ANS: – Google Cloud SQL serves as the managed MySQL database for WordPress. It replaces the traditional installation of MySQL, offering a scalable and fully managed database solution for your WordPress application.

WRITTEN BY Deepakraj A L

Deepakraj A L works as a Research Intern at CloudThat. He is learning and gaining practical experience in AWS and Azure. Deepakraj is also passionate about continuously expanding his skill set and knowledge base by actively seeking opportunities to learn new skills. Deepakraj regularly explores blogs and articles related to various programming languages, technologies, and industry trends to stay up to date with the latest development in the field.



    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!