diff --git a/content/en/docs/tasks/run-application/mysql-deployment.yaml b/content/en/docs/tasks/run-application/mysql-deployment.yaml index dc1275792b..518457777e 100644 --- a/content/en/docs/tasks/run-application/mysql-deployment.yaml +++ b/content/en/docs/tasks/run-application/mysql-deployment.yaml @@ -9,17 +9,6 @@ spec: app: mysql clusterIP: None --- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: mysql-pv-claim -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 20Gi ---- apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 kind: Deployment metadata: diff --git a/content/en/docs/tasks/run-application/mysql-pv.yaml b/content/en/docs/tasks/run-application/mysql-pv.yaml new file mode 100644 index 0000000000..6f4e692f3b --- /dev/null +++ b/content/en/docs/tasks/run-application/mysql-pv.yaml @@ -0,0 +1,26 @@ +kind: PersistentVolume +apiVersion: v1 +metadata: + name: mysql-pv-volume + labels: + type: local +spec: + storageClassName: manual + capacity: + storage: 20Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/data" +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mysql-pv-claim +spec: + storageClassName: manual + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 20Gi diff --git a/content/en/docs/tasks/run-application/run-single-instance-stateful-application.md b/content/en/docs/tasks/run-application/run-single-instance-stateful-application.md index 3840ad2a00..ea02502645 100644 --- a/content/en/docs/tasks/run-application/run-single-instance-stateful-application.md +++ b/content/en/docs/tasks/run-application/run-single-instance-stateful-application.md @@ -49,14 +49,19 @@ Note: The password is defined in the config yaml, and this is insecure. See for a secure solution. {{< code file="mysql-deployment.yaml" >}} +{{< code file="mysql-pv.yaml" >}} + +1. Deploy the PV and PVC of the YAML file: + + kubectl create -f https://k8s.io/docs/tasks/run-application/mysql-pv.yaml 1. Deploy the contents of the YAML file: - kubectl create -f https://k8s.io/docs/tasks/run-application/mysql-deployment.yaml + kubectl create -f https://k8s.io/docs/tasks/run-application/mysql-deployment.yaml 1. Display information about the Deployment: - kubectl describe deployment mysql + kubectl describe deployment mysql Name: mysql Namespace: default @@ -96,14 +101,14 @@ for a secure solution. 1. List the pods created by the Deployment: - kubectl get pods -l app=mysql + kubectl get pods -l app=mysql NAME READY STATUS RESTARTS AGE mysql-63082529-2z3ki 1/1 Running 0 3m 1. Inspect the PersistentVolumeClaim: - kubectl describe pvc mysql-pv-claim + kubectl describe pvc mysql-pv-claim Name: mysql-pv-claim Namespace: default @@ -165,6 +170,7 @@ Delete the deployed objects by name: ``` kubectl delete deployment,svc mysql kubectl delete pvc mysql-pv-claim +kubectl delete pv mysql-pv-volume ``` If you manually provisioned a PersistentVolume, you also need to manually diff --git a/test/examples_test.go b/test/examples_test.go index 55d0fa6a92..89a179e3b8 100644 --- a/test/examples_test.go +++ b/test/examples_test.go @@ -474,7 +474,8 @@ func TestExampleObjectSchemas(t *testing.T) { "deployment-update": {&extensions.Deployment{}}, "hpa-php-apache": {&autoscaling.HorizontalPodAutoscaler{}}, "mysql-configmap": {&api.ConfigMap{}}, - "mysql-deployment": {&api.Service{}, &api.PersistentVolumeClaim{}, &extensions.Deployment{}}, + "mysql-deployment": {&api.Service{}, &extensions.Deployment{}}, + "mysql-pv": {&api.PersistentVolume{}, &api.PersistentVolumeClaim{}}, "mysql-services": {&api.Service{}, &api.Service{}}, "mysql-statefulset": {&apps.StatefulSet{}}, },