首页 > 其他分享 >local-path-provisioner

local-path-provisioner

时间:2023-12-25 15:12:24浏览次数:23  
标签:kind name storage provisioner path local

参考Github:https://github.com/rancher/local-path-provisioner

1.部署

1.1.创建local-path-provisioner

官网默认路径:/opt/local-path-provisioner

# 创建资源
kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.26/deploy/local-path-storage.yaml

注:这里目录当pod启动时会自动创建。

1.2.测试local-path-provisioner

创建pvc

cat > local-path-pvc.yaml <<EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: local-path-pvc
  namespace: default
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: local-path
  resources:
    requests:
      storage: 2Gi
EOF
cat local-path-pvc.yaml | kubectl apply -f -
​
kubectl get pvc | grep local-path-pvc
local-path-pvc                   Pending                                                                        local-path     108s

创建pod

cat > local-path-pod.yaml <<EOF
apiVersion: v1
kind: Pod
metadata:
  name: local-path-pod
  namespace: default
spec:
  containers:
  - name: volume-test
    image: nginx:stable-alpine
    imagePullPolicy: IfNotPresent
    volumeMounts:
    - name: volv
      mountPath: /data
    ports:
    - containerPort: 80
  volumes:
  - name: volv
    persistentVolumeClaim:
      claimName: local-path-pvc
EOF
cat local-path-pod.yaml | kubectl apply -f -

查看创建资源:

kubectl get pvc,pod | grep loca
persistentvolumeclaim/local-path-pvc                   Bound    pvc-102f516d-f0e7-49e8-a308-18674655ba88   2Gi        RWO            local-path     5m50s
pod/local-path-pod                           1/1     Running   0               24s

附件:

local-path-storage.yaml

local-path-storage.yaml
 # https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.26/deploy/local-path-storage.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: local-path-storage
​
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: local-path-provisioner-service-account
  namespace: local-path-storage
​
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: local-path-provisioner-role
  namespace: local-path-storage
rules:
  - apiGroups: [""]
    resources: ["pods"]
    verbs: ["get", "list", "watch", "create", "patch", "update", "delete"]
