Kubernetes指南
Linux性能优化实战eBPF 核心技术与实战SDN指南个人博客
EN
EN
  • Overview
  • Introduction
    • Kubernetes Introduction
    • Kubernetes Concepts
    • Kubernetes 101
    • Kubernetes 201
    • Kubernetes Cluster
  • Concepts
    • Concepts
    • Architecture
    • Design Principles
    • Components
      • etcd
      • kube-apiserver
      • kube-scheduler
      • kube-controller-manager
      • kubelet
      • kube-proxy
      • kube-dns
      • Federation
      • kubeadm
      • hyperkube
      • kubectl
    • Objects
      • Autoscaling
      • ConfigMap
      • CronJob
      • CustomResourceDefinition
      • DaemonSet
      • Deployment
      • Ingress
      • Job
      • LocalVolume
      • Namespace
      • NetworkPolicy
      • Node
      • PersistentVolume
      • Pod
      • PodPreset
      • ReplicaSet
      • Resource Quota
      • Secret
      • SecurityContext
      • Service
      • ServiceAccount
      • StatefulSet
      • Volume
  • Setup
    • Setup Guidance
    • kubectl Install
    • Single Machine
    • Feature Gates
    • Best Practice
    • Version Support
    • Setup Cluster
      • kubeadm
      • kops
      • Kubespray
      • Azure
      • Windows
      • LinuxKit
      • kubeasz
    • Setup Addons
      • Addon-manager
      • DNS
      • Dashboard
      • Monitoring
      • Logging
      • Metrics
      • GPU
      • Cluster Autoscaler
      • ip-masq-agent
  • Extension
    • API Extension
      • Aggregation
      • CustomResourceDefinition
    • Access Control
      • Authentication
      • RBAC Authz
      • Admission
    • Scheduler Extension
    • Network Plugin
      • CNI
      • Flannel
      • Calico
      • Weave
      • Cilium
      • OVN
      • Contiv
      • SR-IOV
      • Romana
      • OpenContrail
      • Kuryr
    • Container Runtime
      • CRI-tools
      • Frakti
    • Storage Driver
      • CSI
      • FlexVolume
      • glusterfs
    • Network Policy
    • Ingress Controller
      • Ingress + Letsencrypt
      • minikube Ingress
      • Traefik Ingress
      • Keepalived-VIP
    • Cloud Provider
    • Device Plugin
  • Cloud Native Apps
    • Apps Management
      • Patterns
      • Rolling Update
      • Helm
      • Operator
      • Service Mesh
      • Linkerd
      • Linkerd2
    • Istio
      • Deploy
      • Traffic Management
      • Security
      • Policy
      • Metrics
      • Troubleshooting
      • Community
    • Devops
      • Draft
      • Jenkins X
      • Spinnaker
      • Kompose
      • Skaffold
      • Argo
      • Flux GitOps
  • Practices
    • Overview
    • Resource Management
    • Cluster HA
    • Workload HA
    • Debugging
    • Portmap
    • Portforward
    • User Management
    • GPU
    • HugePage
    • Security
    • Audit
    • Backup
    • Cert Rotation
    • Large Cluster
    • Big Data
      • Spark
      • Tensorflow
    • Serverless
  • Troubleshooting
    • Overview
    • Cluster Troubleshooting
    • Pod Troubleshooting
    • Network Troubleshooting
    • PV Troubleshooting
      • AzureDisk
      • AzureFile
    • Windows Troubleshooting
    • Cloud Platform Troubleshooting
      • Azure
    • Troubleshooting Tools
  • Community
    • Development Guide
    • Unit Test and Integration Test
    • Community Contribution
  • Appendix
    • Ecosystem
    • Learning Resources
    • Domestic Mirrors
    • How to Contribute
    • Reference Documents
由 GitBook 提供支持
在本页
  • The Principles
  • Configuration
  • Example
  • Reference Documents
  1. Extension
  2. Storage Driver

CSI

The Container Storage Interface (CSI) first made its appearance in Kubernetes v1.9 and reached General Availability (GA) in version v1.13. CSI is not just tethered to Kubernetes—it's a universal storage interface for the container ecosystem, compatible with other container orchestration systems like Mesos and Cloud Foundry.

