Deploying WordPress Using Helm
Helm is a package manager that simplifies the deployment, upgrade, and management of Kubernetes applications. Helm uses charts (a packaging format that defines Kubernetes resources) to encapsulate all elements deployed by Kubernetes, including application code, dependencies, configuration files, and deployment instructions. With Helm, you can easily deploy and manage complex Kubernetes applications, simplifying application development and deployment.
This section describes how to deploy the WordPress workload using Helm.
Prerequisites
You have created a CCE cluster that contains a node with 4 vCPUs and 8 GiB memory. The node has an EIP to pull the WordPress image from an external repository. For details on how to create a cluster, see Creating a Kubernetes Cluster.
Preparations
- Download and configure kubectl to connect to the cluster.
Log in to the CCE console and click the target cluster name. In the Connection Information area of the Cluster Information page, click Configure next to kubectl and configure kubectl as instructed.
Figure 1 kubectl - Install Helm 3.
Deploying WordPress
- Add the official WordPress repository.
helm repo add bitnami https://charts.bitnami.com/bitnami
- Run the following commands to create a WordPress workload:
helm install myblog bitnami/wordpress \ --set mariadb.primary.persistence.enabled=true \ --set mariadb.primary.persistence.storageClass=csi-disk \ --set mariadb.primary.persistence.size=10Gi \ --set persistence.enabled=false
- mariadb uses a persistent volume (PV) to store data. The PV is automatically created with an EVS disk of 10 GiB by configuring StorageClassName.
- Data persistence is not required for WordPress. Set persistence.enabled to false for the data volume.
Information similar to the following is displayed:
coalesce.go:223: warning: destination for mariadb.networkPolicy.egressRules.customRules is a table. Ignoring non-table value ([]) NAME: myblog LAST DEPLOYED: Mon Mar 27 11:47:58 2023 NAMESPACE: default STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: CHART NAME: wordpress CHART VERSION: 15.2.57 APP VERSION: 6.1.1 ** Please be patient while the chart is being deployed ** Your WordPress site can be accessed through the following DNS name from within your cluster: myblog-wordpress.default.svc.cluster.local (port 80) To access your WordPress site from outside the cluster follow the steps below: 1. Get the WordPress URL by running these commands: NOTE: It may take a few minutes for the LoadBalancer IP to be available. Watch the status with: 'kubectl get svc --namespace default -w myblog-wordpress' export SERVICE_IP=$(kubectl get svc --namespace default myblog-wordpress --template "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}") echo "WordPress URL: http://$SERVICE_IP/" echo "WordPress Admin URL: http://$SERVICE_IP/admin" 2. Open a browser and access WordPress using the obtained URL. 3. Login with the following credentials below to see your blog: echo Username: user echo Password: $(kubectl get secret --namespace default myblog-wordpress -o jsonpath="{.data.wordpress-password}" | base64 -d)
The command output shows how to obtain the WordPress URL and the username and password for logging in to the WordPress background.
Accessing WordPress
- Modify the WordPress Service configuration.
Additional annotation configuration is required for using a LoadBalancer Service in CCE. However, bitnami/wordpress does not have this configuration. You need to manually modify the configuration.
kubectl edit svc myblog-wordpress
Add kubernetes.io/elb.autocreate and kubernetes.io/elb.class to metadata.annotations and save the modification. The two annotations are used to create a shared load balancer so that the WordPress workload can be accessed through the EIP of the load balancer.
apiVersion: v1 kind: Service metadata: name: myblog-wordpress namespace: default annotations: kubernetes.io/elb.autocreate: '{ "type": "public", "bandwidth_name": "myblog-wordpress", "bandwidth_chargemode": "bandwidth", "bandwidth_size": 5, "bandwidth_sharetype": "PER", "eip_type": "5_bgp" }' kubernetes.io/elb.class: union spec: ports: - name: http ...
- Obtain the public network load balancer IP address of Service myblog-wordpress and access it.
On the Services tab, locate myblog-wordpress and find its public network load balancer IP address.
In the address box of a browser, enter <Public IP address of the load balancer>:80 to access WordPress.
In the address box of a browser, enter <Public IP address of the load balancer>:80/login to access the WordPress background as user user. Run the following command to obtain the password of user:
kubectl get secret --namespace default myblog-wordpress -o jsonpath="{.data.wordpress-password}" | base64 -d
Deleting the WordPress Workload
- Run the following command to delete the WordPress workload:
helm delete myblog
Information similar to the following is displayed:release "myblog" uninstalled
- Delete the PersistentVolumeClaim (PVC) used by the mariadb component in WordPress.
kubectl delete pvc data-myblog-mariadb-0
Information similar to the following is displayed:persistentvolumeclaim "data-myblog-mariadb-0" deleted
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot