创建sc,cm ,local-path插件
创建storageclass(cluster资源)
apiVersion : storage.k8s.io/v1
kind : StorageClass
metadata : annotations : defaultVolumeType : localname : base- local- path
provisioner : rancher.io/local- path
reclaimPolicy : Retain
volumeBindingMode : WaitForFirstConsumer
创建命名空间级别的configmap
apiVersion : v1
data : config.json : | - { "nodePathMap": [ { "node": "DEFAULT_PATH_FOR_NON_LISTED_NODES" , "paths": [ "/opt/local-path-zcy" ] } ] } helperPod.yaml : | - apiVersion : v1kind : Podmetadata : name : helper- podspec : containers : - name : helper- podimage : busyboximagePullPolicy : IfNotPresentsetup : | - set - eumkdir - m 0777 - p "$VOL_DIR"teardown : | - set - eurm - rf "$VOL_DIR"
kind : ConfigMap
metadata : name : local- path- confignamespace : middleware
配置 sa及clusterrolebinding
apiVersion : v1
kind : ServiceAccount
metadata : name : local- path- provisioner- service- accountnamespace : middleware
---
apiVersion : rbac.authorization.k8s.io/v1
kind : ClusterRoleBinding
metadata : name : local- path- provisioner- bind- bigdata
roleRef : apiGroup : rbac.authorization.k8s.iokind : ClusterRolename : local- path- provisioner- role
subjects :
- kind : ServiceAccountname : local- path- provisioner- service- accountnamespace : middleware
查看clusterrole(一般情况可共用)
apiVersion : rbac.authorization.k8s.io/v1
kind : ClusterRole
metadata : name : local- path- provisioner- role
rules :
- apiGroups : - "" resources : - nodes- persistentvolumeclaims- configmapsverbs : - get- list- watch
- apiGroups : - "" resources : - endpoints- persistentvolumes- podsverbs : - '*'
- apiGroups : - "" resources : - eventsverbs : - create- patch
- apiGroups : - storage.k8s.ioresources : - storageclassesverbs : - get- list- watch
创建local-path-provisioner
apiVersion : apps/v1
kind : Deployment
metadata : name : local- path- provisionernamespace : bigdata
spec : progressDeadlineSeconds : 600 replicas : 1 revisionHistoryLimit : 10 selector : matchLabels : app : local- path- provisionerstrategy : rollingUpdate : maxSurge : 25%maxUnavailable : 25%type : RollingUpdatetemplate : metadata : creationTimestamp : null labels : app : local- path- provisionerspec : containers : - command : - local- path- provisioner- - - debug- start- - - config- /etc/config/config.jsonenv : - name : POD_NAMESPACEvalueFrom : fieldRef : apiVersion : v1fieldPath : metadata.namespaceimage : rancher/local- path- provisioner: v0.0.24imagePullPolicy : IfNotPresentname : local- path- provisionerresources : { } terminationMessagePath : /dev/termination- logterminationMessagePolicy : FilevolumeMounts : - mountPath : /etc/config/name : config- volumednsPolicy : ClusterFirstrestartPolicy : AlwaysschedulerName : default- schedulersecurityContext : { } serviceAccount : local- path- provisioner- service- accountserviceAccountName : local- path- provisioner- service- accountterminationGracePeriodSeconds : 30 volumes : - configMap : defaultMode : 420 name : local- path- configname : config- volume