Skip to content

pragkent/aliyun-disk

Repository files navigation

aliyun-disk

Build Status

Aliyun Disk Kubernetes FlexVolume Driver

Usage

  1. Copy aliyun-disk binary to kubelet volume plugin directory. (/usr/libexec/kubernetes/kubelet-plugins/volume/exec/pragkent.me~aliyun-disk)
  2. Add four env variables to kube-controller-manager:
  • ALIYUN_ACCESS_KEY
  • ALIYUN_ACCESS_SECRET
  • ALIYUN_REGION
  • ALIYUN_CLUSTER

Install

To install, use go get:

$ go get github.com/pragkent/aliyun-disk

Examples

Volume

apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - name: myfrontend
    image: nginx
    volumeMounts:
    - mountPath: /var/www/html
      name: my-disk
  volumes:
    - name: my-disk
      flexVolume:
        driver: pragkent.me/aliyun-disk
        fsType: ext4
        options:
          diskId: "d-12345"

Static PersistentVolume

apiVersion: v1
kind: PersistentVolume
metadata:
  name: myvol
  labels:
    type: aliyundisk
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  flexVolume:
    driver: pragkent.me/aliyun-disk
    fsType: ext4
    options:
      diskId: "d-12345"

Dynamic PersistentVolume and StorageClass

Deploy aliyundisk-provisioner on your cluster first.

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: ssd
provisioner: pragkent.me/aliyun-disk
parameters:
  category: cloud_ssd

---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: my-pvd-claim
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ssd
  resources:
    requests:
      storage: 5Gi