How to Deploy Wordpress Using Manifest
Trait is the fundamental characteristic of application components. Different traits have different contents. For detailed information, please refer to the Built-in Trait Types.
Now let’s start from scratch. In the previous chapters, we introduced Manifest and Spec. When we want to deploy Wordpress on your RAPD environment, the preceding content of the Manifest is as follows:
apiVersion: po.rapd.app/v1beta1kind: Applicationmetadata: name: my_wordpressspec: version: "1.0" revisionHistory: 3 components: ...
Next, to deploy a Wordpress, we will need a DB server. Therefore, in the component composition of this application, we can add the following example:
- type: webservice.container name: wordpress-mysql target: AWS_K8S traits: - type: container image: mysql ports: - port: 3306 name: "mysql_port" protocol: "TCP" env: - name: MYSQL_DATABASE value: wp - name: MYSQL_USER value: user - name: MYSQL_PASSWORD value: passwd - name: MYSQL_ROOT_PASSWORD value: aaaaaa
After deploying through RAPD, we will have a mysql container running externally on port 3306 within the cluster named AWS_K8S.
But we are still missing the main webservice: Wordpress. So we can add the following example within the component:
- type: webservice.container name: wordpress target: AWS_K8S traits: - type: container image: wordpress ports: - port: 80 name: "http" protocol: "TCP"
Wait a moment, it seems like we’re missing something here!!!
Now, there are two containers, Wordpress and mysql, within the Component, but they are not related to each other. Right, Wordpress lacks the location and credentials of the DB. So we need to modify the above Trait example:
- type: container image: wordpress ports: - port: 80 name: "http" protocol: "TCP" env: - name: WORDPRESS_DB_HOST value: my_wordpress-wordpress-mysql - name: WORDPRESS_DB_USER value: wpuser - name: WORDPRESS_DB_PASSWORD value: passwd - name: WORDPRESS_DB_NAME value: wp
Through this Manifest, we can deploy these two pods on the AWS K8S Cluster with RAPD, and start using the newly deployed Wordpress immediately. Open your browser and enter http://{your-k8s-domain}, but you’ll find that you can’t access the Wordpress homepage. It turns out that our webservice is still missing routing. Therefore, the complete example of the Wordpress component should be as follows:
- type: webservice.container name: wordpress target: [deployment_target_name] traits: - type: container image: wordpress ports: - port: 80 name: "http" protocol: "TCP" env: - name: WORDPRESS_DB_HOST value: my_wordpress-wordpress-mysql - name: WORDPRESS_DB_USER value: wpuser - name: WORDPRESS_DB_PASSWORD value: passwd - name: WORDPRESS_DB_NAME value: wp - type: ingressRoute paths: "/": 80 pathType: Prefix name: ingr-name
Let’s refresh the Manifest and redeploy. After RAPD completes the deployment, you will find that the previously unreachable Wordpress can now be accessed.
Congratulations! You can now use Manifest to build your own application scenarios and let RAPD quickly deploy them in different environments.