正确部署阿⾥csi-plugins-nas
如何使⽤阿⾥的csi-lugins的nas部分
⽂章⽬录
github地址,gitee也有很多拷贝
说明: CSI插件需要您的集版本⼤于1.14,且初始化集的时候选择使⽤CSI插件。或者⾃⾏配置节点kubelet参数,确保enable-controller-attach-detach为true。意思是由AD Controller来发起attach/detach请求,⽽不是kubelet发起。
1.创建serviceAccount
kubectl create -f xxx/alibaba-cloud-csi-driver/deploy/rbac.yaml
建议还不了解⼯作原理的可以先⽤下⾯的配置部署
# This YAML file contains all RBAC objects that are necessary to run external
# CSI provisioner.
#
# In production, each CSI driver deployment has to be customized:
# - to avoid conflicts, use non-default namespace and different names
# for non-namespaced entities like the ClusterRole
# - decide whether the deployment replicates the external CSI
# provisioner, in which case leadership election must be enabled;
# this influences the RBAC setup, see below
apiVersion: v1
kind: ServiceAccount
metadata:
name: csi-admin
# replace with the same namespace name with plugin
namespace: kube-system
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: alicloud-csi-plugin
rules:
-apiGroups:[""]
resources:["secrets"]
verbs:["get","list"]
-
apiGroups:[""]
resources:["persistentvolumes"]
verbs:["get","list","watch","update","create","delete","patch"]
-apiGroups:[""]
resources:["persistentvolumeclaims"]
verbs:["get","list","watch","update"]
-apiGroups:[""]
resources:["persistentvolumeclaims/status"]
verbs:["get","list","watch","update","patch"]
-apiGroups:["storage.k8s.io"]
resources:["storageclasses"]
verbs:["get","list","watch"]
-apiGroups:["storage.k8s.io"]
resources:["csinodes"]
verbs:["get","list","watch"]
-apiGroups:[""]
-apiGroups:[""]
resources:["events"]
verbs:["get","list","watch","create","update","patch"] -apiGroups:[""]
resources:["endpoints"]
verbs:["get","watch","list","delete","update","create"] -apiGroups:[""]
resources:["configmaps"]
verbs:["get","watch","list","delete","update","create"] -apiGroups:[""]
resources:["nodes"]
verbs:["get","list","watch"]
-apiGroups:["csi.storage.k8s.io"]
resources:["csinodeinfos"]
verbs:["get","list","watch"]
-apiGroups:["storage.k8s.io"]
resources:["volumeattachments"]
verbs:["get","list","watch","update","patch"]
-apiGroups:["snapshot.storage.k8s.io"]
resources:["volumesnapshotclasses"]
verbs:["get","list","watch"]
-apiGroups:["snapshot.storage.k8s.io"]
resources:["volumesnapshotcontents"]
verbs:["create","get","list","watch","update","delete"] -apiGroups:["snapshot.storage.k8s.io"]
resources:["volumesnapshots"]
verbs:["get","list","watch","update"]
-apiGroups:["apiextensions.k8s.io"]
resources:["customresourcedefinitions"]
verbs:["create","list","watch","delete","get","update"] -apiGroups:["coordination.k8s.io"]
resources:["leases"]
verbs:["get","create","list","watch","delete","update"] -apiGroups:["snapshot.storage.k8s.io"]
resources:["volumesnapshotcontents/status"] verbs:["update"]
-apiGroups:["storage.k8s.io"]
resources:["volumeattachments/status"]
verbs:["patch"]
-apiGroups:[""]
resources:["nodes"]
verbs:["get","list","watch"]
-apiGroups:["snapshot.storage.k8s.io"]
resources:["volumesnapshots/status"]
verbs:["update"]
-apiGroups:["storage.k8s.io"]
resources:["storageclasses"]
verbs:["get","list","watch"]
-apiGroups:[""]
resources:["namespaces"]
verbs:["get","list"]
-apiGroups:[""]
resources:["pods"]
verbs:["get","list","watch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: alicloud-csi-plugin
namespace: kube-system
subjects:
-kind: ServiceAccount
name: csi-admin
namespace: kube-system
roleRef:
kind: ClusterRole
kind: ClusterRole
name: alicloud-csi-plugin
apiGroup: rbac.authorization.k8s.io
2.容器部署csi-plugin
kubectl create -f xxx/alibaba-cloud-csi-driver/deploy/nas/nas-plugin.yaml
nas-plugin.yaml
apiVersion: storage.k8s.io/v1beta1
kind: CSIDriver
metadata:
name: nasplugin.csi.alibabacloud
spec:
attachRequired:false
podInfoOnMount:true
-
--
# This YAML defines all API objects to create RBAC roles for csi node plugin.
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: csi-plugin
namespace: kube-system
spec:
selector:
matchLabels:
app: csi-plugin
template:
metadata:
labels:
app: csi-plugin
spec:
tolerations:
-operator: Exists
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
-
matchExpressions:
-key: type
operator: NotIn
values:
- virtual-kubelet
nodeSelector:
beta.kubernetes.io/os: linux
serviceAccount: csi-admin
priorityClassName: system-node-critical
hostNetwork:true
hostPID:true
containers:
-name: nas-driver-registrar
image: registry-hangzhou.aliyuncs/acs/csi-node-driver-registrar:v1.2.0
imagePullPolicy: Always
args:
-"--v=5"
-"--csi-address=/var/lib/kubelet/csi-plugins/nasplugin.csi.alibabacloud/csi.sock"
-"--kubelet-registration-path=/var/lib/kubelet/csi-plugins/nasplugin.csi.alibabacloud/csi.sock"
volumeMounts:
-name: kubelet-dir
mountPath: /var/lib/kubelet/
-
name: registration-dir
mountPath: /registration
-name: csi-plugin
securityContext:
privileged:true
add:["SYS_ADMIN"]
allowPrivilegeEscalation:true
image: registry-hangzhou.aliyuncs/acs/csi-plugin:v1.16.9.43-f36bb540-aliyun imagePullPolicy:"Always"
args:
-"--endpoint=$(CSI_ENDPOINT)"
-"--v=2"
-"--driver=nas"
env:
-name: KUBE_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: deName
-name: CSI_ENDPOINT
value: unix://var/lib/kubelet/csi-plugins/driverplugin.csi.alibabacloud-replace/csi.sock -name: MAX_VOLUMES_PERNODE
value:"15"
-name: SERVICE_TYPE
value:"plugin"
livenessProbe:
httpGet:
path: /healthz
port: healthz
scheme: HTTP
initialDelaySeconds:10
periodSeconds:30
timeoutSeconds:5
failureThreshold:5
ports:
-
name: healthz
containerPort:11260
protocol: TCP
volumeMounts:
-name: kubelet-dir
mountPath: /var/lib/kubelet/
mountPropagation:"Bidirectional"
-name: etc
mountPath: /host/etc
-name: host-log
mountPath: /var/log/
-
name: container-dir
mountPath: /var/lib/container
mountPropagation:"Bidirectional"
nodeselector-name: host-dev
mountPath: /dev
mountPropagation:"HostToContainer"
volumes:
-name: registration-dir
hostPath:
path: /var/lib/kubelet/plugins_registry
type: DirectoryOrCreate
-
name: container-dir
hostPath:
path: /var/lib/container
type: DirectoryOrCreate
-name: kubelet-dir
hostPath:
path: /var/lib/kubelet
type: Directory
-name: host-dev
hostPath:
path: /dev
-
name: host-log
path: /var/log/
-name: etc
hostPath:
path: /etc
updateStrategy:
rollingUpdate:
maxUnavailable: 10%
type: RollingUpdate
nas-provisioner.yaml
kubectl create -f xxx/alibaba-cloud-csi-driver/deploy/nas/nas-provisioner.yaml
kind: Service
apiVersion: v1
metadata:
name: csi-provisioner
namespace: kube-system
labels:
app: csi-provisioner
spec:
selector:
app: csi-provisioner
ports:
-
name: dummy
port:12345
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: csi-provisioner
namespace: kube-system
spec:
selector:
matchLabels:
app: csi-provisioner
replicas:2
template:
metadata:
labels:
app: csi-provisioner
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
-weight:1
preference:
matchExpressions:
-key: node-role.kubernetes.io/master
operator: Exists
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
-matchExpressions:
-key: type
operator: NotIn
values:
- virtual-kubelet
tolerations:
-effect: NoSchedule
operator: Exists
key: node-role.kubernetes.io/master
-effect: NoSchedule
operator: Exists
key: node.cloudprovider.kubernetes.io/uninitialized
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论