您可以在金山云容器服务Kubernetes集群中使用金山云KFS存储卷。
目前,金山云提供两种kubernetes挂载方式:
静态存储卷
可以通过以下两种方式使用KFS文件存储静态存储卷:
动态存储卷
挂载文件系统(KFS)的前提是您有创建好的文件系统。如果您还未创建文件系统,您需要先创建文件系统。有关如何创建文件系统的详细信息,参见创建文件系统及挂载点
Kube-system
命名空间下disk-provisioner
组件,YAML见附录server:10.0.1.x
挂载路径:/share-2c51940a-6261-4044-addc-xxxxxxxx
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kfs
spec:
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: "kfs"
mountPath: "/data"
volumes:
- name: "kfs"
nfs:
server: "10.0.1.x"
path: "/share-2c51940a-6261-4044-addc-xxxxxxx"
创建PV:
apiVersion: v1
kind: PersistentVolume
metadata:
name: kfs-pv
spec:
storageClassName: "kfs"
capacity:
storage: 100Mi
accessModes:
- ReadWriteMany
mountOptions:
- nfsvers=3
nfs:
server: 10.0.1.x
path: "/share-2c51940a-6261-4044-addc-xxxxxxx"
创建PVC:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: kfs-pvc
spec:
storageClassName: "kfs"
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Mi
创建Deployment:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kfs-deploy
spec:
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: kfs
mountPath: "/data"
volumes:
- name: kfs
persistentVolumeClaim:
claimName: kfs-pvc
参数 | 说明 |
---|---|
server | 指定kfs服务器地址(必填) |
path | 指定kfs挂载目录 (必填,子目录不存在时可自动创建) |
archiveOnDelete | 表示删除PVC、PV时候,处理kfs子目录的方式:如果reclaimPolicy为Delete,且archiveOnDelete为false:会直接删除远端目录和数据,请谨慎使用。如果reclaimPolicy为Delete,且archiveOnDelete为true:会将远端的目录更新为其他名字备份。如果reclaimPolicy为Retain,远端的目录不作处理。(选填,默认为false) |
storageType | ksc/kfs,指定使用kfs存储(必填) |
创建Storageclass:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ksc-kfs
parameters:
server: 10.0.1.xx
path: /cfs-AyQaA3xxxx/test-path
archiveOnDelete: "false"
storageType: ksc/kfs
provisioner: ksc/storage
创建StatefulSet:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: test
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: www
mountPath: "/data"
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes:
- ReadWriteOnce
storageClassName: ksc-kfs
resources:
requests:
storage: 10Gi
apiVersion: apps/v1
kind: Deployment
metadata:
name: disk-provisioner
namespace: kube-system
spec:
selector:
matchLabels:
app: disk-provisioner
replicas: 1
revisionHistoryLimit: 2
template:
metadata:
labels:
app: disk-provisioner
spec:
dnsPolicy: Default
tolerations:
# this taint is set by all kubelets running `--cloud-provider=external`
- key: "node.cloudprovider.kubernetes.io/uninitialized"
value: "true"
effect: "NoSchedule"
containers:
- image: hub.kce.ksyun.com/ksyun/disk-provisioner:latest
name: ebs-provisioner
env:
- name: OPENAPI_ENDPOINT
value: "internal.api.ksyun.com"
- name: OPENAPI_PREFIX
value: "http"
volumeMounts:
- name: kubeconfig
mountPath: /root/.kube/config
- name: clusterinfo
mountPath: /opt/app-agent/arrangement/clusterinfo
- image: hub.kce.ksyun.com/ksyun/disk-provisioner:latest
name: ksc-storage-provisioner
securityContext:
privileged: true # do mount
args:
- --provisioner=ksc/storage
env:
- name: OPENAPI_ENDPOINT
value: "internal.api.ksyun.com"
- name: OPENAPI_PREFIX
value: "http"
volumeMounts:
- name: kubeconfig
mountPath: /root/.kube/config
- name: clusterinfo
mountPath: /opt/app-agent/arrangement/clusterinfo
volumes:
- name: kubeconfig
hostPath:
path: /root/.kube/config
- name: clusterinfo
hostPath:
path: /opt/app-agent/arrangement/clusterinfo
文档内容是否对您有帮助?
评价建议不能为空
非常感谢您的反馈,我们会继续努力做到更好!