mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 05:30:26 +00:00
Flexvolume: Add support for multiple secrets
This commit is contained in:
@@ -53,22 +53,62 @@ Driver will be invoked with 'Init' to initialize the driver. It will be invoked
|
||||
### Driver invocation model:
|
||||
|
||||
Init:
|
||||
\<driver executable\> init
|
||||
|
||||
```
|
||||
<driver executable> init
|
||||
```
|
||||
|
||||
Attach:
|
||||
\<driver executable\> attach \<json options\>
|
||||
|
||||
```
|
||||
<driver executable> attach <json options>
|
||||
```
|
||||
|
||||
Detach:
|
||||
\<driver executable\> detach \<mount device\>
|
||||
|
||||
```
|
||||
<driver executable> detach <mount device>
|
||||
```
|
||||
|
||||
Mount:
|
||||
\<driver executable\> mount \<target mount dir\> \<mount device\> \<json options\>
|
||||
|
||||
```
|
||||
<driver executable> mount <target mount dir> <mount device> <json options>
|
||||
```
|
||||
|
||||
Unmount:
|
||||
\<driver executable\> unmount \<mount dir\>
|
||||
|
||||
```
|
||||
<driver executable> unmount <mount dir>
|
||||
```
|
||||
|
||||
See lvm[lvm] for a quick example on how to write a simple flexvolume driver.
|
||||
|
||||
### Driver output:
|
||||
|
||||
Flexvolume expects the driver to reply with the status of the operation in the
|
||||
following format.
|
||||
|
||||
```
|
||||
{
|
||||
"status": "<Success/Failure>",
|
||||
"message": "<Reason for success/failure>",
|
||||
"device": "<Path to the device attached. This field is valid only for attach calls>"
|
||||
}
|
||||
```
|
||||
|
||||
### Default Json options
|
||||
|
||||
In addition to the flags specified by the user in the Options field of the FlexVolumeSource, the following flags are also passed to the executable.
|
||||
|
||||
```
|
||||
"kubernetes.io/fsType":"<FS type>",
|
||||
"kubernetes.io/readwrite":"<rw>",
|
||||
"kubernetes.io/secret/key1":"<secret1>"
|
||||
...
|
||||
"kubernetes.io/secret/keyN":"<secretN>"
|
||||
```
|
||||
|
||||
### Example of Flexvolume
|
||||
|
||||
See nginx.yaml[nginx.yaml] for a quick example on how to use Flexvolume in a pod.
|
||||
|
@@ -14,6 +14,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Notes:
|
||||
# - Please install "jq" package before using this driver.
|
||||
usage() {
|
||||
err "Invalid usage. Usage: "
|
||||
err "\t$0 init"
|
||||
@@ -46,6 +48,10 @@ attach() {
|
||||
SIZE=$(echo $1 | jq -r '.size')
|
||||
VG=$(echo $1|jq -r '.volumegroup')
|
||||
|
||||
# LVM substitutes - with --
|
||||
VOLUMEID= `echo $VOLUMEID|sed s/-/--/g`
|
||||
VG=`echo $VG|sed s/-/--/g`
|
||||
|
||||
DMDEV="/dev/mapper/${VG}-${VOLUMEID}"
|
||||
if [ ! -b "${DMDEV}" ]; then
|
||||
err "{\"status\": \"Failure\", \"message\": \"Volume ${VOLUMEID} does not exist\"}"
|
||||
@@ -77,7 +83,7 @@ domount() {
|
||||
|
||||
VOLFSTYPE=`blkid -o udev ${DMDEV} 2>/dev/null|grep "ID_FS_TYPE"|cut -d"=" -f2`
|
||||
if [ "${VOLFSTYPE}" == "" ]; then
|
||||
mkfs -t ${FSTYPE} ${DMDEV}
|
||||
mkfs -t ${FSTYPE} ${DMDEV} >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
err "{ \"status\": \"Failure\", \"message\": \"Failed to create fs ${FSTYPE} on device ${DMDEV}\"}"
|
||||
exit 1
|
||||
|
Reference in New Issue
Block a user