github.com/qsunny/k8s@v0.0.0-20220101153623-e6dca256d5bf/examples-master/staging/volumes/scaleio/README.md (about)

     1  # Dell EMC ScaleIO Volume Plugin for Kubernetes
     2  
     3  This document shows how to configure Kubernetes resources to consume storage from volumes hosted on ScaleIO cluster.
     4  
     5  ## Pre-Requisites
     6  
     7  * Kubernetes ver 1.6 or later
     8  * ScaleIO ver 2.0 or later
     9  * A ScaleIO cluster with an API gateway
    10  * ScaleIO SDC binary installed/configured on each Kubernetes node that will consume storage
    11  
    12  ## ScaleIO Setup
    13  
    14  This document assumes you are familiar with ScaleIO and have a cluster ready to go.  If you are *not familiar* with ScaleIO, please review *Learn how to setup a 3-node* [ScaleIO cluster on Vagrant](https://github.com/codedellemc/labs/tree/master/setup-scaleio-vagrant) and see *General instructions on* [setting up ScaleIO](https://www.emc.com/products-solutions/trial-software-download/scaleio.htm)
    15  
    16  For this demonstration, ensure the following:
    17  
    18   - The ScaleIO `SDC` component is installed and properly configured on all Kubernetes nodes where deployed pods will consume ScaleIO-backed storage.
    19   - You have a configured ScaleIO gateway that is accessible from the Kubernetes nodes.
    20  
    21  ## Deploy Kubernetes Secret for ScaleIO
    22  
    23  The ScaleIO plugin uses a Kubernetes Secret object to store the `username` and `password` credentials.  Kubernetes requires the secret values to be base64-encoded to simply obfuscate (not encrypt) the clear text as shown below.
    24  
    25  ```
    26  $> echo -n "siouser" | base64
    27  c2lvdXNlcg==
    28  $> echo -n "sc@l3I0" | base64
    29  c2NAbDNJMA==
    30  ```
    31  The previous will generate `base64-encoded` values for the username and password.
    32  Remember to generate the credentials for your own environment and copy them in a secret file similar to the following.
    33  
    34  File: [secret.yaml](secret.yaml)
    35  
    36  ```
    37  apiVersion: v1
    38  kind: Secret
    39  metadata:
    40    name: sio-secret
    41  type: kubernetes.io/scaleio
    42  data:
    43    username: c2lvdXNlcg==
    44    password: c2NAbDNJMA==
    45  ```
    46  
    47  Notice the name of the secret specified above as `sio-secret`.  It will be referred in other YAML configuration files later.  Next, deploy the secret.
    48  
    49  ```
    50  $ kubectl create -f ./examples/volumes/scaleio/secret.yaml
    51  ```
    52  Read more about Kubernetes secrets [here](https://kubernetes.io/docs/concepts/configuration/secret/).
    53  
    54  ## Deploying Pods with Persistent Volumes
    55  
    56  The example presented in this section shows how the ScaleIO volume plugin can automatically attach, format, and mount an existing ScaleIO volume for pod.  The Kubernetes ScaleIO volume spec supports the following attributes:
    57  
    58  | Attribute | Description |
    59  |-----------|-------------|
    60  | gateway | address to a ScaleIO API gateway (required)|
    61  | system  | the name of the ScaleIO system (required)|
    62  | protectionDomain| the name of the ScaleIO protection domain (required)|
    63  | storagePool| the name of the volume storage pool (required)|
    64  | storageMode| the storage provision mode: `ThinProvisioned` (default) or `ThickProvisioned`|
    65  | volumeName| the name of an existing volume in ScaleIO (required)|
    66  | secretRef:name| references the name of a Secret object (required)|
    67  | readOnly| specifies the access mode to the mounted volume (default `false`)|
    68  | fsType| the file system to use for the volume (default `ext4`)|
    69  
    70  ### Create Volume
    71  
    72  When using static persistent volumes, it is required that the volume, to be consumed by the pod, be already created in ScaleIO.  For this demo, we assume there's an existing ScaleIO volume named `vol-0` which is reflected configuration properly `volumeName:`  below.
    73  
    74  ### Deploy Pod YAML
    75  
    76  Create a pod YAML file that declares the volume (above) to be used.
    77  
    78  File: [pod.yaml](pod.yaml)
    79  
    80  ```
    81  apiVersion: v1
    82  kind: Pod
    83  metadata:
    84    name: pod-0
    85  spec:
    86    containers:
    87    - image: k8s.gcr.io/test-webserver
    88      name: pod-0
    89      volumeMounts:
    90      - mountPath: /test-pd
    91        name: vol-0
    92    volumes:
    93    - name: vol-0
    94      scaleIO:
    95        gateway: https://localhost:443/api
    96        system: scaleio
    97        protectionDomain: pd01
    98        storagePool: sp01
    99        volumeName: vol-0
   100        secretRef:
   101          name: sio-secret
   102        fsType: xfs
   103  ```
   104  Remember to change the ScaleIO attributes above to reflect that of your own environment.
   105  
   106  Next, deploy the pod.
   107  
   108  ```
   109  $> kubectl create -f examples/volumes/scaleio/pod.yaml
   110  ```
   111  You can verify the pod:
   112  ```
   113  $> kubectl get pod
   114  NAME      READY     STATUS    RESTARTS   AGE
   115  pod-0     1/1       Running   0          33s
   116  ```
   117  Or for more detail, use
   118  ```
   119  kubectl describe pod pod-0
   120  ```
   121  You can see the attached/mapped volume on the node:
   122  ```
   123  $> lsblk
   124  NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
   125  ...
   126  scinia      252:0    0    8G  0 disk /var/lib/kubelet/pods/135986c7-dcb7-11e6-9fbf-080027c990a7/volumes/kubernetes.io~scaleio/vol-0
   127  ```
   128  
   129  ## StorageClass and Dynamic Provisioning
   130  
   131  The ScaleIO volume plugin can also dynamically provision storage to a Kubernetes cluster.
   132  The ScaleIO dynamic provisioner plugin can be used with a `StorageClass` and is identified as `kubernetes.io/scaleio`.
   133  
   134  ### ScaleIO StorageClass
   135  The ScaleIO dynamic provisioning plugin supports the following StorageClass parameters:
   136  
   137  | Parameter | Description |
   138  |-----------|-------------|
   139  | gateway | address to a ScaleIO API gateway (required)|
   140  | system  | the name of the ScaleIO system (required)|
   141  | protectionDomain| the name of the ScaleIO protection domain (required)|
   142  | storagePool| the name of the volume storage pool (required)|
   143  | storageMode| the storage provision mode: `ThinProvisioned` (default) or `ThickProvisioned`|
   144  | secretRef| reference to the name of a configuered Secret object (required)|
   145  | readOnly| specifies the access mode to the mounted volume (default `false`)|
   146  | fsType| the file system to use for the volume (default `ext4`)|
   147  
   148  The following shows an example of ScaleIO  `StorageClass` configuration YAML:
   149  
   150  File [sc.yaml](sc.yaml)
   151  
   152  ```
   153  kind: StorageClass
   154  apiVersion: storage.k8s.io/v1
   155  metadata:
   156    name: sio-small
   157  provisioner: kubernetes.io/scaleio
   158  parameters:
   159    gateway: https://localhost:443/api
   160    system: scaleio
   161    protectionDomain: pd01
   162    storagePool: sp01
   163    secretRef: sio-secret
   164    fsType: xfs
   165  ```
   166  Note the `metadata:name` attribute of the StorageClass is set to `sio-small` and will be referenced later.  Again, remember to update other parameters to reflect your environment setup.
   167  
   168  Next, deploy the storage class file.
   169  
   170  ```
   171  $> kubectl create -f examples/volumes/scaleio/sc.yaml
   172  
   173  $> kubectl get sc
   174  NAME        TYPE
   175  sio-small   kubernetes.io/scaleio
   176  ```
   177  
   178  ### PVC for the StorageClass
   179  
   180  The next step is to define/deploy a `PersistentVolumeClaim` that will use the StorageClass.
   181  
   182  File [sc-pvc.yaml](sc-pvc.yaml)
   183  
   184  ```
   185  kind: PersistentVolumeClaim
   186  apiVersion: v1
   187  metadata:
   188    name: pvc-sio-small
   189  spec:
   190    storageClassName: sio-small
   191    accessModes:
   192      - ReadWriteOnce
   193    resources:
   194      requests:
   195        storage: 10Gi
   196  ```
   197  
   198  Note the `spec:storageClassName` entry which specifies the name of the previously defined StorageClass `sio-small` .
   199  
   200  Next, deploy the PVC file.  This step will cause the Kubernetes ScaleIO plugin to create the volume in the storage system.
   201  ```
   202  $> kubectl create -f examples/volumes/scaleio/sc-pvc.yaml
   203  ```
   204  You verify that a new volume created in the ScaleIO dashboard.  You can also verify the newly created volume as follows.
   205  ```
   206   kubectl get pvc
   207  NAME            STATUS    VOLUME                CAPACITY   ACCESSMODES   AGE
   208  pvc-sio-small   Bound     k8svol-5fc78518dcae   10Gi       RWO           1h
   209  ```
   210  
   211  ###Pod for PVC and SC
   212  At this point, the volume is created (by the claim) in the storage system.  To use it, we must define a pod that references the volume as done in this YAML.
   213  
   214  File [pod-sc-pvc.yaml](pod-sc-pvc.yaml)
   215  
   216  ```
   217  kind: Pod
   218  apiVersion: v1
   219  metadata:
   220    name: pod-sio-small
   221  spec:
   222    containers:
   223      - name: pod-sio-small-container
   224        image: k8s.gcr.io/test-webserver
   225        volumeMounts:
   226        - mountPath: /test
   227          name: test-data
   228    volumes:
   229      - name: test-data
   230        persistentVolumeClaim:
   231          claimName: pvc-sio-small
   232  ```
   233  
   234  Notice that the `claimName:` attribute refers to the name of the PVC, `pvc-sio-small`, defined and deployed earlier.  Next, let us deploy the file.
   235  
   236  ```
   237  $> kubectl create -f examples/volumes/scaleio/pod-sc-pvc.yaml
   238  ```
   239  We can now verify that the new pod is deployed OK.
   240  ```
   241  kubectl get pod
   242  NAME            READY     STATUS    RESTARTS   AGE
   243  pod-0           1/1       Running   0          23m
   244  pod-sio-small   1/1       Running   0          5s
   245  ```
   246  <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
   247  [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/examples/volumes/scaleio/README.md?pixel)]()
   248  <!-- END MUNGE: GENERATED_ANALYTICS -->