mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Now that we automatically format GCE PD, remove formatting from the e2e test.
Also remove docs that note that it is necessary.
This commit is contained in:
		@@ -41,7 +41,7 @@ Watch out when using this type of volume, because:
 | 
				
			|||||||
  - When Kubernetes adds resource-aware scheduling, as is planned, it will not be able to account for resources used by a HostDir.
 | 
					  - When Kubernetes adds resource-aware scheduling, as is planned, it will not be able to account for resources used by a HostDir.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### GCEPersistentDisk
 | 
					### GCEPersistentDisk
 | 
				
			||||||
__Important: You must create and format a PD before you can use it__
 | 
					__Important: You must create a PD using ```gcloud``` or the GCE API before you can use it__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
A Volume with a GCEPersistentDisk property allows access to files on a Google Compute Engine (GCE)
 | 
					A Volume with a GCEPersistentDisk property allows access to files on a Google Compute Engine (GCE)
 | 
				
			||||||
[Persistent Disk](http://cloud.google.com/compute/docs/disks).
 | 
					[Persistent Disk](http://cloud.google.com/compute/docs/disks).
 | 
				
			||||||
@@ -55,20 +55,10 @@ There are some restrictions when using a GCEPersistentDisk:
 | 
				
			|||||||
    - replication controllers with replicas > 1 can only be created for pods that use read-only mounts.
 | 
					    - replication controllers with replicas > 1 can only be created for pods that use read-only mounts.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### Creating a PD
 | 
					#### Creating a PD
 | 
				
			||||||
Before you can use a GCE PD with a pod, you need to create it and format it.
 | 
					Before you can use a GCE PD with a pod, you need to create it.
 | 
				
			||||||
 | 
					 | 
				
			||||||
__We are actively working on making this more streamlined.__
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
```sh
 | 
					```sh
 | 
				
			||||||
DISK_NAME=my-data-disk
 | 
					gcloud compute disks create --size=500GB --zone=us-central1-a my-data-disk
 | 
				
			||||||
DISK_SIZE=500GB
 | 
					 | 
				
			||||||
ZONE=us-central1-a
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
gcloud compute disks create --size=$DISK_SIZE --zone=$ZONE $DISK_NAME
 | 
					 | 
				
			||||||
gcloud compute instances attach-disk --zone=$ZONE --disk=$DISK_NAME --device-name temp-data kubernetes-master
 | 
					 | 
				
			||||||
gcloud compute ssh --zone=$ZONE kubernetes-master \
 | 
					 | 
				
			||||||
  --command "sudo mkdir /mnt/tmp && sudo /usr/share/google/safe_format_and_mount /dev/disk/by-id/google-temp-data /mnt/tmp"
 | 
					 | 
				
			||||||
gcloud compute instances detach-disk --zone=$ZONE --disk $DISK_NAME kubernetes-master
 | 
					 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### GCE PD Example configuration:
 | 
					#### GCE PD Example configuration:
 | 
				
			||||||
@@ -88,7 +78,7 @@ desiredState:
 | 
				
			|||||||
      - name: testpd
 | 
					      - name: testpd
 | 
				
			||||||
        source:
 | 
					        source:
 | 
				
			||||||
          persistentDisk:
 | 
					          persistentDisk:
 | 
				
			||||||
            # This GCE PD must already exist and be formatted ext4
 | 
					            # This GCE PD must already exist.
 | 
				
			||||||
            pdName: test
 | 
					            pdName: test
 | 
				
			||||||
            fsType: ext4
 | 
					            fsType: ext4
 | 
				
			||||||
id: testpd
 | 
					id: testpd
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,7 @@ desiredState:
 | 
				
			|||||||
      - name: testpd
 | 
					      - name: testpd
 | 
				
			||||||
        source:
 | 
					        source:
 | 
				
			||||||
          persistentDisk:
 | 
					          persistentDisk:
 | 
				
			||||||
            # This GCE PD must already exist and be formatted ext4
 | 
					            # This GCE PD must already exist.
 | 
				
			||||||
            pdName: "%insert_pd_name_here%"
 | 
					            pdName: "%insert_pd_name_here%"
 | 
				
			||||||
            fsType: ext4
 | 
					            fsType: ext4
 | 
				
			||||||
id: testpd
 | 
					id: testpd
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,32 +39,24 @@ $ <kubernetes>/cluster/kube-up.sh
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
where `<kubernetes>` is the path to your Kubernetes installation.
 | 
					where `<kubernetes>` is the path to your Kubernetes installation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Create and format two persistent disks
 | 
					## Create two persistent disks
 | 
				
			||||||
 | 
					
 | 
				
			||||||
For this WordPress installation, we're going to configure our Kubernetes [pods](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/pods.md) to use [persistent disks](https://cloud.google.com/compute/docs/disks). This means that we can preserve installation state across pod shutdown and re-startup.
 | 
					For this WordPress installation, we're going to configure our Kubernetes [pods](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/pods.md) to use [persistent disks](https://cloud.google.com/compute/docs/disks). This means that we can preserve installation state across pod shutdown and re-startup.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Before doing anything else, we'll create and format the persistent disks that we'll use for the installation: one for the mysql pod, and one for the wordpress pod.
 | 
					Before doing anything else, we'll create the persistent disks that we'll use for the installation: one for the mysql pod, and one for the wordpress pod.
 | 
				
			||||||
The general series of steps required is as described [here](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/volumes.md), where $ZONE is the zone where your cluster is running, and $DISK_SIZE is specified as, e.g. '500GB'.  In future, this process will be more streamlined.
 | 
					The general series of steps required is as described [here](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/volumes.md), where $ZONE is the zone where your cluster is running, and $DISK_SIZE is specified as, e.g. '500GB'.  In future, this process will be more streamlined.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
So for the two disks used in this example, do the following.
 | 
					So for the two disks used in this example, do the following.
 | 
				
			||||||
First create and format the mysql disk, setting the disk size to meet your needs:
 | 
					First create the mysql disk, setting the disk size to meet your needs:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
gcloud compute disks create --size=$DISK_SIZE --zone=$ZONE mysql-disk
 | 
					gcloud compute disks create --size=$DISK_SIZE --zone=$ZONE mysql-disk
 | 
				
			||||||
gcloud compute instances attach-disk --zone=$ZONE --disk=mysql-disk --device-name temp-data kubernetes-master
 | 
					 | 
				
			||||||
gcloud compute ssh --zone=$ZONE kubernetes-master \
 | 
					 | 
				
			||||||
  --command "sudo mkdir -p /mnt/tmp && sudo /usr/share/google/safe_format_and_mount /dev/disk/by-id/google-temp-data /mnt/tmp"
 | 
					 | 
				
			||||||
gcloud compute instances detach-disk --zone=$ZONE --disk mysql-disk kubernetes-master
 | 
					 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Then create and format the wordpress disk.  Note that you may not want as large a disk size for the wordpress code as for the mysql disk.
 | 
					Then create the wordpress disk.  Note that you may not want as large a disk size for the wordpress code as for the mysql disk.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
gcloud compute disks create --size=$DISK_SIZE --zone=$ZONE wordpress-disk
 | 
					gcloud compute disks create --size=$DISK_SIZE --zone=$ZONE wordpress-disk
 | 
				
			||||||
gcloud compute instances attach-disk --zone=$ZONE --disk=$wordpress-disk --device-name temp-data kubernetes-master
 | 
					 | 
				
			||||||
gcloud compute ssh --zone=$ZONE kubernetes-master \
 | 
					 | 
				
			||||||
  --command "sudo mkdir -p /mnt/tmp && sudo /usr/share/google/safe_format_and_mount /dev/disk/by-id/google-temp-data /mnt/tmp"
 | 
					 | 
				
			||||||
gcloud compute instances detach-disk --zone=$ZONE --disk wordpress-disk kubernetes-master
 | 
					 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Start the Mysql Pod and Service
 | 
					## Start the Mysql Pod and Service
 | 
				
			||||||
@@ -102,7 +94,7 @@ desiredState:
 | 
				
			|||||||
      - name: mysql-persistent-storage
 | 
					      - name: mysql-persistent-storage
 | 
				
			||||||
        source:
 | 
					        source:
 | 
				
			||||||
          persistentDisk:
 | 
					          persistentDisk:
 | 
				
			||||||
            # This GCE PD must already exist and be formatted ext4
 | 
					            # This GCE PD must already exist
 | 
				
			||||||
            pdName: mysql-disk
 | 
					            pdName: mysql-disk
 | 
				
			||||||
            fsType: ext4
 | 
					            fsType: ext4
 | 
				
			||||||
labels:
 | 
					labels:
 | 
				
			||||||
@@ -207,7 +199,7 @@ desiredState:
 | 
				
			|||||||
        source:
 | 
					        source:
 | 
				
			||||||
          # emptyDir: {}
 | 
					          # emptyDir: {}
 | 
				
			||||||
          persistentDisk:
 | 
					          persistentDisk:
 | 
				
			||||||
            # This GCE PD must already exist and be formatted ext4
 | 
					            # This GCE PD must already exist
 | 
				
			||||||
            pdName: wordpress-disk
 | 
					            pdName: wordpress-disk
 | 
				
			||||||
            fsType: ext4
 | 
					            fsType: ext4
 | 
				
			||||||
labels:
 | 
					labels:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,7 +24,7 @@ desiredState:
 | 
				
			|||||||
        source:
 | 
					        source:
 | 
				
			||||||
          # emptyDir: {}
 | 
					          # emptyDir: {}
 | 
				
			||||||
          persistentDisk:
 | 
					          persistentDisk:
 | 
				
			||||||
            # This GCE PD must already exist and be formatted ext4
 | 
					            # This GCE PD must already exist.
 | 
				
			||||||
            pdName: mysql-disk
 | 
					            pdName: mysql-disk
 | 
				
			||||||
            fsType: ext4
 | 
					            fsType: ext4
 | 
				
			||||||
labels:
 | 
					labels:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,7 +23,7 @@ desiredState:
 | 
				
			|||||||
        source:
 | 
					        source:
 | 
				
			||||||
          # emptyDir: {}
 | 
					          # emptyDir: {}
 | 
				
			||||||
          persistentDisk:
 | 
					          persistentDisk:
 | 
				
			||||||
            # This GCE PD must already exist and be formatted ext4
 | 
					            # This GCE PD must already exist.
 | 
				
			||||||
            pdName: wordpress-disk
 | 
					            pdName: wordpress-disk
 | 
				
			||||||
            fsType: ext4
 | 
					            fsType: ext4
 | 
				
			||||||
labels:
 | 
					labels:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -105,15 +105,8 @@ trap "teardown" EXIT
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
perl -p -e "s/%.*%/${disk_name}/g" ${KUBE_ROOT}/examples/gce-pd/testpd.yaml > ${config}
 | 
					perl -p -e "s/%.*%/${disk_name}/g" ${KUBE_ROOT}/examples/gce-pd/testpd.yaml > ${config}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create and format the disk.
 | 
					# Create the disk. The first mount into a pod should format it.
 | 
				
			||||||
"${GCLOUD}" compute disks create --zone="${ZONE}" --size=10GB "${disk_name}"
 | 
					"${GCLOUD}" compute disks create --zone="${ZONE}" --size=10GB "${disk_name}"
 | 
				
			||||||
"${GCLOUD}" compute instances attach-disk --zone="${ZONE}" --disk="${disk_name}" \
 | 
					 | 
				
			||||||
  --device-name tempdata "${MASTER_NAME}"
 | 
					 | 
				
			||||||
"${GCLOUD}" compute ssh --zone="${ZONE}" "${MASTER_NAME}" --command "sudo rm -rf /mnt/tmp"
 | 
					 | 
				
			||||||
"${GCLOUD}" compute ssh --zone="${ZONE}" "${MASTER_NAME}" --command "sudo mkdir -p /mnt/tmp"
 | 
					 | 
				
			||||||
"${GCLOUD}" compute ssh --zone="${ZONE}" "${MASTER_NAME}" --command "sudo /usr/share/google/safe_format_and_mount /dev/disk/by-id/google-tempdata /mnt/tmp"
 | 
					 | 
				
			||||||
"${GCLOUD}" compute ssh --zone="${ZONE}" "${MASTER_NAME}" --command "sudo umount /mnt/tmp"
 | 
					 | 
				
			||||||
"${GCLOUD}" compute instances detach-disk --zone="${ZONE}" --disk "${disk_name}" "${MASTER_NAME}"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create a pod that uses the PD
 | 
					# Create a pod that uses the PD
 | 
				
			||||||
${KUBECTL} create -f ${config}
 | 
					${KUBECTL} create -f ${config}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user