HostPath转localDir、emptyDir或flexVolume
使用场景
在使用CCE或者其他K8s集群时,可以使用HostPath。由于CCI为共享集群,未开放HostPath能力,所以当使用HostPath的Pod想通过Virtual Kubelet弹到CCI时,会被vk-webhook拦截。如无法改变Pod spec.volumes中配置的HostPath,当前可通过配置Annotation的形式,允许让使用HostPath的Pod弹性到CCI上,但是VK在校验时需要去掉Pod中的HostPath或者将HostPath替换为localDir、emptyDir或者flexVolume。
通过在Pod.Annotations中加入注解可以做到HostPath转localDir、emptyDir或者flexVolume。
- 单个HostPath替换为localDir配置方式:
"coordinator.cci.io/hostpath-replacement": '[{"name":"source-hostpath-volume","policyType":"replaceByLocalDir","localDir":{"sizeLimit":"1Gi"}}]'
- 单个HostPath替换为flexVolume配置方式:
"coordinator.cci.io/hostpath-replacement": '[{"name":"source-hostpath-volume","policyType":"replaceByFlexVolume","flexVolume":{"driver": "huawei.com/fuxidisk", "fsType": "ext4", "options": {"volumeType": "sata", "volumeSize": "10Gi"}}}]'
EVS目前支持普通、高I/O、超高I/O三种规格,volumeType根据实际情况填写:表1 EVS规格 EVS规格
类型
适用场景
普通I/O
sata
后端存储由SATA存储介质提供,适用于大容量,读写速率要求不高,事务性处理较少的应用场景,如:开发测试、企业办公应用。
高I/O
sas
后端存储由SAS存储介质提供,适用于性能相对较高,读写速率要求高,有实时数据存储需求应用场景,如:创建文件系统、分布式文件共享。
超高I/O
ssd
后端存储SSD存储介质提供,适用于高性能、高读写速率要求、数据密集型应用场景,如:NoSQL、关系型数据库、数据仓库(如Oracle RAC、SAP HANA)。
- 全部hostPath都忽略:
"coordinator.cci.io/hostpath-replacement": '[{"name":"*","policyType":"remove"}]'
- 多个hostPath差异化替换策略:
"coordinator.cci.io/hostpath-replacement": '[{"name":"source-hostpath-volume-1","policyType":"remove"},{"name":"source-hostpath-volume-2","policyType":"replaceByLocalDir","localDir":{"sizeLimit":"1Gi"}},{"name":"source-hostpath-volume-3","policyType":"replaceByEmptyDir","emptyDir":{"sizeLimit":"10Gi"}}]'
示例deployment:
apiVersion: apps/v1 kind: Deployment metadata: annotations: description:'' labels: virtual-kubelet.io/burst-to-cci: enforce appgroup:'' version: v1 name: test namespace: default spec: replicas:2 selector: matchLabels: app: test version: v1 template: metadata: labels: app: test version: v1 annotations: coordinator.cci.io/hostpath-replacement:'[{"name": "test-log2", "policyType": "remove"}, {"name": "test-log", "policyType": "replaceByEmptyDir", "emptyDir":{"sizeLimit":"10Gi"}}, {"name": "test-log1", "policyType": "replaceByLocalDir", "localDir":{"sizeLimit":"1Gi"}}]' spec: containers: -name: container-1 image: nginx imagePullPolicy: IfNotPresent env: -name: PAAS_APP_NAME value: test -name: PAAS_NAMESPACE value: default -name: PAAS_PROJECT_ID value: 0b52a6e40b00d3682f36c0005163a82c resources: requests: cpu: 250m memory: 512Mi limits: cpu: 250m memory: 512Mi volumeMounts: -name: test-log mountPath: /tmp/log -name: test-log1 mountPath: /tmp/log1 -name: test-log2 mountPath: /tmp/log2 volumes: -hostPath: path: /var/paas/sys/log/virtual-kubelet type:"" name: test-log -hostPath: path: /var/paas/sys/log type:"" name: test-log1 -hostPath: path: /var/paas/sys/log2 type:"" name: test-log2