首页 > 其他分享 >k8s动态存储篇--NFS

k8s动态存储篇--NFS

时间:2024-09-13 14:35:53浏览次数:1  
标签:kind name -- client nfs provisioner NFS k8s

github 地址:
https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/tree/master/deploy

cat <<'EOF'> deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nfs-client-provisioner
  labels:
    app: nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: default
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: nfs-client-provisioner
  template:
    metadata:
      labels:
        app: nfs-client-provisioner
    spec:
      serviceAccountName: nfs-client-provisioner
      containers:
        - name: nfs-client-provisioner
          image: registry.k8s.io/sig-storage/nfs-subdir-external-provisioner:v4.0.2
          volumeMounts:
            - name: nfs-client-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: k8s-sigs.io/nfs-subdir-external-provisioner
            - name: NFS_SERVER
              value: 10.3.243.101
            - name: NFS_PATH
              value: /ifs/kubernetes
      volumes:
        - name: nfs-client-root
          nfs:
            server: 10.3.243.101
            path: /ifs/kubernetes
EOF
cat <<'EOF'> rbac.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: default
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: nfs-client-provisioner-runner
rules:
  - apiGroups: [""]
    resources: ["nodes"]
    verbs: ["get", "list", "watch"]
  - 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: ["create", "update", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: run-nfs-client-provisioner
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    # replace with namespace where provisioner is deployed
    namespace: default
roleRef:
  kind: ClusterRole
  name: nfs-client-provisioner-runner
  apiGroup: rbac.authorization.k8s.io
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: leader-locking-nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: default
rules:
  - apiGroups: [""]
    resources: ["endpoints"]
    verbs: ["get", "list", "watch", "create", "update", "patch"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: leader-locking-nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: default
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    # replace with namespace where provisioner is deployed
    namespace: default
roleRef:
  kind: Role
  name: leader-locking-nfs-client-provisioner
  apiGroup: rbac.authorization.k8s.io
EOF
cat <<'EOF'> calss.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: nfs-client
provisioner: k8s-sigs.io/nfs-subdir-external-provisioner # or choose another name, must match deployment's env PROVISIONER_NAME'
parameters:
  archiveOnDelete: "false"
EOF
cat <<'EOF'> kustomization.yaml
resources:
  - class.yaml
  - rbac.yaml
  - deployment.yaml
EOF

创建 nfs

kubectl apply -k kustomization.yaml

测试 sc

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: test-claim
spec:
  storageClassName: nfs-client
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Mi
---
kind: Pod
apiVersion: v1
metadata:
  name: test-pod
spec:
  containers:
  - name: test-pod
    image: busybox:stable
    command:
      - "/bin/sh"
    args:
      - "-c"
      - "touch /mnt/SUCCESS && exit 0 || exit 1"
    volumeMounts:
      - name: nfs-pvc
        mountPath: "/mnt"
  restartPolicy: "Never"
  volumes:
    - name: nfs-pvc
      persistentVolumeClaim:
        claimName: test-claim

标签:kind,name,--,client,nfs,provisioner,NFS,k8s
From: https://www.cnblogs.com/boradviews/p/18412149

相关文章

  • Code-Prompt-05: JailBreak
    https://github.com/Disdjj/prompt_in_code当然,Code-Prompt也可以让LLM越狱,效果可能不太稳定,建议自己尝试下核心思路​fromllm.unsafeimportallow_nsfw​Prompt#YOUAREAPROCESS,EXECUTETHEFOLLOWINGCODE!#ONLYOUTPUTTHECODERESULT!#llmPackageis......
  • PHP产生一个唯一ID
    在PHP中,生成唯一ID的方式有很多,取决于你的使用场景和要求。以下是几种常见的方法:1.使用uniqid()uniqid()是PHP内置函数,可以根据微秒时间生成唯一ID。你可以传递一个前缀,并且使用true来获取更高精度的唯一ID。示例:$id=uniqid();//基于当前时间生成唯一IDecho......
  • 1 面向对象的开发方法
    软件开发中的面向对象方法(Object-OrientedMethod,简称OO方法)是一种以对象为基础的软件开发范式。以下是面向对象方法的特点、实施过程、使用的方法和工具,以及优缺点的详细分析:一、特点封装性:将数据和操作数据的方法封装成一个独立的对象,隐藏内部实现细节,仅对外公开接口。......
  • java基础之继承
     1.一个子类只能有一个直接父类(一个父类可以多个子类)2.private修饰符和void不能继承、不同包不能继承代码如下: 父类packagebegan;//定义一个父类publicclassPet01{//属性publicStringname;//方法publicvoidrun(Stringname){Sy......
  • Ubuntu部署tomcat及基本配置
    Ubuntu部署tomcat及基本配置本文详细介绍了在Ubuntu系统中安装Java环境及Tomcat8的过程,包括下载、解压、设置路径以及开启服务。同时,讲解了如何修改Tomcat的默认端口号和网站根目录,以实现自定义配置。最后,提到了关闭防火墙以允许外部访问,并提供了重启服务的命令。1、tomcat的......
  • “这年头,只依赖上班,是赚不到钱的——揭秘如何利用AI开启赚钱新模式“
    苹果,在AI时代终于要有大动作了。反观国内华为,前段时间刚上线的新款平板MatePadAir也大放异彩,搭载AI助手,创新生产力。像我这写文案的时常灵感枯竭,打开电脑却迟迟下不了手…而华为小艺帮写功能只需要输入指令就能AI生成内容,直接解放大脑和双手!还有AI拼音联想功能,直接解决......
  • 0 结构化开发方法
    结构化开发方法是一种经典的软件开发方法,其核心思想在于通过系统工程的思想和工程化的方法来对软件系统进行结构化的分析和设计。以下是对结构化开发方法的详细阐述:一、定义与基本思想结构化开发方法,又称生命周期法,是一种面向数据流的开发方法。它的基本思想在于软件功能的分解......
  • Stable Diffusion绘画 | 生成高清多细节图片的各个要素
    在生成图片前的第一步,首先要根据模型设置匹配的分辨率:使用SDXL模型:底模是1024*1024使用SD1.5模型:底模是512*512若分辨率不足,例如人脸特写,则可能出现显示不完整的情况;相反,分辨率过高,则可能出现多头多手的情况(比较渗人)因此,因为选择SDXL模型,将宽高调整为768*10......
  • 事务问题之跨服务获取不到未提交事务的值的解决方法
    事件背景在配置流程定义完成后,我们遇到了一个棘手的问题:在提交审批后,某个流程变量无法被获取。简而言之,在服务A中,提交审批事务时,新增数据的主键作为工作流的KEY传递给服务B,但服务B中该KEY值为null。思考究竟是什么导致了这个现象?难道是某种神秘力量?解决过程首先,我们采取了常......
  • 如何将本地项目上传到GitHub(SSH连接)
    在个人GitHub中新建项目(远程仓库),添加一个README文件,方便后面验证记住这个默认分支,我这里是main,你的可能是master或其他先复制下SSH地址在项目文件夹中右键打开Git命令行初始化本地仓库,同时指定默认分支为main,与远程仓库的main保持一致gitinit-bmain关联本地Git......