kubernetes-csi / external-attacher

Sidecar container that watches Kubernetes VolumeAttachment objects and triggers ControllerPublish/Unpublish against a CSI endpoint
Apache License 2.0
161 stars 176 forks source link
k8s-sig-storage

CSI attacher

The external-attacher is a sidecar container that attaches volumes to nodes by calling ControllerPublish and ControllerUnpublish functions of CSI drivers. It is necessary because internal Attach/Detach controller running in Kubernetes controller-manager does not have any direct interfaces to CSI drivers.

Terminology

In Kubernetes, the term attach means 3rd party volume attachment to a node. This is common in cloud environments, where the cloud API is able to attach a volume to a node without any code running on the node. In CSI terminology, this corresponds to the ControllerPublish call.

Detach is the reverse operation, 3rd party volume detachment from a node, ControllerUnpublish in CSI terminology.

It is not an attach/detach operation performed by a code running on a node, such as an attachment of iSCSI or Fibre Channel volumes. These are typically performed during NodeStage and NodeUnstage CSI calls and are not done by the external-attacher.

Overview

The external-attacher is an external controller that monitors VolumeAttachment objects created by controller-manager and attaches/detaches volumes to/from nodes (i.e. calls ControllerPublish/ControllerUnpublish. Full design can be found at Kubernetes proposal at container-storage-interface.md

Compatibility

This information reflects the head of this branch.

Compatible with CSI Version Container Image Min K8s Version Recommended K8s Version
CSI Spec v1.5.0 registry.k8s.io/sig-storage/csi-attacher 1.17 1.22

Feature Status

Various external-attacher releases come with different alpha / beta features.

The following table reflects the head of this branch.

Feature Status Default Description
CSIMigration* GA On Migrating in-tree volume plugins to CSI.
ReadWriteOncePod* Alpha Off Single pod access mode for PersistentVolumes.

*) There is no special feature gate for this feature. It is enabled by turning on the corresponding features in Kubernetes.

All other external-attacher features and the external-attacher itself is considered GA and fully supported.

Usage

It is necessary to create a new service account and give it enough privileges to run the external-attacher, see deploy/kubernetes/rbac.yaml. The attacher is then deployed as single Deployment as illustrated below:

kubectl create deploy/kubernetes/deployment.yaml

The external-attacher may run in the same pod with other external CSI controllers such as the external-provisioner, external-snapshotter and/or external-resizer.

Note that the external-attacher does not scale with more replicas. Only one external-attacher is elected as leader and running. The others are waiting for the leader to die. They re-elect a new active leader in ~15 seconds after death of the old leader.

Command line options

Important optional arguments that are highly recommended to be used

Other recognized arguments

CSI error and timeout handling

The external-attacher invokes all gRPC calls to CSI driver with timeout provided by --timeout command line argument (15 seconds by default).

Correct timeout value depends on the storage backend and how quickly it is able to processes ControllerPublish and ControllerUnpublish calls. The value should be set to accommodate majority of them. It is fine if some calls time out - such calls will be re-tried after exponential backoff (starting with --retry-interval-start), however, this backoff will introduce delay when the call times out several times for a single volume (up to --retry-interval-max).

Periodic re-sync

When CSI driver supports LIST_VOLUMES and LIST_VOLUMES_PUBLISHED_NODES capabilities, the external attacher periodically syncs volume attachments requested by Kubernetes with the actual state reported by CSI driver. Volumes detached by any 3rd party, but still required to be attached by Kubernetes, will be re-attached back. Frequency of this re-sync is controlled by --reconcile-sync command line parameter.

HTTP endpoint

The external-attacher optionally exposes an HTTP endpoint at address:port specified by --http-endpoint argument. When set, these two paths are exposed:

Community, discussion, contribution, and support

Learn how to engage with the Kubernetes community on the community page.

You can reach the maintainers of this project at:

Code of conduct

Participation in the Kubernetes community is governed by the Kubernetes Code of Conduct.