text
stringlengths
0
59.1k
For this demonstration, ensure the following:
- The ScaleIO `SDC` component is installed and properly configured on all Kubernetes nodes where deployed pods will consume ScaleIO-backed storage.
- You have a configured ScaleIO gateway that is accessible from the Kubernetes nodes.
## Deploy Kubernetes Secret for ScaleIO
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.
```
$> echo -n "siouser" | base64
c2lvdXNlcg==
$> echo -n "sc@l3I0" | base64
c2NAbDNJMA==
```
The previous will generate `base64-encoded` values for the username and password.
Remember to generate the credentials for your own environment and copy them in a secret file similar to the following.
File: [secret.yaml](secret.yaml)
```
apiVersion: v1
kind: Secret
metadata:
name: sio-secret
type: kubernetes.io/scaleio
data:
username: c2lvdXNlcg==
password: c2NAbDNJMA==
```
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.
```
$ kubectl create -f ./examples/volumes/scaleio/secret.yaml
```
Read more about Kubernetes secrets [here](https://kubernetes.io/docs/concepts/configuration/secret/).
## Deploying Pods with Persistent Volumes
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:
| Attribute | Description |
|-----------|-------------|
| gateway | address to a ScaleIO API gateway (required)|
| system | the name of the ScaleIO system (required)|
| protectionDomain| the name of the ScaleIO protection domain (required)|
| storagePool| the name of the volume storage pool (required)|
| storageMode| the storage provision mode: `ThinProvisioned` (default) or `ThickProvisioned`|
| volumeName| the name of an existing volume in ScaleIO (required)|
| secretRef:name| references the name of a Secret object (required)|
| readOnly| specifies the access mode to the mounted volume (default `false`)|
| fsType| the file system to use for the volume (default `ext4`)|
### Create Volume
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.
### Deploy Pod YAML
Create a pod YAML file that declares the volume (above) to be used.
File: [pod.yaml](pod.yaml)
```
apiVersion: v1
kind: Pod
metadata:
name: pod-0
spec:
containers:
- image: registry.k8s.io/test-webserver
name: pod-0
volumeMounts:
- mountPath: /test-pd
name: vol-0
volumes:
- name: vol-0
scaleIO:
gateway: https://localhost:443/api
system: scaleio
protectionDomain: pd01
storagePool: sp01
volumeName: vol-0
secretRef:
name: sio-secret
fsType: xfs
```
Remember to change the ScaleIO attributes above to reflect that of your own environment.
Next, deploy the pod.
```
$> kubectl create -f examples/volumes/scaleio/pod.yaml
```
You can verify the pod:
```
$> kubectl get pod
NAME READY STATUS RESTARTS AGE