Skip to content

Latest commit

 

History

History
47 lines (38 loc) · 2.26 KB

app-deploy-mysql-and-service.adoc

File metadata and controls

47 lines (38 loc) · 2.26 KB

Deploy MySQL and Service

Duration: 4:00

MySQL uses persistent storage. Rather than writing the data directly into the container image itself, our example stores the MySQL in a Persistent Volume. Before you can deploy the pod, you need to claim a persistent volume that can be mounted inside of the MySQL container:

[vagrant@rhel-cdk kubernetes]$ kubectl create -f mysql-pvc.yaml
persistentvolumeclaim "mysql-pvc" created

CDK provides 3 PersistentVolumes, previously defined by the cluster administrator, called pv01(1Gi), pv02(2Gi) and pv03(3Gi). These PersistentVolumes will be assigned based on the size claimed by the PersistentVolumeClaim.

You can examine the PersistentVolumeClaim with the following command:

[vagrant@rhel-cdk kubernetes]$ kubectl get pvc
NAME        LABELS    STATUS    VOLUME    CAPACITY   ACCESSMODES   AGE
mysql-pvc   <none>    Bound     pv01      1Gi        RWO,RWX       12m

You can then deploy both the MySQL Pod and the Service with a single command:

[vagrant@rhel-cdk kubernetes]$ kubectl create -f mysql-rc.yaml -f mysql-service.yaml
replicationcontroller "mysql" created
service "mysql" created

Lastly, you can see the pods and service status via the command line. Recall the command you can use to see the status (hint: kubectl get …​). Make sure the status is Running before continuing.