Kubernetes配置多个local-path-provisioner
Posted styshoo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Kubernetes配置多个local-path-provisioner相关的知识,希望对你有一定的参考价值。
背景
常规的本地卷,一般使用hostpath和local volume,但hostpath问题较多( 参考),而local volume布置成动态卷,使用起来较为复杂。因此,rancher开发了 local-path,可以实现动态卷功能。
但如果想实现IO隔离,就需要一套Kubernetes环境下部署多个local-path-provisioner。
配置
local-path-provisioner可设置环境变量PROVISIONER_NAME,只要该环境变量的值,与新创建local-path的存储类中的provisioner值一致即可。
apiVersion: v1
kind: Namespace
metadata:
name: local-path-storage
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: local-path-provisioner-service-account-new
namespace: local-path-storage
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: local-path-provisioner-role-new
rules:
- apiGroups: [""]
resources: ["nodes", "persistentvolumeclaims"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["endpoints", "persistentvolumes", "pods"]
verbs: ["*"]
- apiGroups: [""]
resources: ["events"]
verbs: ["create", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: local-path-provisioner-bind-new
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: local-path-provisioner-role-new
subjects:
- kind: ServiceAccount
name: local-path-provisioner-service-account-new
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-new
containers:
- name: local-path-provisioner
image: rancher/local-path-provisioner:v0.0.17
imagePullPolicy: IfNotPresent
command:
- local-path-provisioner
- --debug
- start
- --config
- /etc/config/config.json
- --helper-image
- busybox
volumeMounts:
- name: config-volume
mountPath: /etc/config/
env:
- name: PROVISIONER_NAME
value: "provisioner-new"
- 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-new
provisioner: provisioner-new
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Retain
---
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
path=$1
mkdir -m 0777 -p $path
teardown: |-
#!/bin/sh
path=$1
rm -rf $path
以上是关于Kubernetes配置多个local-path-provisioner的主要内容,如果未能解决你的问题,请参考以下文章
正在使用 Kubernetes Spring Cloud 多个配置映射
spring boot cloud kubernetes 配置不适用于多个 pod