Version information

Kubernetes
CSI Spec
Status

v1.9

v0.1.0

Alpha

v1.10

v0.2.0

Beta

v1.11-v1.12

v0.3.0

Beta

v1.13

GA

Sidecar container versions

Container Name
Description
CSI spec
Latest Release Tag

external-provisioner

Watch PVC and create PV

v1.0.0

v1.0.1

external-attacher

Operate VolumeAttachment

v1.0.0

v1.0.1

external-snapshotter

Operate VolumeSnapshot

v1.0.0

v1.0.1

node-driver-registrar

Register kubelet plugin

v1.0.0

v1.0.2

cluster-driver-registrar

v1.0.0

v1.0.1

livenessprobe

Monitors health of CSI driver

v1.0.0

v1.0.2

The Principles

Similar to CRI, CSI is implemented based on gRPC. The detailed CSI SPEC can be referred to here. It requires plugin developers to implement three gRPC services:

  • Identity Service: For Kubernetes to coordinate version information with CSI plugin

  • Controller Service: For creating, deleting, and managing Volume storage

  • Node Service: For mounting the Volume storage to a specified directory for Kubelet to use when creating containers (must listen on /var/lib/kubelet/plugins/[SanitizedCSIDriverName]/csi.sock)

Since CSI listens on a Unix socket file, kube-controller-manager can't directly call the CSI plugin. To manage the lifecycle of Volumes and to simplify the development of CSI plugins for developers, Kubernetes provides several sidecar containers and recommends deploying CSI plugins using the following method:

This deployment method includes:

  • StatefulSet: Ensuring only one instance is running with a replica number of 1, it contains three containers:

    • The CSI plugin implemented by the user

    • External Attacher: A sidecar container provided by Kubernetes. It listens for changes in VolumeAttachment and PersistentVolume objects and calls the CSI plugin's ControllerPublishVolume and ControllerUnpublishVolume APIs to mount or unmount the Volume to the specified Node.

    • External Provisioner: A sidecar container provided by Kubernetes. It listens for changes in PersistentVolumeClaim objects and calls APIs like ControllerPublish and ControllerUnpublish of the CSI plugin to manage Volumes.

  • Daemonset: Runs the CSI plugin on every Node so that Kubelet can call it. It contains 2 containers:

    • The CSI plugin implemented by the user

    • Driver Registrar: Registers the CSI plugin with kubelet and initiates the NodeId (i.e., adds an Annotation csi.volume.kubernetes.io/nodeid to the Node object)

Configuration

  • API Server configuration:

--allow-privileged=true
--feature-gates=CSIPersistentVolume=true,MountPropagation=true
--runtime-config=storage.k8s.io/v1alpha1=true
  • Controller-manager configuration:

--feature-gates=CSIPersistentVolume=true
  • Kubelet configuration:

--allow-privileged=true
--feature-gates=CSIPersistentVolume=true,MountPropagation=true

Example

Kubernetes provides several CSI examples, including NFS, iSCSI, HostPath, Cinder, and FlexAdapter, among others. These examples can be used as references when creating a CSI plugin.

Name
Status
More Information

v0.2.0

A Container Storage Interface (CSI) Storage Plug-in for Cinder

... and more

Let's look at the usage of a CSI plugin, using NFS as an example.

First, you need to deploy the NFS plugin:

git clone https://github.com/kubernetes-csi/drivers
cd drivers/pkg/nfs
kubectl create -f deploy/kubernetes

Then create a container using an NFS storage volume:

kubectl create -f examples/kubernetes/nginx.yaml

The example directly creates a PV to use NFS:

apiVersion: v1
kind: PersistentVolume
...

You can also use it with StorageClass:

kind: StorageClass
...

Reference Documents

  • Kubernetes CSI Documentation

  • CSI Volume Plugins in Kubernetes Design Doc

上一页Storage Driver下一页FlexVolume

最后更新于1年前

,

Register

v0.3.0
v1.0.0
CSIDriver Object
Cinder
Recommended CSI Deployment Diagram