WordPress deployment example

Prev Next

Available in VPC

This is an example to use Kubectl CLI introduced in Getting started with Ncloud Kubernetes Service (VPC) to deploy WordPress.

WordPress deployment example through Kubectl

WordPress deployment example

To deploy WordPress, you must deploy MySQL first.

The following is the example for deploying WordPress through Kubectl.

  1. Run the command shown below and create a password to access MySQL as a secret object.
    kubectl --kubeconfig $KUBE_CONFIG create secret generic mysql-pass --from-literal=password="YOUR_PASSWORD"
    
  2. Download the MySQL service manifest file from the link below.
  3. Run the command shown below to reflect the downloaded MySQL service manifest file to the cluster.
    kubectl --kubeconfig $KUBE_CONFIG apply -f  https://gist.githubusercontent.com/NaverCloudPlatformDeveloper/39e63bf8051c2af338bf4728b4336358/raw/1804b7b36eb6818fedf600c73f6b9cf9219529a0/nks-tutorial-mysql.yaml
    
  4. Download the WordPress service manifest file from the link below.
  5. Run the command shown below to reflect the downloaded WordPress service manifest file to the cluster.
    kubectl --kubeconfig $KUBE_CONFIG apply -f https://gist.githubusercontent.com/NaverCloudPlatformDeveloper/8bb23ccd8310f05d2ef737835d4d1748/raw/d97aa174df6f31d7c4b0de5957fe67c6a2846fe3/nks-tutorial-wordpress.yaml
    

Example of checking the deployment status in real time

You can use the command shown below to check the deployment status of WordPress in real time.

kubectl --kubeconfig $KUBE_CONFIG get service wordpress --watch
  • The service becomes available after a certain time when EXTERNAL-IP is changed to a real address from the Pending status.
  • You can use the command shown below to check the whole EXTERNAL-IP address of the WordPress service.
    kubectl --kubeconfig $KUBE_CONFIG get service wordpress
    
  • Access the EXTERNAL-IP (e.g., slb-1815725.ncloudslb.com) of WordPress from a browser to see the WordPress page.

Example of WordPress pod scaling

The following is an example of scaling the pod where the WordPress service belongs to.

  1. Run the command shown below to confirm that there is one MySQL pod and WordPress pod each.
    kubectl --kubeconfig $KUBE_CONFIG get pods
    
  2. Run the command shown below to increase the number of WordPress pods to three.
    kubectl --kubeconfig $KUBE_CONFIG scale deployments/wordpress --replicas=3
    
  3. Run the command shown below to check whether the number of WordPress pods has increased to three.
    • The result will be shown as below.
    NAME                               READY   STATUS    RESTARTS   AGE
    wordpress-6d884d9866-2c8cl         1/1     Running   0          5s
    wordpress-6d884d9866-7rxj8         1/1     Running   0          5s
    wordpress-6d884d9866-lj5bl         1/1     Running   0          12m
    wordpress-mysql-7977b9588d-gbtll   1/1     Running   0          14m
    

WordPress version update example

The following is an example where you update the 5.2 version of WordPress to the 5.2.2 version.

  1. Run the command shown below to check the current version of WordPress.
    kubectl --kubeconfig $KUBE_CONFIG get deployments wordpress -o wide
    
  2. Run the command shown below to update the WordPress version from 5.2 to 5.2.2.
    kubectl --kubeconfig $KUBE_CONFIG set image deployments/wordpress wordpress=wordpress:5.2.2-apache
    
  3. Run the command shown below to check the WordPress update in real time.
    kubectl --kubeconfig $KUBE_CONFIG get deployments wordpress -o wide -w