By Aman Basotra and Alka Gupta
This blog is a continuation from our previous blog where we had covered technical overview of project hatchway with pivotal container service (PKS) and shown how to create storage class, persistent volume claims, and other kubernetes storage constructs in PKS.
In this blog, we will showcase how to deploy stateful applications using PKS, using guestbook application as an example.
Step 1: A storage class, persistent volume claim and persistent volume are required to exist in the PKS environment as shown in Fig 1.
Step 2: Make sure the guestbook application yamlfile (let’s call it pv-guestbook.yaml) has volumeMounts and volumesparameters defined for the application pod as shown in Fig. 2.
Step 3: Deploy application by executing the command kubectl -f pv-guestbook.yaml and make sure all five application pods are in running state as shown in Fig. 3
Step 4: Check the node identity and service port on which the application UI frontend pod is running as shown in Fig. 4. This is to locate the IP address and port number for accessing the application.
Step 5 : Launch the application with the IP and port number identified as above. Provide a message to be stored in the application. This message will be stored in the persistent volume defined earlier.
Step 6: Delete the application and ensure all the pods for application are destroyed as shown in Fig. 6
Step 7: Try to re-launch the guestbook application. It will not be found as shown in Fig. 7
Step 8: Redeploy the application and recheck the node identity and service port on which the application UI frontend pod is running as shown in Fig 8 and 9
Step 10: Relaunch the application and the data stored earlier should persist as shown in Fig. 10.
This example demonstrates the persistent volume functionality in PKS. The data stored in the guestbook application persisted across its termination/failure. As such, it’s a best practice to use persistent volumes for stateful applications where data is required to persist beyond container/pod’s lifecycle. Pivotal Container Service can be downloaded from here. Install and configure PKS as per the documentation here. vSphere Cloud provider comes integrated into Kubernetes upstream distribution and no additional bits are need to be installed.