存储
弹性到CCI的工作负载支持多种华为云存储配置,用于满足客户多样化的存储需求。通过阅读本章用户可以:
- 了解弹性CCI的负载支持的存储类型。
- 了解弹性CCI的负载Hostpath类型的典型场景以及如何使用。
约束与限制
调度到CCI的实例的存储类型支持ConfigMap、Secret、EmptyDir、DownwardAPI、Projected、PersistentVolumeClaims几种Volume类型,其中Projected和DownwardAPI类型仅bursting 1.3.25版本及以上支持。
- EmptyDir:不支持子路径。
- PersistentVolumeClaims:只支持SFS Turbo云存储类型,且只支持使用CSI类型的StorageClass。1.17.10及以下版本的Volcano调度器不支持调度所有云存储类型。
- Projected:如配置了serviceAccountToken类型的source,那么弹性到CCI后挂载的会是对应service-account-token secret中的token,该token为长期有效的token且没有预期受众,即expirationSeconds和audience两项配置不会生效。
支持的存储类型
用户在配置负载存储类型时,CCE的console有如下选项。
弹性CCI的负载对存储类型的支持情况如下:
volume类型 |
是否支持 |
特殊场景说明 |
---|---|---|
HostPath |
否 |
|
ConfigMap |
是 |
- |
Secret |
是 |
- |
EmptyDir |
是 |
EmptyDir的sizeLimit仅对emptyDir.medium配置为“Memory”生效。 |
DownwardAPI |
是 |
- |
Projected |
是 |
如配置了serviceAccountToken类型的source,弹性到CCI后会挂载对应service-account-token secret中的token,该token为长期有效,且token没有预期受众,即expirationSeconds和audience两项配置不会生效。 |
PersistentVolumeClaims |
是 |
只支持SFS Turbo云存储类型,且只支持使用CSI类型的StorageClass。 |
负载Hostpath配置方式
操作场景
在使用CCE或者其他K8s集群时,用户使用HostPath类型存储。但CCI是共享集群,不开放HostPath能力,因此使用HostPath的Pod通过bursting弹到CCI时,会被拦截。如无法改变Pod spec.volumes中配置的HostPath,可通过配置Annotation的形式,允许让使用HostPath的Pod弹性到CCI上,bursting在校验时需要去掉Pod中的HostPath或者将HostPath替换为emptyDir。
约束与限制
- LocalDir和flexVolume当前暂不支持。
操作步骤
- 单个hostPath替换为emptyDir配置方式:
bursting.cci.io/hostpath-replacement: '[{"name":"source-hostpath-volume-3","policyType":"replaceByEmptyDir","emptyDir":{"sizeLimit":"10Gi"}}]'
- 单个hostPath忽略:
bursting.cci.io/hostpath-replacement: '[{"name":"source-hostpath-volume-1","policyType":"remove"}]'
- 全部HostPath都忽略:
bursting.cci.io/hostpath-replacement: '[{"name":"*","policyType":"remove"}]'
- 多个HostPath差异化替换策略:
bursting.cci.io/hostpath-replacement: '[{"name":"source-hostpath-volume-1","policyType":"remove"},{"name":"source-hostpath-volume-3","policyType":"replaceByEmptyDir","emptyDir":{"sizeLimit":"10Gi"}}]'
对于path为/etc/localtime的HostPath存储,会被单个HostPath替换的策略(策略name为具体的volume name)替换,不会被全部HostPath替换的策略(策略name为"*")替换。
参考deployment yaml示例:
apiVersion: apps/v1 kind: Deployment metadata: annotations: description: '' labels: bursting.cci.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: bursting.cci.io/hostpath-replacement: '[{"name": "test-log2", "policyType": "remove"}, {"name": "test-log", "policyType": "replaceByEmptyDir", "emptyDir":{"sizeLimit":"10Gi"}}, {"name": "test-log1", "policyType": "remove" }]' spec: containers: - name: container-1 image: nginx imagePullPolicy: IfNotPresent 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