ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

k8s存储管理

2021-07-01 20:52:04  阅读:209  来源: 互联网

标签:存储管理 name storage client nfs provisioner k8s


存储管理 一.nfs搭建 yum install infs-utils -y rpcbind mkdir -p /data/k8s-volume chmod 755 /data/k8s-volume cat >>/etc/exports <<EOF /data/k8s-volume *(rw,no_root_squash,sync) EOF   二.注意需要在客户端安装nfs,才能正常   三.我们需要配置nfs-client的Deployment文件
kind: Deployment
apiVersion: apps/v1
metadata:
  name: nfs-client-provisioner
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nfs-client-provisioner
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: nfs-client-provisioner
    spec:
      serviceAccountName: nfs-client-provisioner
      containers:
        - name: nfs-client-provisioner
          image: quay.io/external_storage/nfs-client-provisioner:latest
          volumeMounts:
            - name: nfs-client-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: fuseim.pri/ifs
            - name: NFS_SERVER
              value: 10.206.16.4           #nfs server 地址
            - name: NFS_PATH
              value: /data/k8s-volume     #nfs共享目录
      volumes:
        - name: nfs-client-root
          nfs:
            server: 10.206.16.4
            path: /data/k8s-volume
四.创建serviceAccount
apiVersion: v1
kind: ServiceAccount
metadata:
  name: nfs-client-provisioner
 
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: nfs-client-provisioner-runner
rules:
  - apiGroups: [""]
    resources: ["persistentvolumes"]
    verbs: ["get", "list", "watch", "create", "delete"]
  - apiGroups: [""]
    resources: ["persistentvolumeclaims"]
    verbs: ["get", "list", "watch", "update"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["storageclasses"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["list", "watch", "create", "update", "patch"]
  - apiGroups: [""]
    resources: ["endpoints"]
    verbs: ["create", "delete", "get", "list", "watch", "patch", "update"]
 
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: run-nfs-client-provisioner
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    namespace: default
roleRef:
  kind: ClusterRole
  name: nfs-client-provisioner-runner
  apiGroup: rbac.authorization.k8s.io
五.声明storageclass对象
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: managed-nfs-storage
provisioner: fuseim.pri/ifs # or choose another name, must match deployment's env PROVISIONER_NAME'
六.创建对象 kubectl apply -f .   七.pvc申请存储
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: test-claim
  annotations:
    volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"    #storageclass 名称
spec:
  accessModes:              #访问模式
    - ReadWriteMany
  resources:
    requests:
      storage: 1024Mi              #请求
八.查看效果
[root@k8s-master-01 dynamic]# kubectl get pvc|grep test
test-claim   Bound    pvc-d2719003-188b-4d1e-a212-db0b35435630   1Gi        RWX            managed-nfs-storage   14m
[root@k8s-master-01 dynamic]# kubectl get pv|grep test
pvc-d2719003-188b-4d1e-a212-db0b35435630   1Gi        RWX            Delete           Bound    default/test-claim   managed-nfs-storage            12m


标签:存储管理,name,storage,client,nfs,provisioner,k8s
来源: https://blog.51cto.com/luoguoling/2966225

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有