​
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: local-path-provisioner-role
rules:
  - apiGroups: [""]
    resources: ["nodes", "persistentvolumeclaims", "configmaps", "pods", "pods/log"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["persistentvolumes"]
    verbs: ["get", "list", "watch", "create", "patch", "update", "delete"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["create", "patch"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["storageclasses"]
    verbs: ["get", "list", "watch"]
​
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: local-path-provisioner-bind
  namespace: local-path-storage
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: local-path-provisioner-role
subjects:
  - kind: ServiceAccount
    name: local-path-provisioner-service-account
    namespace: local-path-storage
​
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: local-path-provisioner-bind
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: local-path-provisioner-role
subjects:
  - kind: ServiceAccount
    name: local-path-provisioner-service-account
    namespace: local-path-storage
​
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: local-path-provisioner
  namespace: local-path-storage
spec:
  replicas: 1
  selector:
    matchLabels:
      app: local-path-provisioner
  template:
    metadata:
      labels:
        app: local-path-provisioner
    spec:
      serviceAccountName: local-path-provisioner-service-account
      containers:
        - name: local-path-provisioner
          image: rancher/local-path-provisioner:v0.0.26
          imagePullPolicy: IfNotPresent
          command:
            - local-path-provisioner
            - --debug
            - start
            - --config
            - /etc/config/config.json
          volumeMounts:
            - name: config-volume
              mountPath: /etc/config/
          env:
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
      volumes:
        - name: config-volume
          configMap:
            name: local-path-config
​
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-path
provisioner: rancher.io/local-path
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Delete
​
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: local-path-config
  namespace: local-path-storage
data:
  config.json: |-
    {
            "nodePathMap":[
            {
                    "node":"DEFAULT_PATH_FOR_NON_LISTED_NODES",
                    "paths":["/opt/local-path-provisioner"]
            }
            ]
    }
  setup: |-
    #!/bin/sh
    set -eu
    mkdir -m 0777 -p "$VOL_DIR"
  teardown: |-
    #!/bin/sh
    set -eu
    rm -rf "$VOL_DIR"
  helperPod.yaml: |-
    apiVersion: v1
    kind: Pod
    metadata:
      name: helper-pod
    spec:
      priorityClassName: system-node-critical
      tolerations:
        - key: node.kubernetes.io/disk-pressure
          operator: Exists
          effect: NoSchedule
      containers:
      - name: helper-pod
        image: busybox
        imagePullPolicy: IfNotPresent

标签:kind,name,storage,provisioner,path,local
From: https://www.cnblogs.com/-k8s/p/17926131.html

相关文章

  • ThreadLocal是什么?有哪些应用场景?
    大家好,我是joker,希望你快乐。多线程情况下操作共享变量会产生线程安全问题,需要进行线程间同步,但是并不是所有的情况都是多线程去操作共享变量,有些线程是无状态的只进行操作处理,不涉及共享数据操作,所以就需要threadlocal登场了。threadlocal是什么?threadlocal根据命名来看,分为两......
  • JSONPATH-阿里和jayway的实现测试
    业务业务的需要,所以想找一个从对象中获取属性的工具。搜了搜发现由阿里和jayway的实现,又花费了一些时间了解和练习,总结了一些要点:阿里的可能快一些,但考虑到完备性,也许选择jayway更好一些。本文档参考了以下URL:JaywayJsonPath介绍_com.jayway.jsonpath-CSDN博客FASTJSON2JSO......
  • Spring工具类--路径匹配(AntPathMatcher)--使用/实例
    原文网址:Spring工具类--路径匹配(AntPathMatcher)--使用/实例_IT利刃出鞘的博客-CSDN博客简介整个Spring(SpringBoot)框架的路径解析都是按照Ant的风格来的,比如:Controller的请求路径、文件路径、包的路径。所以,掌握Ant的路径匹配很重要。Spring中的具体实现:org.springframewor......
  • 请求参数之@PathVariable与@PathParam
    初学springmvc容易分不清楚这两个参数之间的用法差别,如果较长一段时间不接触,可能又会搞忘,贴个笔记,方便以后回顾以及初学者参考。如有错误,还请指正。@PathVariable:@PathVariable适用于RESTFULL风格的请求。例://请求样式为restfulhttp://localhost:8080/user/张三@Ge......
  • Longest Path
    每个点肯定是它上个点转移过来的#include<bits/stdc++.h>usingnamespacestd;constintN=1e5+10;vector<int>a[N];intd[N],dp[N];voidsolve(){ intn,m; cin>>n>>m; for(inti=1;i<=m;i++){ intu,v; cin>>u>>v; a[u].push_back(v......
  • 11月25日,RPA 学习天地基于UiPath产品公开课,圆满结束,帮助学员掌握RPA能力!
    11月25日,RPA学习天地在UiPath产品的公开课上,成功地帮助学员们掌握了RPA(RoboticProcessAutomation)的能力。这堂课程通过深入浅出的讲解,让学员们了解到了RPA的原理和应用场景,以及如何利用UiPath的产品进行流程设计和自动化执行。在这次公开课中,RPA学习天地的讲师们运用生动的案......
  • A novel local-global dependency deep learning model for soil mapping
    程哥的一区文章“Anovellocal-globaldependencydeeplearningmodelforsoilmapping”(Li和Zhang,2022,pp.-)(pdf)研究问题:“工程“discrete”特征不能反映环境协变量之间的相互作用或依赖关系”(pdf)预测的对象是土壤质地的预测。属于step1里面的对于......
  • ThreadLocal和InheritableThreadLocal详解,基本原理及注意项 父子线程数据共享
    一、ThreadLocal介绍在多线程环境下访问同一个线程的时候会出现并发问题,特别是多个线程同时对一个变量进行写入操作时,为了保证线程的安全,通常会进行加锁来保证线程的安全,但是加锁又会造成效率的降低;ThreadLocal是jdk提供的除了加锁之外保证线程安全的方法,其实现原理是在Thread类......
  • 常用xpath选择器和css选择器总结
    xpath选择器表达式说明article选取所有article元素的所有子节点/article选取根元素articlearticle/a选取所有属于article的子元素的a元素//div选取所有div子元素(不论出现在文档任何地方)article//div选取所有属于article元素的后代的div元素,不管它出现在ar......
  • LocalSend v1.8.0 开源跨平台的局域网文件传输工具中文版
    LocalSend下载官网地址:https://localsend.org/#/download包管理器使用终端安装。Winget:> wingetinstalllocalsendChocolatey:> chocoinstalllocalsendScoop:> scoopbucketaddextras;scoopinstalllocalsendLocalSend一款开源支持全平台的局域网文......