《kubernetes-1.8.0》16-examples-vSphere Volume
《kubernetes 1.8.0 测试环境安装部署》
时间:2017-12-04
一、关于vSphere Volume:
之前写了一篇关于vSphere Cloud Provider
的bolg,本文中实现vSphere Volume
前提是vSphere Cloud Provider
的支持,关于vSphere Cloud Provider
–> 《kubernetes-1.8.0》15-addon-vSphere Cloud Provider
本文是关于vSphere Cloud Provider
的应用例子,分别用pod volume直接挂载、通过pv pvc使用、以及通过Storage Class
使用vSphere Volume;
二、直接通过volume挂载:
1、ssh到ESX上,在ESX上创建VMDK:
[root@localhost:~] vmkfstools -c 2G /vmfs/volumes/local_datastore_47/k8s-volume/myDisk.vmdk
/vmfs/volumes/local_datastore_47
:为数据存储路径
2、创建pod并用上myDisk.vmdk:
vsphere-volume-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: test-vmdk
spec:
containers:
- image: gcr.mirrors.ustc.edu.cn/google_containers/test-webserver
name: test-container
volumeMounts:
- mountPath: /test-vmdk
name: test-volume
volumes:
- name: test-volume
# This VMDK volume must already exist.
vsphereVolume:
volumePath: "[local_datastore_47] k8s-volume/myDisk"
fsType: ext4
volumePath
:[local_datastore_47]
为数据存储名,k8s-volume/myDisk为 目录/vmdk
3、创建pod
$ kubectl create -f vsphere-volume-pod.yaml
4、验证是否成功挂载:
[root@node-131 vsphere-volume]# kubectl get pods
NAME READY STATUS RESTARTS AGE
...
test-vmdk 1/1 Running 0 2h
...
[root@node-131 vsphere-volume]# kubectl describe pods test-vmdk
Name: test-vmdk
Namespace: default
...
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 17s default-scheduler Successfully assigned test-vmdk to node.131
Normal SuccessfulMountVolume 17s kubelet, node.131 MountVolume.SetUp succeeded for volume "default-token-t8j7k"
Normal SuccessfulMountVolume 16s kubelet, node.131 MountVolume.SetUp succeeded for volume "test-volume"
Normal Pulling 15s kubelet, node.131 pulling image "gcr.mirrors.ustc.edu.cn/google_containers/test-webserver"
Normal Pulled 10s kubelet, node.131 Successfully pulled image "gcr.mirrors.ustc.edu.cn/google_containers/test-webserver"
Normal Created 10s kubelet, node.131 Created container
Normal Started 10s kubelet, node.131 Started container
三、通过PV方式实现:
利用之前创建的vmdk
:/vmfs/volumes/local_datastor