mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
Merge pull request #56460 from liggitt/flex-pv-secret
Automatic merge from submit-queue (batch tested with PRs 56413, 56322, 56490, 56460, 56487). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Allow FlexVolume PV secret namespaces Completes the secret namespace PV refactor, so all PV volume sources that specify secrets can reference them outside the PVC namespace. Finished the secret-related aspect of https://github.com/kubernetes/kubernetes/issues/32131 ```release-note PersistentVolume flexVolume sources can now reference secrets in a namespace other than the PersistentVolumeClaim's namespace. ```
This commit is contained in:
commit
d9b45d08c0
33
api/openapi-spec/swagger.json
generated
33
api/openapi-spec/swagger.json
generated
@ -75654,6 +75654,37 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"io.k8s.api.core.v1.FlexPersistentVolumeSource": {
|
||||
"description": "FlexPersistentVolumeSource represents a generic persistent volume resource that is provisioned/attached using an exec based plugin.",
|
||||
"required": [
|
||||
"driver"
|
||||
],
|
||||
"properties": {
|
||||
"driver": {
|
||||
"description": "Driver is the name of the driver to use for this volume.",
|
||||
"type": "string"
|
||||
},
|
||||
"fsType": {
|
||||
"description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". The default filesystem depends on FlexVolume script.",
|
||||
"type": "string"
|
||||
},
|
||||
"options": {
|
||||
"description": "Optional: Extra command options if any.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"readOnly": {
|
||||
"description": "Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"secretRef": {
|
||||
"description": "Optional: SecretRef is reference to the secret object containing sensitive information to pass to the plugin scripts. This may be empty if no secret object is specified. If the secret object contains more than one secret, all secrets are passed to the plugin scripts.",
|
||||
"$ref": "#/definitions/io.k8s.api.core.v1.SecretReference"
|
||||
}
|
||||
}
|
||||
},
|
||||
"io.k8s.api.core.v1.FlexVolumeSource": {
|
||||
"description": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.",
|
||||
"required": [
|
||||
@ -77007,7 +77038,7 @@
|
||||
},
|
||||
"flexVolume": {
|
||||
"description": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.",
|
||||
"$ref": "#/definitions/io.k8s.api.core.v1.FlexVolumeSource"
|
||||
"$ref": "#/definitions/io.k8s.api.core.v1.FlexPersistentVolumeSource"
|
||||
},
|
||||
"flocker": {
|
||||
"description": "Flocker represents a Flocker volume attached to a kubelet's host machine and exposed to the pod for its usage. This depends on the Flocker control service being running",
|
||||
|
59
api/swagger-spec/v1.json
generated
59
api/swagger-spec/v1.json
generated
@ -20606,7 +20606,7 @@
|
||||
"description": "Flocker represents a Flocker volume attached to a kubelet's host machine and exposed to the pod for its usage. This depends on the Flocker control service being running"
|
||||
},
|
||||
"flexVolume": {
|
||||
"$ref": "v1.FlexVolumeSource",
|
||||
"$ref": "v1.FlexPersistentVolumeSource",
|
||||
"description": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin."
|
||||
},
|
||||
"azureFile": {
|
||||
@ -21020,9 +21020,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.FlexVolumeSource": {
|
||||
"id": "v1.FlexVolumeSource",
|
||||
"description": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.",
|
||||
"v1.FlexPersistentVolumeSource": {
|
||||
"id": "v1.FlexPersistentVolumeSource",
|
||||
"description": "FlexPersistentVolumeSource represents a generic persistent volume resource that is provisioned/attached using an exec based plugin.",
|
||||
"required": [
|
||||
"driver"
|
||||
],
|
||||
@ -21036,7 +21036,7 @@
|
||||
"description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". The default filesystem depends on FlexVolume script."
|
||||
},
|
||||
"secretRef": {
|
||||
"$ref": "v1.LocalObjectReference",
|
||||
"$ref": "v1.SecretReference",
|
||||
"description": "Optional: SecretRef is reference to the secret object containing sensitive information to pass to the plugin scripts. This may be empty if no secret object is specified. If the secret object contains more than one secret, all secrets are passed to the plugin scripts."
|
||||
},
|
||||
"readOnly": {
|
||||
@ -21049,16 +21049,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.LocalObjectReference": {
|
||||
"id": "v1.LocalObjectReference",
|
||||
"description": "LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.AzureFilePersistentVolumeSource": {
|
||||
"id": "v1.AzureFilePersistentVolumeSource",
|
||||
"description": "AzureFile represents an Azure File Service mount on the host and bind mount to the pod.",
|
||||
@ -21803,6 +21793,16 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.LocalObjectReference": {
|
||||
"id": "v1.LocalObjectReference",
|
||||
"description": "LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.PersistentVolumeClaimVolumeSource": {
|
||||
"id": "v1.PersistentVolumeClaimVolumeSource",
|
||||
"description": "PersistentVolumeClaimVolumeSource references the user's PVC in the same namespace. This volume finds the bound PV and mounts that volume for the pod. A PersistentVolumeClaimVolumeSource is, essentially, a wrapper around another type of volume that is owned by someone else (the system).",
|
||||
@ -21865,6 +21865,35 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.FlexVolumeSource": {
|
||||
"id": "v1.FlexVolumeSource",
|
||||
"description": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.",
|
||||
"required": [
|
||||
"driver"
|
||||
],
|
||||
"properties": {
|
||||
"driver": {
|
||||
"type": "string",
|
||||
"description": "Driver is the name of the driver to use for this volume."
|
||||
},
|
||||
"fsType": {
|
||||
"type": "string",
|
||||
"description": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". The default filesystem depends on FlexVolume script."
|
||||
},
|
||||
"secretRef": {
|
||||
"$ref": "v1.LocalObjectReference",
|
||||
"description": "Optional: SecretRef is reference to the secret object containing sensitive information to pass to the plugin scripts. This may be empty if no secret object is specified. If the secret object contains more than one secret, all secrets are passed to the plugin scripts."
|
||||
},
|
||||
"readOnly": {
|
||||
"type": "boolean",
|
||||
"description": "Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts."
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
"description": "Optional: Extra command options if any."
|
||||
}
|
||||
}
|
||||
},
|
||||
"v1.CephFSVolumeSource": {
|
||||
"id": "v1.CephFSVolumeSource",
|
||||
"description": "Represents a Ceph Filesystem mount that lasts the lifetime of a pod Cephfs volumes do not support ownership management or SELinux relabeling.",
|
||||
|
132
docs/api-reference/v1/definitions.html
generated
132
docs/api-reference/v1/definitions.html
generated
@ -3531,6 +3531,40 @@ Examples:<br>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_v1_servicestatus">v1.ServiceStatus</h3>
|
||||
<div class="paragraph">
|
||||
<p>ServiceStatus represents the current status of a service.</p>
|
||||
</div>
|
||||
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
||||
<colgroup>
|
||||
<col style="width:20%;">
|
||||
<col style="width:20%;">
|
||||
<col style="width:20%;">
|
||||
<col style="width:20%;">
|
||||
<col style="width:20%;">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="tableblock halign-left valign-top">Name</th>
|
||||
<th class="tableblock halign-left valign-top">Description</th>
|
||||
<th class="tableblock halign-left valign-top">Required</th>
|
||||
<th class="tableblock halign-left valign-top">Schema</th>
|
||||
<th class="tableblock halign-left valign-top">Default</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">loadBalancer</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">LoadBalancer contains the current status of the load-balancer, if one is present.</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_loadbalancerstatus">v1.LoadBalancerStatus</a></p></td>
|
||||
<td class="tableblock halign-left valign-top"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_v1_nfsvolumesource">v1.NFSVolumeSource</h3>
|
||||
@ -3579,40 +3613,6 @@ Examples:<br>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_v1_servicestatus">v1.ServiceStatus</h3>
|
||||
<div class="paragraph">
|
||||
<p>ServiceStatus represents the current status of a service.</p>
|
||||
</div>
|
||||
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
||||
<colgroup>
|
||||
<col style="width:20%;">
|
||||
<col style="width:20%;">
|
||||
<col style="width:20%;">
|
||||
<col style="width:20%;">
|
||||
<col style="width:20%;">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="tableblock halign-left valign-top">Name</th>
|
||||
<th class="tableblock halign-left valign-top">Description</th>
|
||||
<th class="tableblock halign-left valign-top">Required</th>
|
||||
<th class="tableblock halign-left valign-top">Schema</th>
|
||||
<th class="tableblock halign-left valign-top">Default</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">loadBalancer</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">LoadBalancer contains the current status of the load-balancer, if one is present.</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_loadbalancerstatus">v1.LoadBalancerStatus</a></p></td>
|
||||
<td class="tableblock halign-left valign-top"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_v1_httpheader">v1.HTTPHeader</h3>
|
||||
@ -4089,7 +4089,7 @@ Examples:<br>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">flexVolume</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_flexvolumesource">v1.FlexVolumeSource</a></p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_flexpersistentvolumesource">v1.FlexPersistentVolumeSource</a></p></td>
|
||||
<td class="tableblock halign-left valign-top"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -6880,6 +6880,68 @@ Examples:<br>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_v1_flexpersistentvolumesource">v1.FlexPersistentVolumeSource</h3>
|
||||
<div class="paragraph">
|
||||
<p>FlexPersistentVolumeSource represents a generic persistent volume resource that is provisioned/attached using an exec based plugin.</p>
|
||||
</div>
|
||||
<table class="tableblock frame-all grid-all" style="width:100%; ">
|
||||
<colgroup>
|
||||
<col style="width:20%;">
|
||||
<col style="width:20%;">
|
||||
<col style="width:20%;">
|
||||
<col style="width:20%;">
|
||||
<col style="width:20%;">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="tableblock halign-left valign-top">Name</th>
|
||||
<th class="tableblock halign-left valign-top">Description</th>
|
||||
<th class="tableblock halign-left valign-top">Required</th>
|
||||
<th class="tableblock halign-left valign-top">Schema</th>
|
||||
<th class="tableblock halign-left valign-top">Default</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">driver</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">Driver is the name of the driver to use for this volume.</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
|
||||
<td class="tableblock halign-left valign-top"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">fsType</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". The default filesystem depends on FlexVolume script.</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
|
||||
<td class="tableblock halign-left valign-top"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">secretRef</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">Optional: SecretRef is reference to the secret object containing sensitive information to pass to the plugin scripts. This may be empty if no secret object is specified. If the secret object contains more than one secret, all secrets are passed to the plugin scripts.</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_secretreference">v1.SecretReference</a></p></td>
|
||||
<td class="tableblock halign-left valign-top"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">readOnly</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">boolean</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">options</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">Optional: Extra command options if any.</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock">object</p></td>
|
||||
<td class="tableblock halign-left valign-top"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_v1_endpointslist">v1.EndpointsList</h3>
|
||||
|
@ -62,8 +62,16 @@ func VisitPVSecretNames(pv *api.PersistentVolume, visitor Visitor) bool {
|
||||
}
|
||||
}
|
||||
case source.FlexVolume != nil:
|
||||
if source.FlexVolume.SecretRef != nil && !visitor(getClaimRefNamespace(pv), source.FlexVolume.SecretRef.Name) {
|
||||
return false
|
||||
if source.FlexVolume.SecretRef != nil {
|
||||
// previously persisted PV objects use claimRef namespace
|
||||
ns := getClaimRefNamespace(pv)
|
||||
if len(source.FlexVolume.SecretRef.Namespace) > 0 {
|
||||
// use the secret namespace if namespace is set
|
||||
ns = source.FlexVolume.SecretRef.Namespace
|
||||
}
|
||||
if !visitor(ns, source.FlexVolume.SecretRef.Name) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
case source.RBD != nil:
|
||||
if source.RBD.SecretRef != nil {
|
||||
|
@ -61,8 +61,15 @@ func TestPVSecrets(t *testing.T) {
|
||||
{Spec: api.PersistentVolumeSpec{
|
||||
ClaimRef: &api.ObjectReference{Namespace: "claimrefns", Name: "claimrefname"},
|
||||
PersistentVolumeSource: api.PersistentVolumeSource{
|
||||
FlexVolume: &api.FlexVolumeSource{
|
||||
SecretRef: &api.LocalObjectReference{
|
||||
FlexVolume: &api.FlexPersistentVolumeSource{
|
||||
SecretRef: &api.SecretReference{
|
||||
Name: "Spec.PersistentVolumeSource.FlexVolume.SecretRef",
|
||||
Namespace: "flexns"}}}}},
|
||||
{Spec: api.PersistentVolumeSpec{
|
||||
ClaimRef: &api.ObjectReference{Namespace: "claimrefns", Name: "claimrefname"},
|
||||
PersistentVolumeSource: api.PersistentVolumeSource{
|
||||
FlexVolume: &api.FlexPersistentVolumeSource{
|
||||
SecretRef: &api.SecretReference{
|
||||
Name: "Spec.PersistentVolumeSource.FlexVolume.SecretRef"}}}}},
|
||||
{Spec: api.PersistentVolumeSpec{
|
||||
ClaimRef: &api.ObjectReference{Namespace: "claimrefns", Name: "claimrefname"},
|
||||
@ -160,15 +167,22 @@ func TestPVSecrets(t *testing.T) {
|
||||
expectedNamespacedNames := sets.NewString(
|
||||
"claimrefns/Spec.PersistentVolumeSource.AzureFile.SecretName",
|
||||
"Spec.PersistentVolumeSource.AzureFile.SecretNamespace/Spec.PersistentVolumeSource.AzureFile.SecretName",
|
||||
|
||||
"claimrefns/Spec.PersistentVolumeSource.CephFS.SecretRef",
|
||||
"cephfs/Spec.PersistentVolumeSource.CephFS.SecretRef",
|
||||
|
||||
"claimrefns/Spec.PersistentVolumeSource.FlexVolume.SecretRef",
|
||||
"flexns/Spec.PersistentVolumeSource.FlexVolume.SecretRef",
|
||||
|
||||
"claimrefns/Spec.PersistentVolumeSource.RBD.SecretRef",
|
||||
"rbdns/Spec.PersistentVolumeSource.RBD.SecretRef",
|
||||
|
||||
"claimrefns/Spec.PersistentVolumeSource.ScaleIO.SecretRef",
|
||||
"scaleions/Spec.PersistentVolumeSource.ScaleIO.SecretRef",
|
||||
|
||||
"claimrefns/Spec.PersistentVolumeSource.ISCSI.SecretRef",
|
||||
"iscsi/Spec.PersistentVolumeSource.ISCSI.SecretRef",
|
||||
|
||||
"storageosns/Spec.PersistentVolumeSource.StorageOS.SecretRef",
|
||||
)
|
||||
if missingNames := expectedNamespacedNames.Difference(extractedNamesWithNamespace); len(missingNames) > 0 {
|
||||
|
@ -354,7 +354,7 @@ type PersistentVolumeSource struct {
|
||||
// FlexVolume represents a generic volume resource that is
|
||||
// provisioned/attached using an exec based plugin.
|
||||
// +optional
|
||||
FlexVolume *FlexVolumeSource
|
||||
FlexVolume *FlexPersistentVolumeSource
|
||||
// Cinder represents a cinder volume attached and mounted on kubelets host machine
|
||||
// +optional
|
||||
Cinder *CinderVolumeSource
|
||||
@ -867,6 +867,32 @@ type FCVolumeSource struct {
|
||||
WWIDs []string
|
||||
}
|
||||
|
||||
// FlexPersistentVolumeSource represents a generic persistent volume resource that is
|
||||
// provisioned/attached using an exec based plugin.
|
||||
type FlexPersistentVolumeSource struct {
|
||||
// Driver is the name of the driver to use for this volume.
|
||||
Driver string
|
||||
// Filesystem type to mount.
|
||||
// Must be a filesystem type supported by the host operating system.
|
||||
// Ex. "ext4", "xfs", "ntfs". The default filesystem depends on FlexVolume script.
|
||||
// +optional
|
||||
FSType string
|
||||
// Optional: SecretRef is reference to the secret object containing
|
||||
// sensitive information to pass to the plugin scripts. This may be
|
||||
// empty if no secret object is specified. If the secret object
|
||||
// contains more than one secret, all secrets are passed to the plugin
|
||||
// scripts.
|
||||
// +optional
|
||||
SecretRef *SecretReference
|
||||
// Optional: Defaults to false (read/write). ReadOnly here will force
|
||||
// the ReadOnly setting in VolumeMounts.
|
||||
// +optional
|
||||
ReadOnly bool
|
||||
// Optional: Extra driver options if any.
|
||||
// +optional
|
||||
Options map[string]string
|
||||
}
|
||||
|
||||
// FlexVolume represents a generic volume resource that is
|
||||
// provisioned/attached using an exec based plugin.
|
||||
type FlexVolumeSource struct {
|
||||
|
34
pkg/apis/core/v1/zz_generated.conversion.go
generated
34
pkg/apis/core/v1/zz_generated.conversion.go
generated
@ -141,6 +141,8 @@ func RegisterConversions(scheme *runtime.Scheme) error {
|
||||
Convert_core_ExecAction_To_v1_ExecAction,
|
||||
Convert_v1_FCVolumeSource_To_core_FCVolumeSource,
|
||||
Convert_core_FCVolumeSource_To_v1_FCVolumeSource,
|
||||
Convert_v1_FlexPersistentVolumeSource_To_core_FlexPersistentVolumeSource,
|
||||
Convert_core_FlexPersistentVolumeSource_To_v1_FlexPersistentVolumeSource,
|
||||
Convert_v1_FlexVolumeSource_To_core_FlexVolumeSource,
|
||||
Convert_core_FlexVolumeSource_To_v1_FlexVolumeSource,
|
||||
Convert_v1_FlockerVolumeSource_To_core_FlockerVolumeSource,
|
||||
@ -1758,6 +1760,34 @@ func Convert_core_FCVolumeSource_To_v1_FCVolumeSource(in *core.FCVolumeSource, o
|
||||
return autoConvert_core_FCVolumeSource_To_v1_FCVolumeSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_FlexPersistentVolumeSource_To_core_FlexPersistentVolumeSource(in *v1.FlexPersistentVolumeSource, out *core.FlexPersistentVolumeSource, s conversion.Scope) error {
|
||||
out.Driver = in.Driver
|
||||
out.FSType = in.FSType
|
||||
out.SecretRef = (*core.SecretReference)(unsafe.Pointer(in.SecretRef))
|
||||
out.ReadOnly = in.ReadOnly
|
||||
out.Options = *(*map[string]string)(unsafe.Pointer(&in.Options))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1_FlexPersistentVolumeSource_To_core_FlexPersistentVolumeSource is an autogenerated conversion function.
|
||||
func Convert_v1_FlexPersistentVolumeSource_To_core_FlexPersistentVolumeSource(in *v1.FlexPersistentVolumeSource, out *core.FlexPersistentVolumeSource, s conversion.Scope) error {
|
||||
return autoConvert_v1_FlexPersistentVolumeSource_To_core_FlexPersistentVolumeSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_core_FlexPersistentVolumeSource_To_v1_FlexPersistentVolumeSource(in *core.FlexPersistentVolumeSource, out *v1.FlexPersistentVolumeSource, s conversion.Scope) error {
|
||||
out.Driver = in.Driver
|
||||
out.FSType = in.FSType
|
||||
out.SecretRef = (*v1.SecretReference)(unsafe.Pointer(in.SecretRef))
|
||||
out.ReadOnly = in.ReadOnly
|
||||
out.Options = *(*map[string]string)(unsafe.Pointer(&in.Options))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_core_FlexPersistentVolumeSource_To_v1_FlexPersistentVolumeSource is an autogenerated conversion function.
|
||||
func Convert_core_FlexPersistentVolumeSource_To_v1_FlexPersistentVolumeSource(in *core.FlexPersistentVolumeSource, out *v1.FlexPersistentVolumeSource, s conversion.Scope) error {
|
||||
return autoConvert_core_FlexPersistentVolumeSource_To_v1_FlexPersistentVolumeSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_FlexVolumeSource_To_core_FlexVolumeSource(in *v1.FlexVolumeSource, out *core.FlexVolumeSource, s conversion.Scope) error {
|
||||
out.Driver = in.Driver
|
||||
out.FSType = in.FSType
|
||||
@ -3250,7 +3280,7 @@ func autoConvert_v1_PersistentVolumeSource_To_core_PersistentVolumeSource(in *v1
|
||||
out.CephFS = (*core.CephFSPersistentVolumeSource)(unsafe.Pointer(in.CephFS))
|
||||
out.FC = (*core.FCVolumeSource)(unsafe.Pointer(in.FC))
|
||||
out.Flocker = (*core.FlockerVolumeSource)(unsafe.Pointer(in.Flocker))
|
||||
out.FlexVolume = (*core.FlexVolumeSource)(unsafe.Pointer(in.FlexVolume))
|
||||
out.FlexVolume = (*core.FlexPersistentVolumeSource)(unsafe.Pointer(in.FlexVolume))
|
||||
out.AzureFile = (*core.AzureFilePersistentVolumeSource)(unsafe.Pointer(in.AzureFile))
|
||||
out.VsphereVolume = (*core.VsphereVirtualDiskVolumeSource)(unsafe.Pointer(in.VsphereVolume))
|
||||
out.Quobyte = (*core.QuobyteVolumeSource)(unsafe.Pointer(in.Quobyte))
|
||||
@ -3278,7 +3308,7 @@ func autoConvert_core_PersistentVolumeSource_To_v1_PersistentVolumeSource(in *co
|
||||
out.RBD = (*v1.RBDPersistentVolumeSource)(unsafe.Pointer(in.RBD))
|
||||
out.Quobyte = (*v1.QuobyteVolumeSource)(unsafe.Pointer(in.Quobyte))
|
||||
out.ISCSI = (*v1.ISCSIPersistentVolumeSource)(unsafe.Pointer(in.ISCSI))
|
||||
out.FlexVolume = (*v1.FlexVolumeSource)(unsafe.Pointer(in.FlexVolume))
|
||||
out.FlexVolume = (*v1.FlexPersistentVolumeSource)(unsafe.Pointer(in.FlexVolume))
|
||||
out.Cinder = (*v1.CinderVolumeSource)(unsafe.Pointer(in.Cinder))
|
||||
out.CephFS = (*v1.CephFSPersistentVolumeSource)(unsafe.Pointer(in.CephFS))
|
||||
out.FC = (*v1.FCVolumeSource)(unsafe.Pointer(in.FC))
|
||||
|
@ -1257,6 +1257,27 @@ func validateFlexVolumeSource(fv *core.FlexVolumeSource, fldPath *field.Path) fi
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateFlexPersistentVolumeSource(fv *core.FlexPersistentVolumeSource, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if len(fv.Driver) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("driver"), ""))
|
||||
}
|
||||
|
||||
// Make sure user-specified options don't use kubernetes namespaces
|
||||
for k := range fv.Options {
|
||||
namespace := k
|
||||
if parts := strings.SplitN(k, "/", 2); len(parts) == 2 {
|
||||
namespace = parts[0]
|
||||
}
|
||||
normalized := "." + strings.ToLower(namespace)
|
||||
if strings.HasSuffix(normalized, ".kubernetes.io") || strings.HasSuffix(normalized, ".k8s.io") {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("options").Key(k), k, "kubernetes.io and k8s.io namespaces are reserved"))
|
||||
}
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateAzureFile(azure *core.AzureFileVolumeSource, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if azure.SecretName == "" {
|
||||
@ -1588,7 +1609,7 @@ func ValidatePersistentVolume(pv *core.PersistentVolume) field.ErrorList {
|
||||
}
|
||||
if pv.Spec.FlexVolume != nil {
|
||||
numVolumes++
|
||||
allErrs = append(allErrs, validateFlexVolumeSource(pv.Spec.FlexVolume, specPath.Child("flexVolume"))...)
|
||||
allErrs = append(allErrs, validateFlexPersistentVolumeSource(pv.Spec.FlexVolume, specPath.Child("flexVolume"))...)
|
||||
}
|
||||
if pv.Spec.AzureFile != nil {
|
||||
if numVolumes > 0 {
|
||||
|
@ -469,7 +469,7 @@ func TestValidatePersistentVolumeSourceUpdate(t *testing.T) {
|
||||
validPvSourceNoUpdate := validVolume.DeepCopy()
|
||||
invalidPvSourceUpdateType := validVolume.DeepCopy()
|
||||
invalidPvSourceUpdateType.Spec.PersistentVolumeSource = core.PersistentVolumeSource{
|
||||
FlexVolume: &core.FlexVolumeSource{
|
||||
FlexVolume: &core.FlexPersistentVolumeSource{
|
||||
Driver: "kubernetes.io/blue",
|
||||
FSType: "ext4",
|
||||
},
|
||||
|
34
pkg/apis/core/zz_generated.deepcopy.go
generated
34
pkg/apis/core/zz_generated.deepcopy.go
generated
@ -1547,6 +1547,38 @@ func (in *FCVolumeSource) DeepCopy() *FCVolumeSource {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FlexPersistentVolumeSource) DeepCopyInto(out *FlexPersistentVolumeSource) {
|
||||
*out = *in
|
||||
if in.SecretRef != nil {
|
||||
in, out := &in.SecretRef, &out.SecretRef
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(SecretReference)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
if in.Options != nil {
|
||||
in, out := &in.Options, &out.Options
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlexPersistentVolumeSource.
|
||||
func (in *FlexPersistentVolumeSource) DeepCopy() *FlexPersistentVolumeSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FlexPersistentVolumeSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FlexVolumeSource) DeepCopyInto(out *FlexVolumeSource) {
|
||||
*out = *in
|
||||
@ -3152,7 +3184,7 @@ func (in *PersistentVolumeSource) DeepCopyInto(out *PersistentVolumeSource) {
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(FlexVolumeSource)
|
||||
*out = new(FlexPersistentVolumeSource)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
@ -1076,6 +1076,16 @@ func printAzureFilePersistentVolumeSource(azureFile *api.AzureFilePersistentVolu
|
||||
azureFile.SecretName, ns, azureFile.ShareName, azureFile.ReadOnly)
|
||||
}
|
||||
|
||||
func printFlexPersistentVolumeSource(flex *api.FlexPersistentVolumeSource, w PrefixWriter) {
|
||||
w.Write(LEVEL_2, "Type:\tFlexVolume (a generic volume resource that is provisioned/attached using an exec based plugin)\n"+
|
||||
" Driver:\t%v\n"+
|
||||
" FSType:\t%v\n"+
|
||||
" SecretRef:\t%v\n"+
|
||||
" ReadOnly:\t%v\n",
|
||||
" Options:\t%v\n",
|
||||
flex.Driver, flex.FSType, flex.SecretRef, flex.ReadOnly, flex.Options)
|
||||
}
|
||||
|
||||
func printFlexVolumeSource(flex *api.FlexVolumeSource, w PrefixWriter) {
|
||||
w.Write(LEVEL_2, "Type:\tFlexVolume (a generic volume resource that is provisioned/attached using an exec based plugin)\n"+
|
||||
" Driver:\t%v\n"+
|
||||
@ -1184,7 +1194,7 @@ func describePersistentVolume(pv *api.PersistentVolume, events *api.EventList) (
|
||||
case pv.Spec.AzureFile != nil:
|
||||
printAzureFilePersistentVolumeSource(pv.Spec.AzureFile, w)
|
||||
case pv.Spec.FlexVolume != nil:
|
||||
printFlexVolumeSource(pv.Spec.FlexVolume, w)
|
||||
printFlexPersistentVolumeSource(pv.Spec.FlexVolume, w)
|
||||
case pv.Spec.Flocker != nil:
|
||||
printFlockerVolumeSource(pv.Spec.Flocker, w)
|
||||
case pv.Spec.CSI != nil:
|
||||
|
@ -48,7 +48,16 @@ func (a *attacherDefaults) GetDeviceMountPath(spec *volume.Spec, mountsDir strin
|
||||
// MountDevice is part of the volume.Attacher interface
|
||||
func (a *attacherDefaults) MountDevice(spec *volume.Spec, devicePath string, deviceMountPath string, mounter mount.Interface) error {
|
||||
glog.Warning(logPrefix(a.plugin.flexVolumePlugin), "using default MountDevice for volume ", spec.Name, ", device ", devicePath, ", deviceMountPath ", deviceMountPath)
|
||||
volSource, readOnly := getVolumeSource(spec)
|
||||
|
||||
volSourceFSType, err := getFSType(spec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
readOnly, err := getReadOnly(spec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
options := make([]string, 0)
|
||||
|
||||
@ -60,5 +69,5 @@ func (a *attacherDefaults) MountDevice(spec *volume.Spec, devicePath string, dev
|
||||
|
||||
diskMounter := &mount.SafeFormatAndMount{Interface: mounter, Exec: a.plugin.host.GetExec(a.plugin.GetPluginName())}
|
||||
|
||||
return diskMounter.FormatAndMount(devicePath, deviceMountPath, volSource.FSType, options)
|
||||
return diskMounter.FormatAndMount(devicePath, deviceMountPath, volSourceFSType, options)
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ func fakePersistentVolumeSpec() *volume.Spec {
|
||||
},
|
||||
Spec: v1.PersistentVolumeSpec{
|
||||
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||
FlexVolume: &v1.FlexVolumeSource{
|
||||
FlexVolume: &v1.FlexPersistentVolumeSource{
|
||||
Driver: "kubernetes.io/fakeAttacher",
|
||||
ReadOnly: false,
|
||||
},
|
||||
|
@ -162,10 +162,25 @@ func (dc *DriverCall) Run() (*DriverStatus, error) {
|
||||
type OptionsForDriver map[string]string
|
||||
|
||||
func NewOptionsForDriver(spec *volume.Spec, host volume.VolumeHost, extraOptions map[string]string) (OptionsForDriver, error) {
|
||||
volSource, readOnly := getVolumeSource(spec)
|
||||
|
||||
volSourceFSType, err := getFSType(spec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
readOnly, err := getReadOnly(spec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
volSourceOptions, err := getOptions(spec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
options := map[string]string{}
|
||||
|
||||
options[optionFSType] = volSource.FSType
|
||||
options[optionFSType] = volSourceFSType
|
||||
|
||||
if readOnly {
|
||||
options[optionReadWrite] = "ro"
|
||||
@ -179,7 +194,7 @@ func NewOptionsForDriver(spec *volume.Spec, host volume.VolumeHost, extraOptions
|
||||
options[key] = value
|
||||
}
|
||||
|
||||
for key, value := range volSource.Options {
|
||||
for key, value := range volSourceOptions {
|
||||
options[key] = value
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ func TestCanSupport(t *testing.T) {
|
||||
if !plugin.CanSupport(&volume.Spec{Volume: &v1.Volume{VolumeSource: v1.VolumeSource{FlexVolume: &v1.FlexVolumeSource{Driver: "kubernetes.io/fakeAttacher"}}}}) {
|
||||
t.Errorf("Expected true")
|
||||
}
|
||||
if !plugin.CanSupport(&volume.Spec{PersistentVolume: &v1.PersistentVolume{Spec: v1.PersistentVolumeSpec{PersistentVolumeSource: v1.PersistentVolumeSource{FlexVolume: &v1.FlexVolumeSource{Driver: "kubernetes.io/fakeAttacher"}}}}}) {
|
||||
if !plugin.CanSupport(&volume.Spec{PersistentVolume: &v1.PersistentVolume{Spec: v1.PersistentVolumeSpec{PersistentVolumeSource: v1.PersistentVolumeSource{FlexVolume: &v1.FlexPersistentVolumeSource{Driver: "kubernetes.io/fakeAttacher"}}}}}) {
|
||||
t.Errorf("Expected true")
|
||||
}
|
||||
if plugin.CanSupport(&volume.Spec{Volume: &v1.Volume{VolumeSource: v1.VolumeSource{}}}) {
|
||||
|
@ -132,8 +132,11 @@ func (plugin *flexVolumePlugin) GetVolumeName(spec *volume.Spec) (string, error)
|
||||
|
||||
// CanSupport is part of the volume.VolumePlugin interface.
|
||||
func (plugin *flexVolumePlugin) CanSupport(spec *volume.Spec) bool {
|
||||
source, _ := getVolumeSource(spec)
|
||||
return (source != nil) && (source.Driver == plugin.driverName)
|
||||
sourceDriver, err := getDriver(spec)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return sourceDriver == plugin.driverName
|
||||
}
|
||||
|
||||
// RequiresRemount is part of the volume.VolumePlugin interface.
|
||||
@ -156,10 +159,19 @@ func (plugin *flexVolumePlugin) NewMounter(spec *volume.Spec, pod *api.Pod, _ vo
|
||||
|
||||
// newMounterInternal is the internal mounter routine to build the volume.
|
||||
func (plugin *flexVolumePlugin) newMounterInternal(spec *volume.Spec, pod *api.Pod, mounter mount.Interface, runner exec.Interface) (volume.Mounter, error) {
|
||||
source, readOnly := getVolumeSource(spec)
|
||||
sourceDriver, err := getDriver(spec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
readOnly, err := getReadOnly(spec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &flexVolumeMounter{
|
||||
flexVolume: &flexVolume{
|
||||
driverName: source.Driver,
|
||||
driverName: sourceDriver,
|
||||
execPath: plugin.getExecutable(),
|
||||
mounter: mounter,
|
||||
plugin: plugin,
|
||||
|
@ -22,15 +22,18 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/golang/glog"
|
||||
api "k8s.io/api/core/v1"
|
||||
"k8s.io/kubernetes/pkg/util/mount"
|
||||
"k8s.io/kubernetes/pkg/volume"
|
||||
"k8s.io/kubernetes/pkg/volume/util"
|
||||
)
|
||||
|
||||
func addSecretsToOptions(options map[string]string, spec *volume.Spec, namespace string, driverName string, host volume.VolumeHost) error {
|
||||
fv, _ := getVolumeSource(spec)
|
||||
if fv.SecretRef == nil {
|
||||
secretName, secretNamespace, err := getSecretNameAndNamespace(spec, namespace)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(secretName) == 0 || len(secretNamespace) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -39,9 +42,9 @@ func addSecretsToOptions(options map[string]string, spec *volume.Spec, namespace
|
||||
return fmt.Errorf("Cannot get kube client")
|
||||
}
|
||||
|
||||
secrets, err := util.GetSecretForPV(namespace, fv.SecretRef.Name, driverName, host.GetKubeClient())
|
||||
secrets, err := util.GetSecretForPV(secretNamespace, secretName, driverName, host.GetKubeClient())
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Couldn't get secret %v/%v err: %v", namespace, fv.SecretRef.Name, err)
|
||||
err = fmt.Errorf("Couldn't get secret %v/%v err: %v", secretNamespace, secretName, err)
|
||||
return err
|
||||
}
|
||||
for name, data := range secrets {
|
||||
@ -52,15 +55,68 @@ func addSecretsToOptions(options map[string]string, spec *volume.Spec, namespace
|
||||
return nil
|
||||
}
|
||||
|
||||
func getVolumeSource(spec *volume.Spec) (volumeSource *api.FlexVolumeSource, readOnly bool) {
|
||||
var notFlexVolume = fmt.Errorf("not a flex volume")
|
||||
|
||||
func getDriver(spec *volume.Spec) (string, error) {
|
||||
if spec.Volume != nil && spec.Volume.FlexVolume != nil {
|
||||
volumeSource = spec.Volume.FlexVolume
|
||||
readOnly = volumeSource.ReadOnly
|
||||
} else if spec.PersistentVolume != nil {
|
||||
volumeSource = spec.PersistentVolume.Spec.FlexVolume
|
||||
readOnly = spec.ReadOnly
|
||||
return spec.Volume.FlexVolume.Driver, nil
|
||||
}
|
||||
return
|
||||
if spec.PersistentVolume != nil && spec.PersistentVolume.Spec.FlexVolume != nil {
|
||||
return spec.PersistentVolume.Spec.FlexVolume.Driver, nil
|
||||
}
|
||||
return "", notFlexVolume
|
||||
}
|
||||
|
||||
func getFSType(spec *volume.Spec) (string, error) {
|
||||
if spec.Volume != nil && spec.Volume.FlexVolume != nil {
|
||||
return spec.Volume.FlexVolume.FSType, nil
|
||||
}
|
||||
if spec.PersistentVolume != nil && spec.PersistentVolume.Spec.FlexVolume != nil {
|
||||
return spec.PersistentVolume.Spec.FlexVolume.FSType, nil
|
||||
}
|
||||
return "", notFlexVolume
|
||||
}
|
||||
|
||||
func getSecretNameAndNamespace(spec *volume.Spec, podNamespace string) (string, string, error) {
|
||||
if spec.Volume != nil && spec.Volume.FlexVolume != nil {
|
||||
if spec.Volume.FlexVolume.SecretRef == nil {
|
||||
return "", "", nil
|
||||
}
|
||||
return spec.Volume.FlexVolume.SecretRef.Name, podNamespace, nil
|
||||
}
|
||||
if spec.PersistentVolume != nil && spec.PersistentVolume.Spec.FlexVolume != nil {
|
||||
if spec.PersistentVolume.Spec.FlexVolume.SecretRef == nil {
|
||||
return "", "", nil
|
||||
}
|
||||
secretName := spec.PersistentVolume.Spec.FlexVolume.SecretRef.Name
|
||||
secretNamespace := spec.PersistentVolume.Spec.FlexVolume.SecretRef.Namespace
|
||||
if len(secretNamespace) == 0 {
|
||||
secretNamespace = podNamespace
|
||||
}
|
||||
return secretName, secretNamespace, nil
|
||||
}
|
||||
return "", "", notFlexVolume
|
||||
}
|
||||
|
||||
func getReadOnly(spec *volume.Spec) (bool, error) {
|
||||
if spec.Volume != nil && spec.Volume.FlexVolume != nil {
|
||||
return spec.Volume.FlexVolume.ReadOnly, nil
|
||||
}
|
||||
if spec.PersistentVolume != nil && spec.PersistentVolume.Spec.FlexVolume != nil {
|
||||
// ReadOnly is specified at the PV level
|
||||
return spec.ReadOnly, nil
|
||||
}
|
||||
return false, notFlexVolume
|
||||
}
|
||||
|
||||
func getOptions(spec *volume.Spec) (map[string]string, error) {
|
||||
if spec.Volume != nil && spec.Volume.FlexVolume != nil {
|
||||
return spec.Volume.FlexVolume.Options, nil
|
||||
}
|
||||
if spec.PersistentVolume != nil && spec.PersistentVolume.Spec.FlexVolume != nil {
|
||||
return spec.PersistentVolume.Spec.FlexVolume.Options, nil
|
||||
}
|
||||
return nil, notFlexVolume
|
||||
}
|
||||
|
||||
func prepareForMount(mounter mount.Interface, deviceMountPath string) (bool, error) {
|
||||
|
@ -410,7 +410,7 @@ func generate(opts sampleDataOpts) ([]*api.Pod, []*api.PersistentVolume) {
|
||||
for i := 0; i < opts.uniquePVCsPerPod; i++ {
|
||||
pv := &api.PersistentVolume{}
|
||||
pv.Name = fmt.Sprintf("pv%d-%s-%s", i, pod.Name, pod.Namespace)
|
||||
pv.Spec.FlexVolume = &api.FlexVolumeSource{SecretRef: &api.LocalObjectReference{Name: fmt.Sprintf("secret-%s", pv.Name)}}
|
||||
pv.Spec.FlexVolume = &api.FlexPersistentVolumeSource{SecretRef: &api.SecretReference{Name: fmt.Sprintf("secret-%s", pv.Name)}}
|
||||
pv.Spec.ClaimRef = &api.ObjectReference{Name: fmt.Sprintf("pvc%d-%s", i, pod.Name), Namespace: pod.Namespace}
|
||||
pvs = append(pvs, pv)
|
||||
|
||||
@ -421,7 +421,7 @@ func generate(opts sampleDataOpts) ([]*api.Pod, []*api.PersistentVolume) {
|
||||
for i := 0; i < opts.sharedPVCsPerPod; i++ {
|
||||
pv := &api.PersistentVolume{}
|
||||
pv.Name = fmt.Sprintf("pv%d-shared-%s", i, pod.Namespace)
|
||||
pv.Spec.FlexVolume = &api.FlexVolumeSource{SecretRef: &api.LocalObjectReference{Name: fmt.Sprintf("secret-%s", pv.Name)}}
|
||||
pv.Spec.FlexVolume = &api.FlexPersistentVolumeSource{SecretRef: &api.SecretReference{Name: fmt.Sprintf("secret-%s", pv.Name)}}
|
||||
pv.Spec.ClaimRef = &api.ObjectReference{Name: fmt.Sprintf("pvc%d-shared", i), Namespace: pod.Namespace}
|
||||
pvs = append(pvs, pv)
|
||||
|
||||
|
3276
staging/src/k8s.io/api/core/v1/generated.pb.go
generated
3276
staging/src/k8s.io/api/core/v1/generated.pb.go
generated
File diff suppressed because it is too large
Load Diff
@ -1169,6 +1169,36 @@ message FCVolumeSource {
|
||||
repeated string wwids = 5;
|
||||
}
|
||||
|
||||
// FlexPersistentVolumeSource represents a generic persistent volume resource that is
|
||||
// provisioned/attached using an exec based plugin.
|
||||
message FlexPersistentVolumeSource {
|
||||
// Driver is the name of the driver to use for this volume.
|
||||
optional string driver = 1;
|
||||
|
||||
// Filesystem type to mount.
|
||||
// Must be a filesystem type supported by the host operating system.
|
||||
// Ex. "ext4", "xfs", "ntfs". The default filesystem depends on FlexVolume script.
|
||||
// +optional
|
||||
optional string fsType = 2;
|
||||
|
||||
// Optional: SecretRef is reference to the secret object containing
|
||||
// sensitive information to pass to the plugin scripts. This may be
|
||||
// empty if no secret object is specified. If the secret object
|
||||
// contains more than one secret, all secrets are passed to the plugin
|
||||
// scripts.
|
||||
// +optional
|
||||
optional SecretReference secretRef = 3;
|
||||
|
||||
// Optional: Defaults to false (read/write). ReadOnly here will force
|
||||
// the ReadOnly setting in VolumeMounts.
|
||||
// +optional
|
||||
optional bool readOnly = 4;
|
||||
|
||||
// Optional: Extra command options if any.
|
||||
// +optional
|
||||
map<string, string> options = 5;
|
||||
}
|
||||
|
||||
// FlexVolume represents a generic volume resource that is
|
||||
// provisioned/attached using an exec based plugin.
|
||||
message FlexVolumeSource {
|
||||
@ -2441,7 +2471,7 @@ message PersistentVolumeSource {
|
||||
// FlexVolume represents a generic volume resource that is
|
||||
// provisioned/attached using an exec based plugin.
|
||||
// +optional
|
||||
optional FlexVolumeSource flexVolume = 12;
|
||||
optional FlexPersistentVolumeSource flexVolume = 12;
|
||||
|
||||
// AzureFile represents an Azure File Service mount on the host and bind mount to the pod.
|
||||
// +optional
|
||||
|
@ -418,7 +418,7 @@ type PersistentVolumeSource struct {
|
||||
// FlexVolume represents a generic volume resource that is
|
||||
// provisioned/attached using an exec based plugin.
|
||||
// +optional
|
||||
FlexVolume *FlexVolumeSource `json:"flexVolume,omitempty" protobuf:"bytes,12,opt,name=flexVolume"`
|
||||
FlexVolume *FlexPersistentVolumeSource `json:"flexVolume,omitempty" protobuf:"bytes,12,opt,name=flexVolume"`
|
||||
// AzureFile represents an Azure File Service mount on the host and bind mount to the pod.
|
||||
// +optional
|
||||
AzureFile *AzureFilePersistentVolumeSource `json:"azureFile,omitempty" protobuf:"bytes,13,opt,name=azureFile"`
|
||||
@ -1081,6 +1081,32 @@ type QuobyteVolumeSource struct {
|
||||
Group string `json:"group,omitempty" protobuf:"bytes,5,opt,name=group"`
|
||||
}
|
||||
|
||||
// FlexPersistentVolumeSource represents a generic persistent volume resource that is
|
||||
// provisioned/attached using an exec based plugin.
|
||||
type FlexPersistentVolumeSource struct {
|
||||
// Driver is the name of the driver to use for this volume.
|
||||
Driver string `json:"driver" protobuf:"bytes,1,opt,name=driver"`
|
||||
// Filesystem type to mount.
|
||||
// Must be a filesystem type supported by the host operating system.
|
||||
// Ex. "ext4", "xfs", "ntfs". The default filesystem depends on FlexVolume script.
|
||||
// +optional
|
||||
FSType string `json:"fsType,omitempty" protobuf:"bytes,2,opt,name=fsType"`
|
||||
// Optional: SecretRef is reference to the secret object containing
|
||||
// sensitive information to pass to the plugin scripts. This may be
|
||||
// empty if no secret object is specified. If the secret object
|
||||
// contains more than one secret, all secrets are passed to the plugin
|
||||
// scripts.
|
||||
// +optional
|
||||
SecretRef *SecretReference `json:"secretRef,omitempty" protobuf:"bytes,3,opt,name=secretRef"`
|
||||
// Optional: Defaults to false (read/write). ReadOnly here will force
|
||||
// the ReadOnly setting in VolumeMounts.
|
||||
// +optional
|
||||
ReadOnly bool `json:"readOnly,omitempty" protobuf:"varint,4,opt,name=readOnly"`
|
||||
// Optional: Extra command options if any.
|
||||
// +optional
|
||||
Options map[string]string `json:"options,omitempty" protobuf:"bytes,5,rep,name=options"`
|
||||
}
|
||||
|
||||
// FlexVolume represents a generic volume resource that is
|
||||
// provisioned/attached using an exec based plugin.
|
||||
type FlexVolumeSource struct {
|
||||
|
@ -616,6 +616,19 @@ func (FCVolumeSource) SwaggerDoc() map[string]string {
|
||||
return map_FCVolumeSource
|
||||
}
|
||||
|
||||
var map_FlexPersistentVolumeSource = map[string]string{
|
||||
"": "FlexPersistentVolumeSource represents a generic persistent volume resource that is provisioned/attached using an exec based plugin.",
|
||||
"driver": "Driver is the name of the driver to use for this volume.",
|
||||
"fsType": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". The default filesystem depends on FlexVolume script.",
|
||||
"secretRef": "Optional: SecretRef is reference to the secret object containing sensitive information to pass to the plugin scripts. This may be empty if no secret object is specified. If the secret object contains more than one secret, all secrets are passed to the plugin scripts.",
|
||||
"readOnly": "Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.",
|
||||
"options": "Optional: Extra command options if any.",
|
||||
}
|
||||
|
||||
func (FlexPersistentVolumeSource) SwaggerDoc() map[string]string {
|
||||
return map_FlexPersistentVolumeSource
|
||||
}
|
||||
|
||||
var map_FlexVolumeSource = map[string]string{
|
||||
"": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.",
|
||||
"driver": "Driver is the name of the driver to use for this volume.",
|
||||
|
@ -1547,6 +1547,38 @@ func (in *FCVolumeSource) DeepCopy() *FCVolumeSource {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FlexPersistentVolumeSource) DeepCopyInto(out *FlexPersistentVolumeSource) {
|
||||
*out = *in
|
||||
if in.SecretRef != nil {
|
||||
in, out := &in.SecretRef, &out.SecretRef
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(SecretReference)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
if in.Options != nil {
|
||||
in, out := &in.Options, &out.Options
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlexPersistentVolumeSource.
|
||||
func (in *FlexPersistentVolumeSource) DeepCopy() *FlexPersistentVolumeSource {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FlexPersistentVolumeSource)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FlexVolumeSource) DeepCopyInto(out *FlexVolumeSource) {
|
||||
*out = *in
|
||||
@ -3165,7 +3197,7 @@ func (in *PersistentVolumeSource) DeepCopyInto(out *PersistentVolumeSource) {
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(FlexVolumeSource)
|
||||
*out = new(FlexPersistentVolumeSource)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user